rgwfuncs 0.0.39__py3-none-any.whl → 0.0.41__py3-none-any.whl
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/__init__.py +1 -1
- rgwfuncs/algebra_lib.py +44 -0
- {rgwfuncs-0.0.39.dist-info → rgwfuncs-0.0.41.dist-info}/METADATA +42 -3
- rgwfuncs-0.0.41.dist-info/RECORD +12 -0
- rgwfuncs-0.0.39.dist-info/RECORD +0 -12
- {rgwfuncs-0.0.39.dist-info → rgwfuncs-0.0.41.dist-info}/LICENSE +0 -0
- {rgwfuncs-0.0.39.dist-info → rgwfuncs-0.0.41.dist-info}/WHEEL +0 -0
- {rgwfuncs-0.0.39.dist-info → rgwfuncs-0.0.41.dist-info}/entry_points.txt +0 -0
- {rgwfuncs-0.0.39.dist-info → rgwfuncs-0.0.41.dist-info}/top_level.txt +0 -0
rgwfuncs/__init__.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# This file is automatically generated
|
2
2
|
# Dynamically importing functions from modules
|
3
3
|
|
4
|
-
from .algebra_lib import compute_constant_expression, compute_constant_expression_involving_matrices, compute_constant_expression_involving_ordered_series, compute_prime_factors, python_polynomial_expression_to_latex, simplify_polynomial_expression, solve_homogeneous_polynomial_expression
|
4
|
+
from .algebra_lib import compute_constant_expression, compute_constant_expression_involving_matrices, compute_constant_expression_involving_ordered_series, compute_prime_factors, expand_polynomial_expression, python_polynomial_expression_to_latex, simplify_polynomial_expression, solve_homogeneous_polynomial_expression
|
5
5
|
from .df_lib import append_columns, append_percentile_classification_column, append_ranged_classification_column, append_ranged_date_classification_column, append_rows, append_xgb_labels, append_xgb_logistic_regression_predictions, append_xgb_regression_predictions, bag_union_join, bottom_n_unique_values, cascade_sort, delete_rows, drop_duplicates, drop_duplicates_retain_first, drop_duplicates_retain_last, filter_dataframe, filter_indian_mobiles, first_n_rows, from_raw_data, insert_dataframe_in_sqlite_database, last_n_rows, left_join, limit_dataframe, load_data_from_path, load_data_from_query, load_data_from_sqlite_path, mask_against_dataframe, mask_against_dataframe_converse, numeric_clean, order_columns, print_correlation, print_dataframe, print_memory_usage, print_n_frequency_cascading, print_n_frequency_linear, rename_columns, retain_columns, right_join, send_data_to_email, send_data_to_slack, send_dataframe_via_telegram, sync_dataframe_to_sqlite_database, top_n_unique_values, union_join, update_rows
|
6
6
|
from .docs_lib import docs
|
7
7
|
from .interactive_shell_lib import interactive_shell
|
rgwfuncs/algebra_lib.py
CHANGED
@@ -320,6 +320,50 @@ def python_polynomial_expression_to_latex(
|
|
320
320
|
latex_result = latex(expr)
|
321
321
|
return latex_result
|
322
322
|
|
323
|
+
def expand_polynomial_expression(
|
324
|
+
expression: str,
|
325
|
+
subs: Optional[Dict[str, float]] = None
|
326
|
+
) -> str:
|
327
|
+
"""
|
328
|
+
Expands a polynomial expression written in Python syntax and converts it to LaTeX format.
|
329
|
+
|
330
|
+
This function takes an algebraic expression written in Python syntax,
|
331
|
+
applies polynomial expansion, and converts the expanded expression
|
332
|
+
to a LaTeX formatted string. The expression should be compatible with sympy.
|
333
|
+
|
334
|
+
Parameters:
|
335
|
+
expression (str): The algebraic expression to expand and convert to LaTeX.
|
336
|
+
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
|
339
|
+
before expansion.
|
340
|
+
|
341
|
+
Returns:
|
342
|
+
str: The expanded expression represented as a LaTeX string.
|
343
|
+
|
344
|
+
Raises:
|
345
|
+
ValueError: If the expression cannot be parsed due to syntax errors.
|
346
|
+
"""
|
347
|
+
transformations = standard_transformations + (implicit_multiplication_application,)
|
348
|
+
|
349
|
+
def parse_and_expand_expression(expr_str: str, sym_vars: Dict[str, symbols]) -> symbols:
|
350
|
+
try:
|
351
|
+
expr = parse_expr(expr_str, local_dict=sym_vars, transformations=transformations)
|
352
|
+
if subs:
|
353
|
+
subs_symbols = {symbols(k): v for k, v in subs.items()}
|
354
|
+
expr = expr.subs(subs_symbols)
|
355
|
+
return expr.expand()
|
356
|
+
except (SyntaxError, ValueError, TypeError) as e:
|
357
|
+
raise ValueError(f"Error parsing expression: {expr_str}. Error: {e}")
|
358
|
+
|
359
|
+
variable_names = set(re.findall(r'\b[a-zA-Z]\w*\b', expression))
|
360
|
+
sym_vars = {var: symbols(var) for var in variable_names}
|
361
|
+
|
362
|
+
expr = parse_and_expand_expression(expression, sym_vars)
|
363
|
+
latex_result = latex(expr)
|
364
|
+
return latex_result
|
365
|
+
|
366
|
+
|
323
367
|
|
324
368
|
def simplify_polynomial_expression(
|
325
369
|
expression: str,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: rgwfuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.41
|
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
|
@@ -23,13 +23,16 @@ Requires-Dist: xgboost
|
|
23
23
|
Requires-Dist: requests
|
24
24
|
Requires-Dist: slack-sdk
|
25
25
|
Requires-Dist: google-api-python-client
|
26
|
-
Requires-Dist:
|
26
|
+
Requires-Dist: boto3
|
27
27
|
|
28
28
|
# RGWFUNCS
|
29
29
|
|
30
30
|
***By Ryan Gerard Wilson (https://ryangerardwilson.com)***
|
31
31
|
|
32
|
-
|
32
|
+
|
33
|
+
This library is meant to protect your eyes (and brain) from OOP syntax. It is unbelievably sad that some of the best work done in creating math and data science libraries in Python has been corrupted by the OOP mind-virus.
|
34
|
+
|
35
|
+
By creating a functional-programming wrapper around these libraries, we aim to soothe. This library assumes a Linux environment and the existence of a `.rgwfuncsrc` file for certain features (like database querying, sending data to Slack, etc.).
|
33
36
|
|
34
37
|
--------------------------------------------------------------------------------
|
35
38
|
|
@@ -363,6 +366,42 @@ Converts a polynomial expression written in Python syntax to a LaTeX formatted s
|
|
363
366
|
|
364
367
|
--------------------------------------------------------------------------------
|
365
368
|
|
369
|
+
### 6. `expand_polynomial_expression`
|
370
|
+
|
371
|
+
Expands a polynomial expression written in Python syntax and converts it into a LaTeX formatted string. This function takes algebraic expressions provided as strings using Python's syntax, applies polynomial expansion through SymPy, and translates them into LaTeX representations, suitable for academic or professional documentation. It supports expressions with named variables and provides an option to substitute specific values into the expression before expansion.
|
372
|
+
|
373
|
+
- Parameters:
|
374
|
+
- `expression` (str): The algebraic expression to expand and convert to LaTeX. This string should be formatted using Python syntax acceptable by SymPy.
|
375
|
+
- `subs` (Optional[Dict[str, float]]): An optional dictionary of substitutions where the keys are variable names in the expression, and the values are the numbers with which to substitute those variables before expanding.
|
376
|
+
|
377
|
+
- Returns:
|
378
|
+
- `str`: The LaTeX formatted string of the expanded expression.
|
379
|
+
|
380
|
+
- Raises:
|
381
|
+
- `ValueError`: If the expression cannot be parsed due to syntax errors.
|
382
|
+
|
383
|
+
- Example:
|
384
|
+
|
385
|
+
from rgwfuncs import expand_polynomial_expression
|
386
|
+
|
387
|
+
# Expand a simple polynomial expression and convert to LaTeX
|
388
|
+
latex_result1 = expand_polynomial_expression("(x + y)**2")
|
389
|
+
print(latex_result1) # Output: "x^{2} + 2 x y + y^{2}"
|
390
|
+
|
391
|
+
# Expand polynomial expression with substituted values
|
392
|
+
latex_result2 = expand_polynomial_expression("(x + y)**2", {"x": 3, "y": 4})
|
393
|
+
print(latex_result2) # Output: "49"
|
394
|
+
|
395
|
+
# Another example with partial substitution
|
396
|
+
latex_result3 = expand_polynomial_expression("(x + y)**2", {"x": 3})
|
397
|
+
print(latex_result3) # Output: "y^{2} + 6 y + 9"
|
398
|
+
|
399
|
+
# Handling trigonometric functions with symbolic variables
|
400
|
+
latex_result4 = expand_polynomial_expression("sin(x + z**2) + cos(y)", {"x": 55})
|
401
|
+
print(latex_result4) # Output: "cos y + sin \\left(z^{2} + 55\\right)"
|
402
|
+
|
403
|
+
--------------------------------------------------------------------------------
|
404
|
+
|
366
405
|
### 6. `simplify_polynomial_expression`
|
367
406
|
|
368
407
|
Simplifies an algebraic expression in polynomial form and returns it in LaTeX format. Takes an algebraic expression, in polynomial form, written in Python syntax and simplifies it. The result is returned as a LaTeX formatted string, suitable for academic or professional documentation.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
rgwfuncs/__init__.py,sha256=j1SH_GGf9EPXWvhKd_RWDMUI8GXvJGniq4whdmC-tRk,1550
|
2
|
+
rgwfuncs/algebra_lib.py,sha256=OWltGhJqlP7mS0VszjeSICKQZjNlCrLjWVlaKwrb4Og,23435
|
3
|
+
rgwfuncs/df_lib.py,sha256=b6uMBbj7JrTUusbBGSlGI6jJ37yCN5lb6Oiq-C9oGzg,68987
|
4
|
+
rgwfuncs/docs_lib.py,sha256=y3wSAOPO3qsA4HZ7xAtW8HimM8w-c8hjcEzMRLJ96ao,1960
|
5
|
+
rgwfuncs/interactive_shell_lib.py,sha256=A7EWsYxAfDev_N0-2GjRvAtp0bAwBPHIczXb8Gu9fzI,1107
|
6
|
+
rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
|
7
|
+
rgwfuncs-0.0.41.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
8
|
+
rgwfuncs-0.0.41.dist-info/METADATA,sha256=AqOqGXV-Hb4tSM3oTMQ3ZMxvbpR3hOAL88iaV6i1yYs,52072
|
9
|
+
rgwfuncs-0.0.41.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
+
rgwfuncs-0.0.41.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
11
|
+
rgwfuncs-0.0.41.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
12
|
+
rgwfuncs-0.0.41.dist-info/RECORD,,
|
rgwfuncs-0.0.39.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
rgwfuncs/__init__.py,sha256=CLPRpLtzXxyFHEjS-MrxnhXH0LdS6THjAC5sCHg0m3c,1520
|
2
|
-
rgwfuncs/algebra_lib.py,sha256=g-sNkf9Hz4i17uRIgLUYLQlyUu8yROgsoJMujdj0U3Y,21577
|
3
|
-
rgwfuncs/df_lib.py,sha256=b6uMBbj7JrTUusbBGSlGI6jJ37yCN5lb6Oiq-C9oGzg,68987
|
4
|
-
rgwfuncs/docs_lib.py,sha256=y3wSAOPO3qsA4HZ7xAtW8HimM8w-c8hjcEzMRLJ96ao,1960
|
5
|
-
rgwfuncs/interactive_shell_lib.py,sha256=A7EWsYxAfDev_N0-2GjRvAtp0bAwBPHIczXb8Gu9fzI,1107
|
6
|
-
rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
|
7
|
-
rgwfuncs-0.0.39.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
8
|
-
rgwfuncs-0.0.39.dist-info/METADATA,sha256=Q_t5qkxs2q8wPBnTxvfna07rjDXSUyIYOvpbshtv780,49825
|
9
|
-
rgwfuncs-0.0.39.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
-
rgwfuncs-0.0.39.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
11
|
-
rgwfuncs-0.0.39.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
12
|
-
rgwfuncs-0.0.39.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|