rgwfuncs 0.0.41__tar.gz → 0.0.43__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rgwfuncs-0.0.41/src/rgwfuncs.egg-info → rgwfuncs-0.0.43}/PKG-INFO +1 -1
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/pyproject.toml +1 -1
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/setup.cfg +1 -1
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs/algebra_lib.py +11 -8
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43/src/rgwfuncs.egg-info}/PKG-INFO +1 -1
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/LICENSE +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/README.md +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs/__init__.py +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs/df_lib.py +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs/docs_lib.py +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs/interactive_shell_lib.py +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs/str_lib.py +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs.egg-info/SOURCES.txt +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs.egg-info/dependency_links.txt +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs.egg-info/entry_points.txt +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs.egg-info/requires.txt +0 -0
- {rgwfuncs-0.0.41 → rgwfuncs-0.0.43}/src/rgwfuncs.egg-info/top_level.txt +0 -0
@@ -320,6 +320,7 @@ def python_polynomial_expression_to_latex(
|
|
320
320
|
latex_result = latex(expr)
|
321
321
|
return latex_result
|
322
322
|
|
323
|
+
|
323
324
|
def expand_polynomial_expression(
|
324
325
|
expression: str,
|
325
326
|
subs: Optional[Dict[str, float]] = None
|
@@ -327,15 +328,15 @@ def expand_polynomial_expression(
|
|
327
328
|
"""
|
328
329
|
Expands a polynomial expression written in Python syntax and converts it to LaTeX format.
|
329
330
|
|
330
|
-
This function takes an algebraic expression written in Python syntax,
|
331
|
-
applies polynomial expansion, and converts the expanded expression
|
331
|
+
This function takes an algebraic expression written in Python syntax,
|
332
|
+
applies polynomial expansion, and converts the expanded expression
|
332
333
|
to a LaTeX formatted string. The expression should be compatible with sympy.
|
333
334
|
|
334
335
|
Parameters:
|
335
|
-
expression (str): The algebraic expression to expand and convert to LaTeX.
|
336
|
+
expression (str): The algebraic expression to expand and convert to LaTeX.
|
336
337
|
The expression should be written using Python syntax.
|
337
|
-
subs (Optional[Dict[str, float]]): An optional dictionary of substitutions
|
338
|
-
to apply to variables in the expression
|
338
|
+
subs (Optional[Dict[str, float]]): An optional dictionary of substitutions
|
339
|
+
to apply to variables in the expression
|
339
340
|
before expansion.
|
340
341
|
|
341
342
|
Returns:
|
@@ -345,15 +346,18 @@ def expand_polynomial_expression(
|
|
345
346
|
ValueError: If the expression cannot be parsed due to syntax errors.
|
346
347
|
"""
|
347
348
|
transformations = standard_transformations + (implicit_multiplication_application,)
|
348
|
-
|
349
|
+
|
349
350
|
def parse_and_expand_expression(expr_str: str, sym_vars: Dict[str, symbols]) -> symbols:
|
350
351
|
try:
|
351
352
|
expr = parse_expr(expr_str, local_dict=sym_vars, transformations=transformations)
|
352
353
|
if subs:
|
354
|
+
# Ensure that subs is a dictionary
|
355
|
+
if not isinstance(subs, dict):
|
356
|
+
raise ValueError(f"Substitutions must be a dictionary. Received: {subs}")
|
353
357
|
subs_symbols = {symbols(k): v for k, v in subs.items()}
|
354
358
|
expr = expr.subs(subs_symbols)
|
355
359
|
return expr.expand()
|
356
|
-
except (SyntaxError, ValueError, TypeError) as e:
|
360
|
+
except (SyntaxError, ValueError, TypeError, AttributeError) as e:
|
357
361
|
raise ValueError(f"Error parsing expression: {expr_str}. Error: {e}")
|
358
362
|
|
359
363
|
variable_names = set(re.findall(r'\b[a-zA-Z]\w*\b', expression))
|
@@ -364,7 +368,6 @@ def expand_polynomial_expression(
|
|
364
368
|
return latex_result
|
365
369
|
|
366
370
|
|
367
|
-
|
368
371
|
def simplify_polynomial_expression(
|
369
372
|
expression: str,
|
370
373
|
subs: Optional[Dict[str, float]] = None
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|