rgwfuncs 0.0.43__tar.gz → 0.0.44__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.43/src/rgwfuncs.egg-info → rgwfuncs-0.0.44}/PKG-INFO +1 -1
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/pyproject.toml +1 -1
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/setup.cfg +1 -1
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs/__init__.py +1 -1
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs/algebra_lib.py +85 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44/src/rgwfuncs.egg-info}/PKG-INFO +1 -1
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/LICENSE +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/README.md +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs/df_lib.py +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs/docs_lib.py +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs/interactive_shell_lib.py +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs/str_lib.py +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs.egg-info/SOURCES.txt +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs.egg-info/dependency_links.txt +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs.egg-info/entry_points.txt +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs.egg-info/requires.txt +0 -0
- {rgwfuncs-0.0.43 → rgwfuncs-0.0.44}/src/rgwfuncs.egg-info/top_level.txt +0 -0
@@ -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, expand_polynomial_expression, python_polynomial_expression_to_latex, simplify_polynomial_expression, solve_homogeneous_polynomial_expression
|
4
|
+
from .algebra_lib import cancel_polynomial_expression, compute_constant_expression, compute_constant_expression_involving_matrices, compute_constant_expression_involving_ordered_series, compute_prime_factors, expand_polynomial_expression, factor_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
|
@@ -368,6 +368,91 @@ def expand_polynomial_expression(
|
|
368
368
|
return latex_result
|
369
369
|
|
370
370
|
|
371
|
+
def factor_polynomial_expression(
|
372
|
+
expression: str,
|
373
|
+
subs: Optional[Dict[str, float]] = None
|
374
|
+
) -> str:
|
375
|
+
"""
|
376
|
+
Factors a polynomial expression written in Python syntax and converts it to LaTeX format.
|
377
|
+
|
378
|
+
This function accepts an algebraic expression in Python syntax, performs polynomial factoring,
|
379
|
+
and translates the factored expression into a LaTeX formatted string.
|
380
|
+
|
381
|
+
Parameters:
|
382
|
+
expression (str): The algebraic expression to factor and convert to LaTeX.
|
383
|
+
subs (Optional[Dict[str, float]]): An optional dictionary of substitutions to apply before factoring.
|
384
|
+
|
385
|
+
Returns:
|
386
|
+
str: The LaTeX formatted string of the factored expression.
|
387
|
+
|
388
|
+
Raises:
|
389
|
+
ValueError: If the expression cannot be parsed due to syntax errors.
|
390
|
+
"""
|
391
|
+
transformations = standard_transformations + (implicit_multiplication_application,)
|
392
|
+
|
393
|
+
def parse_and_factor_expression(expr_str: str, sym_vars: Dict[str, symbols]) -> symbols:
|
394
|
+
try:
|
395
|
+
expr = parse_expr(expr_str, local_dict=sym_vars, transformations=transformations)
|
396
|
+
if subs:
|
397
|
+
if not isinstance(subs, dict):
|
398
|
+
raise ValueError(f"Substitutions must be a dictionary. Received: {subs}")
|
399
|
+
subs_symbols = {symbols(k): v for k, v in subs.items()}
|
400
|
+
expr = expr.subs(subs_symbols)
|
401
|
+
return factor(expr)
|
402
|
+
except (SyntaxError, ValueError, TypeError, AttributeError) as e:
|
403
|
+
raise ValueError(f"Error parsing expression: {expr_str}. Error: {e}")
|
404
|
+
|
405
|
+
variable_names = set(re.findall(r'\b[a-zA-Z]\w*\b', expression))
|
406
|
+
sym_vars = {var: symbols(var) for var in variable_names}
|
407
|
+
|
408
|
+
expr = parse_and_factor_expression(expression, sym_vars)
|
409
|
+
latex_result = latex(expr)
|
410
|
+
return latex_result
|
411
|
+
|
412
|
+
|
413
|
+
def cancel_polynomial_expression(
|
414
|
+
expression: str,
|
415
|
+
subs: Optional[Dict[str, float]] = None
|
416
|
+
) -> str:
|
417
|
+
"""
|
418
|
+
Cancels common factors within a polynomial expression and converts it to LaTeX format.
|
419
|
+
|
420
|
+
This function takes an algebraic expression written in Python syntax,
|
421
|
+
cancels common factors, and converts the reduced expression into a LaTeX formatted string.
|
422
|
+
|
423
|
+
Parameters:
|
424
|
+
expression (str): The algebraic expression to cancel and convert to LaTeX.
|
425
|
+
subs (Optional[Dict[str, float]]): An optional dictionary of substitutions to apply before canceling.
|
426
|
+
|
427
|
+
Returns:
|
428
|
+
str: The LaTeX formatted string of the canceled expression.
|
429
|
+
|
430
|
+
Raises:
|
431
|
+
ValueError: If the expression cannot be parsed due to syntax errors.
|
432
|
+
"""
|
433
|
+
transformations = standard_transformations + (implicit_multiplication_application,)
|
434
|
+
|
435
|
+
def parse_and_cancel_expression(expr_str: str, sym_vars: Dict[str, symbols]) -> symbols:
|
436
|
+
try:
|
437
|
+
expr = parse_expr(expr_str, local_dict=sym_vars, transformations=transformations)
|
438
|
+
if subs:
|
439
|
+
if not isinstance(subs, dict):
|
440
|
+
raise ValueError(f"Substitutions must be a dictionary. Received: {subs}")
|
441
|
+
subs_symbols = {symbols(k): v for k, v in subs.items()}
|
442
|
+
expr = expr.subs(subs_symbols)
|
443
|
+
return cancel(expr)
|
444
|
+
except (SyntaxError, ValueError, TypeError, AttributeError) as e:
|
445
|
+
raise ValueError(f"Error parsing expression: {expr_str}. Error: {e}")
|
446
|
+
|
447
|
+
variable_names = set(re.findall(r'\b[a-zA-Z]\w*\b', expression))
|
448
|
+
sym_vars = {var: symbols(var) for var in variable_names}
|
449
|
+
|
450
|
+
expr = parse_and_cancel_expression(expression, sym_vars)
|
451
|
+
latex_result = latex(expr)
|
452
|
+
return latex_result
|
453
|
+
|
454
|
+
|
455
|
+
|
371
456
|
def simplify_polynomial_expression(
|
372
457
|
expression: str,
|
373
458
|
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
|