rgwfuncs 0.0.42__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.42
3
+ Version: 0.0.43
4
4
  Summary: A functional programming paradigm for mathematical modelling and data science
5
5
  Home-page: https://github.com/ryangerardwilson/rgwfunc
6
6
  Author: Ryan Gerard Wilson
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rgwfuncs"
7
- version = "0.0.42"
7
+ version = "0.0.43"
8
8
  authors = [
9
9
  { name = "Ryan Gerard Wilson", email = "ryangerardwilson@gmail.com" },
10
10
  ]
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = rgwfuncs
3
- version = 0.0.42
3
+ version = 0.0.43
4
4
  author = Ryan Gerard Wilson
5
5
  author_email = ryangerardwilson@gmail.com
6
6
  description = A functional programming paradigm for mathematical modelling and data science
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rgwfuncs
3
- Version: 0.0.42
3
+ Version: 0.0.43
4
4
  Summary: A functional programming paradigm for mathematical modelling and data science
5
5
  Home-page: https://github.com/ryangerardwilson/rgwfunc
6
6
  Author: Ryan Gerard Wilson
File without changes
File without changes