rgwfuncs 0.0.30__py3-none-any.whl → 0.0.31__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 +196 -195
- {rgwfuncs-0.0.30.dist-info → rgwfuncs-0.0.31.dist-info}/METADATA +86 -85
- rgwfuncs-0.0.31.dist-info/RECORD +11 -0
- rgwfuncs-0.0.30.dist-info/RECORD +0 -11
- {rgwfuncs-0.0.30.dist-info → rgwfuncs-0.0.31.dist-info}/LICENSE +0 -0
- {rgwfuncs-0.0.30.dist-info → rgwfuncs-0.0.31.dist-info}/WHEEL +0 -0
- {rgwfuncs-0.0.30.dist-info → rgwfuncs-0.0.31.dist-info}/entry_points.txt +0 -0
- {rgwfuncs-0.0.30.dist-info → rgwfuncs-0.0.31.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,
|
4
|
+
from .algebra_lib import compute_constant_expression, compute_constant_expression_involving_matrices, compute_constant_expression_involving_ordered_series, get_prime_factors_latex, 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 .str_lib import send_telegram_message
|
rgwfuncs/algebra_lib.py
CHANGED
@@ -40,6 +40,198 @@ def compute_constant_expression(expression: str) -> float:
|
|
40
40
|
raise ValueError(f"Error computing expression: {e}")
|
41
41
|
|
42
42
|
|
43
|
+
def compute_constant_expression_involving_matrices(expression: str) -> str:
|
44
|
+
"""
|
45
|
+
Computes the result of a constant expression involving matrices and returns it as a LaTeX string.
|
46
|
+
|
47
|
+
Parameters:
|
48
|
+
expression (str): The constant expression involving matrices. Example format includes operations such as "+",
|
49
|
+
"-", "*", "/".
|
50
|
+
|
51
|
+
Returns:
|
52
|
+
str: The LaTeX-formatted string representation of the result or a message indicating an error in dimensions.
|
53
|
+
"""
|
54
|
+
|
55
|
+
def elementwise_operation(matrix1: List[List[float]], matrix2: List[List[float]], operation: str) -> List[List[float]]:
|
56
|
+
if len(matrix1) != len(matrix2) or any(len(row1) != len(row2) for row1, row2 in zip(matrix1, matrix2)):
|
57
|
+
return "Operations between matrices must involve matrices of the same dimension"
|
58
|
+
|
59
|
+
if operation == '+':
|
60
|
+
return [[a + b for a, b in zip(row1, row2)] for row1, row2 in zip(matrix1, matrix2)]
|
61
|
+
elif operation == '-':
|
62
|
+
return [[a - b for a, b in zip(row1, row2)] for row1, row2 in zip(matrix1, matrix2)]
|
63
|
+
elif operation == '*':
|
64
|
+
return [[a * b for a, b in zip(row1, row2)] for row1, row2 in zip(matrix1, matrix2)]
|
65
|
+
elif operation == '/':
|
66
|
+
return [[a / b for a, b in zip(row1, row2) if b != 0] for row1, row2 in zip(matrix1, matrix2)]
|
67
|
+
else:
|
68
|
+
return f"Unsupported operation {operation}"
|
69
|
+
|
70
|
+
try:
|
71
|
+
# Use a stack-based method to properly parse matrices
|
72
|
+
elements = []
|
73
|
+
buffer = ''
|
74
|
+
bracket_level = 0
|
75
|
+
operators = set('+-*/')
|
76
|
+
|
77
|
+
for char in expression:
|
78
|
+
if char == '[':
|
79
|
+
if bracket_level == 0 and buffer.strip():
|
80
|
+
elements.append(buffer.strip())
|
81
|
+
buffer = ''
|
82
|
+
bracket_level += 1
|
83
|
+
elif char == ']':
|
84
|
+
bracket_level -= 1
|
85
|
+
if bracket_level == 0:
|
86
|
+
buffer += char
|
87
|
+
elements.append(buffer.strip())
|
88
|
+
buffer = ''
|
89
|
+
continue
|
90
|
+
if bracket_level == 0 and char in operators:
|
91
|
+
if buffer.strip():
|
92
|
+
elements.append(buffer.strip())
|
93
|
+
buffer = ''
|
94
|
+
elements.append(char)
|
95
|
+
else:
|
96
|
+
buffer += char
|
97
|
+
|
98
|
+
if buffer.strip():
|
99
|
+
elements.append(buffer.strip())
|
100
|
+
|
101
|
+
result = ast.literal_eval(elements[0])
|
102
|
+
|
103
|
+
if not any(isinstance(row, list) for row in result):
|
104
|
+
result = [result] # Convert 1D matrix to 2D
|
105
|
+
|
106
|
+
i = 1
|
107
|
+
while i < len(elements):
|
108
|
+
operation = elements[i]
|
109
|
+
matrix = ast.literal_eval(elements[i + 1])
|
110
|
+
|
111
|
+
if not any(isinstance(row, list) for row in matrix):
|
112
|
+
matrix = [matrix]
|
113
|
+
|
114
|
+
operation_result = elementwise_operation(result, matrix, operation)
|
115
|
+
|
116
|
+
# Check if the operation resulted in an error message
|
117
|
+
if isinstance(operation_result, str):
|
118
|
+
return operation_result
|
119
|
+
|
120
|
+
result = operation_result
|
121
|
+
i += 2
|
122
|
+
|
123
|
+
# Create a LaTeX-style matrix representation
|
124
|
+
matrix_entries = '\\\\'.join(' & '.join(str(x) for x in row) for row in result)
|
125
|
+
return r"\begin{bmatrix}" + f"{matrix_entries}" + r"\end{bmatrix}"
|
126
|
+
|
127
|
+
except Exception as e:
|
128
|
+
return f"Error computing matrix operation: {e}"
|
129
|
+
|
130
|
+
|
131
|
+
def compute_constant_expression_involving_ordered_series(expression: str) -> str:
|
132
|
+
"""
|
133
|
+
Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
|
134
|
+
Supports operations lile "+", "-", "*", "/", as well as "dd()" (the discrete difference operator).
|
135
|
+
|
136
|
+
The function first applies the discrete difference operator to any series where applicable, then evaluates
|
137
|
+
arithmetic operations between series.
|
138
|
+
|
139
|
+
Parameters:
|
140
|
+
expression (str): The series operation expression to compute. Includes operations "+", "-", "*", "/", and "dd()".
|
141
|
+
|
142
|
+
Returns:
|
143
|
+
str: The string representation of the resultant series after performing operations, or an error message
|
144
|
+
if the series lengths do not match.
|
145
|
+
|
146
|
+
Raises:
|
147
|
+
ValueError: If the expression cannot be evaluated.
|
148
|
+
"""
|
149
|
+
|
150
|
+
def elementwise_operation(series1: List[float], series2: List[float], operation: str) -> List[float]:
|
151
|
+
if len(series1) != len(series2):
|
152
|
+
return "Operations between ordered series must involve series of equal length"
|
153
|
+
|
154
|
+
if operation == '+':
|
155
|
+
return [a + b for a, b in zip(series1, series2)]
|
156
|
+
elif operation == '-':
|
157
|
+
return [a - b for a, b in zip(series1, series2)]
|
158
|
+
elif operation == '*':
|
159
|
+
return [a * b for a, b in zip(series1, series2)]
|
160
|
+
elif operation == '/':
|
161
|
+
return [a / b for a, b in zip(series1, series2) if b != 0]
|
162
|
+
else:
|
163
|
+
return f"Unsupported operation {operation}"
|
164
|
+
|
165
|
+
def discrete_difference(series: list) -> list:
|
166
|
+
"""Computes the discrete difference of a series."""
|
167
|
+
return [series[i + 1] - series[i] for i in range(len(series) - 1)]
|
168
|
+
|
169
|
+
try:
|
170
|
+
# First, apply the discrete difference operator where applicable
|
171
|
+
pattern = r'dd\((\[[^\]]*\])\)'
|
172
|
+
matches = re.findall(pattern, expression)
|
173
|
+
|
174
|
+
for match in matches:
|
175
|
+
if match.strip() == '[]':
|
176
|
+
result_series = [] # Handle the empty list case
|
177
|
+
else:
|
178
|
+
series = ast.literal_eval(match)
|
179
|
+
result_series = discrete_difference(series)
|
180
|
+
expression = expression.replace(f'dd({match})', str(result_series))
|
181
|
+
|
182
|
+
# Now parse and evaluate the full expression with basic operations
|
183
|
+
elements = []
|
184
|
+
buffer = ''
|
185
|
+
bracket_level = 0
|
186
|
+
operators = set('+-*/')
|
187
|
+
|
188
|
+
for char in expression:
|
189
|
+
if char == '[':
|
190
|
+
if bracket_level == 0 and buffer.strip():
|
191
|
+
elements.append(buffer.strip())
|
192
|
+
buffer = ''
|
193
|
+
bracket_level += 1
|
194
|
+
elif char == ']':
|
195
|
+
bracket_level -= 1
|
196
|
+
if bracket_level == 0:
|
197
|
+
buffer += char
|
198
|
+
elements.append(buffer.strip())
|
199
|
+
buffer = ''
|
200
|
+
continue
|
201
|
+
if bracket_level == 0 and char in operators:
|
202
|
+
if buffer.strip():
|
203
|
+
elements.append(buffer.strip())
|
204
|
+
buffer = ''
|
205
|
+
elements.append(char)
|
206
|
+
else:
|
207
|
+
buffer += char
|
208
|
+
|
209
|
+
if buffer.strip():
|
210
|
+
elements.append(buffer.strip())
|
211
|
+
|
212
|
+
result = ast.literal_eval(elements[0])
|
213
|
+
|
214
|
+
i = 1
|
215
|
+
while i < len(elements):
|
216
|
+
operation = elements[i]
|
217
|
+
series = ast.literal_eval(elements[i + 1])
|
218
|
+
operation_result = elementwise_operation(result, series, operation)
|
219
|
+
|
220
|
+
# Check if the operation resulted in an error message
|
221
|
+
if isinstance(operation_result, str):
|
222
|
+
return operation_result
|
223
|
+
|
224
|
+
result = operation_result
|
225
|
+
i += 2
|
226
|
+
|
227
|
+
return str(result)
|
228
|
+
|
229
|
+
except Exception as e:
|
230
|
+
return f"Error computing ordered series operation: {e}"
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
43
235
|
def python_polynomial_expression_to_latex(
|
44
236
|
expression: str,
|
45
237
|
subs: Optional[Dict[str, float]] = None
|
@@ -100,7 +292,6 @@ def python_polynomial_expression_to_latex(
|
|
100
292
|
return latex_result
|
101
293
|
|
102
294
|
|
103
|
-
|
104
295
|
def simplify_polynomial_expression(
|
105
296
|
expression: str,
|
106
297
|
subs: Optional[Dict[str, float]] = None
|
@@ -109,7 +300,7 @@ def simplify_polynomial_expression(
|
|
109
300
|
Simplifies an algebraic expression in polynomial form and returns it in LaTeX format.
|
110
301
|
|
111
302
|
Takes an algebraic expression, in polynomial form, written in Python syntax and simplifies it.
|
112
|
-
The result is returned as a LaTeX formatted string, suitable for academic or professional
|
303
|
+
The result is returned as a LaTeX formatted string, suitable for academic or professional
|
113
304
|
documentation.
|
114
305
|
|
115
306
|
Parameters:
|
@@ -282,11 +473,11 @@ def solve_homogeneous_polynomial_expression(
|
|
282
473
|
subs: Optional[Dict[str, float]] = None
|
283
474
|
) -> str:
|
284
475
|
"""
|
285
|
-
Solves a homogeneous polynomial expression for a specified variable and returns solutions
|
476
|
+
Solves a homogeneous polynomial expression for a specified variable and returns solutions
|
286
477
|
in LaTeX format.
|
287
478
|
|
288
|
-
Assumes that the expression is homoegeneous (i.e. equal to zero), and solves for a
|
289
|
-
designated variable. May optionally include substitutions for other variables in the
|
479
|
+
Assumes that the expression is homoegeneous (i.e. equal to zero), and solves for a
|
480
|
+
designated variable. May optionally include substitutions for other variables in the
|
290
481
|
equation. The solutions are provided as a LaTeX formatted string.
|
291
482
|
|
292
483
|
Parameters:
|
@@ -329,196 +520,6 @@ def solve_homogeneous_polynomial_expression(
|
|
329
520
|
raise ValueError(f"Error solving the expression: {e}")
|
330
521
|
|
331
522
|
|
332
|
-
def compute_matrix_expression(expression: str) -> str:
|
333
|
-
"""
|
334
|
-
Computes the result of a matrix-like operation on 1D or 2D list inputs and returns it as a LaTeX string.
|
335
|
-
|
336
|
-
Evaluates an operation where lists are treated as matrices, performs operations on them sequentially, and
|
337
|
-
returns the result formatted as a LaTeX-style string.
|
338
|
-
|
339
|
-
Parameters:
|
340
|
-
expression (str): The matrix operation expression to compute. Example format includes operations such as "+", "-", "*", "/".
|
341
|
-
|
342
|
-
Returns:
|
343
|
-
str: The LaTeX-formatted string representation of the result or a message indicating an error in dimensions.
|
344
|
-
"""
|
345
|
-
|
346
|
-
def elementwise_operation(matrix1: List[List[float]], matrix2: List[List[float]], operation: str) -> List[List[float]]:
|
347
|
-
if len(matrix1) != len(matrix2) or any(len(row1) != len(row2) for row1, row2 in zip(matrix1, matrix2)):
|
348
|
-
return "Operations between matrices must involve matrices of the same dimension"
|
349
|
-
|
350
|
-
if operation == '+':
|
351
|
-
return [[a + b for a, b in zip(row1, row2)] for row1, row2 in zip(matrix1, matrix2)]
|
352
|
-
elif operation == '-':
|
353
|
-
return [[a - b for a, b in zip(row1, row2)] for row1, row2 in zip(matrix1, matrix2)]
|
354
|
-
elif operation == '*':
|
355
|
-
return [[a * b for a, b in zip(row1, row2)] for row1, row2 in zip(matrix1, matrix2)]
|
356
|
-
elif operation == '/':
|
357
|
-
return [[a / b for a, b in zip(row1, row2) if b != 0] for row1, row2 in zip(matrix1, matrix2)]
|
358
|
-
else:
|
359
|
-
return f"Unsupported operation {operation}"
|
360
|
-
|
361
|
-
try:
|
362
|
-
# Use a stack-based method to properly parse matrices
|
363
|
-
elements = []
|
364
|
-
buffer = ''
|
365
|
-
bracket_level = 0
|
366
|
-
operators = set('+-*/')
|
367
|
-
|
368
|
-
for char in expression:
|
369
|
-
if char == '[':
|
370
|
-
if bracket_level == 0 and buffer.strip():
|
371
|
-
elements.append(buffer.strip())
|
372
|
-
buffer = ''
|
373
|
-
bracket_level += 1
|
374
|
-
elif char == ']':
|
375
|
-
bracket_level -= 1
|
376
|
-
if bracket_level == 0:
|
377
|
-
buffer += char
|
378
|
-
elements.append(buffer.strip())
|
379
|
-
buffer = ''
|
380
|
-
continue
|
381
|
-
if bracket_level == 0 and char in operators:
|
382
|
-
if buffer.strip():
|
383
|
-
elements.append(buffer.strip())
|
384
|
-
buffer = ''
|
385
|
-
elements.append(char)
|
386
|
-
else:
|
387
|
-
buffer += char
|
388
|
-
|
389
|
-
if buffer.strip():
|
390
|
-
elements.append(buffer.strip())
|
391
|
-
|
392
|
-
result = ast.literal_eval(elements[0])
|
393
|
-
|
394
|
-
if not any(isinstance(row, list) for row in result):
|
395
|
-
result = [result] # Convert 1D matrix to 2D
|
396
|
-
|
397
|
-
i = 1
|
398
|
-
while i < len(elements):
|
399
|
-
operation = elements[i]
|
400
|
-
matrix = ast.literal_eval(elements[i + 1])
|
401
|
-
|
402
|
-
if not any(isinstance(row, list) for row in matrix):
|
403
|
-
matrix = [matrix]
|
404
|
-
|
405
|
-
operation_result = elementwise_operation(result, matrix, operation)
|
406
|
-
|
407
|
-
# Check if the operation resulted in an error message
|
408
|
-
if isinstance(operation_result, str):
|
409
|
-
return operation_result
|
410
|
-
|
411
|
-
result = operation_result
|
412
|
-
i += 2
|
413
|
-
|
414
|
-
# Create a LaTeX-style matrix representation
|
415
|
-
matrix_entries = '\\\\'.join(' & '.join(str(x) for x in row) for row in result)
|
416
|
-
return r"\begin{bmatrix}" + f"{matrix_entries}" + r"\end{bmatrix}"
|
417
|
-
|
418
|
-
except Exception as e:
|
419
|
-
return f"Error computing matrix operation: {e}"
|
420
|
-
|
421
|
-
|
422
|
-
def compute_ordered_series_expression(expression: str) -> str:
|
423
|
-
"""
|
424
|
-
Computes the result of operations on ordered series expressed as 1D lists, including discrete difference (ddd),
|
425
|
-
and returns it as a string.
|
426
|
-
|
427
|
-
The function first applies the discrete difference operator to any series where applicable, then evaluates
|
428
|
-
arithmetic operations between series.
|
429
|
-
|
430
|
-
Parameters:
|
431
|
-
expression (str): The series operation expression to compute. Includes operations "+", "-", "*", "/", and "ddd".
|
432
|
-
|
433
|
-
Returns:
|
434
|
-
str: The string representation of the resultant series after performing operations, or an error message
|
435
|
-
if the series lengths do not match.
|
436
|
-
|
437
|
-
Raises:
|
438
|
-
ValueError: If the expression cannot be evaluated.
|
439
|
-
"""
|
440
|
-
|
441
|
-
def elementwise_operation(series1: List[float], series2: List[float], operation: str) -> List[float]:
|
442
|
-
if len(series1) != len(series2):
|
443
|
-
return "Operations between ordered series must involve series of equal length"
|
444
|
-
|
445
|
-
if operation == '+':
|
446
|
-
return [a + b for a, b in zip(series1, series2)]
|
447
|
-
elif operation == '-':
|
448
|
-
return [a - b for a, b in zip(series1, series2)]
|
449
|
-
elif operation == '*':
|
450
|
-
return [a * b for a, b in zip(series1, series2)]
|
451
|
-
elif operation == '/':
|
452
|
-
return [a / b for a, b in zip(series1, series2) if b != 0]
|
453
|
-
else:
|
454
|
-
return f"Unsupported operation {operation}"
|
455
|
-
|
456
|
-
def discrete_difference(series: list) -> list:
|
457
|
-
"""Computes the discrete difference of a series."""
|
458
|
-
return [series[i + 1] - series[i] for i in range(len(series) - 1)]
|
459
|
-
|
460
|
-
try:
|
461
|
-
# First, apply the discrete difference operator where applicable
|
462
|
-
pattern = r'ddd\((\[[^\]]*\])\)'
|
463
|
-
matches = re.findall(pattern, expression)
|
464
|
-
|
465
|
-
for match in matches:
|
466
|
-
if match.strip() == '[]':
|
467
|
-
result_series = [] # Handle the empty list case
|
468
|
-
else:
|
469
|
-
series = ast.literal_eval(match)
|
470
|
-
result_series = discrete_difference(series)
|
471
|
-
expression = expression.replace(f'ddd({match})', str(result_series))
|
472
|
-
|
473
|
-
# Now parse and evaluate the full expression with basic operations
|
474
|
-
elements = []
|
475
|
-
buffer = ''
|
476
|
-
bracket_level = 0
|
477
|
-
operators = set('+-*/')
|
478
|
-
|
479
|
-
for char in expression:
|
480
|
-
if char == '[':
|
481
|
-
if bracket_level == 0 and buffer.strip():
|
482
|
-
elements.append(buffer.strip())
|
483
|
-
buffer = ''
|
484
|
-
bracket_level += 1
|
485
|
-
elif char == ']':
|
486
|
-
bracket_level -= 1
|
487
|
-
if bracket_level == 0:
|
488
|
-
buffer += char
|
489
|
-
elements.append(buffer.strip())
|
490
|
-
buffer = ''
|
491
|
-
continue
|
492
|
-
if bracket_level == 0 and char in operators:
|
493
|
-
if buffer.strip():
|
494
|
-
elements.append(buffer.strip())
|
495
|
-
buffer = ''
|
496
|
-
elements.append(char)
|
497
|
-
else:
|
498
|
-
buffer += char
|
499
|
-
|
500
|
-
if buffer.strip():
|
501
|
-
elements.append(buffer.strip())
|
502
|
-
|
503
|
-
result = ast.literal_eval(elements[0])
|
504
|
-
|
505
|
-
i = 1
|
506
|
-
while i < len(elements):
|
507
|
-
operation = elements[i]
|
508
|
-
series = ast.literal_eval(elements[i + 1])
|
509
|
-
operation_result = elementwise_operation(result, series, operation)
|
510
|
-
|
511
|
-
# Check if the operation resulted in an error message
|
512
|
-
if isinstance(operation_result, str):
|
513
|
-
return operation_result
|
514
|
-
|
515
|
-
result = operation_result
|
516
|
-
i += 2
|
517
|
-
|
518
|
-
return str(result)
|
519
|
-
|
520
|
-
except Exception as e:
|
521
|
-
return f"Error computing ordered series operation: {e}"
|
522
523
|
|
523
524
|
|
524
525
|
def get_prime_factors_latex(n: int) -> str:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: rgwfuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.31
|
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
|
@@ -154,7 +154,88 @@ Print a list of available function names in alphabetical order. If a filter is p
|
|
154
154
|
|
155
155
|
This section provides comprehensive functions for handling algebraic expressions, performing tasks such as computation, simplification, solving equations, and prime factorization, all outputted in LaTeX format.
|
156
156
|
|
157
|
-
### 1. `
|
157
|
+
### 1. `compute_constant_expression`
|
158
|
+
|
159
|
+
Computes the numerical result of a given expression, which can evaluate to a constant, represented as a float. Evaluates an constant expression provided as a string and returns the computed result. Supports various arithmetic operations, including addition, subtraction, multiplication, division, and modulo, as well as mathematical functions from the math module.
|
160
|
+
|
161
|
+
• Parameters:
|
162
|
+
- `expression` (str): The constant expression to compute. This should be a string consisting of arithmetic operations and Python's math module functions.
|
163
|
+
|
164
|
+
• Returns:
|
165
|
+
- `float`: The computed numerical result.
|
166
|
+
|
167
|
+
• Example:
|
168
|
+
|
169
|
+
from rgwfuncs import compute_constant_expression
|
170
|
+
result1 = compute_constant_expression("2 + 2")
|
171
|
+
print(result1) # Output: 4.0
|
172
|
+
|
173
|
+
result2 = compute_constant_expression("10 % 3")
|
174
|
+
print(result2) # Output: 1.0
|
175
|
+
|
176
|
+
result3 = compute_constant_expression("math.gcd(36, 60) * math.sin(math.radians(45)) * 10000")
|
177
|
+
print(result3) # Output: 84852.8137423857
|
178
|
+
|
179
|
+
--------------------------------------------------------------------------------
|
180
|
+
|
181
|
+
### 2. `compute_constant_expression_involving_matrices`
|
182
|
+
|
183
|
+
Computes the result of a constant expression involving matrices and returns it as a LaTeX string.
|
184
|
+
|
185
|
+
• Parameters:
|
186
|
+
- `expression` (str): The constant expression involving matrices. Example format includes operations such as "+", "-", "*", "/".
|
187
|
+
|
188
|
+
• Returns:
|
189
|
+
- `str`: The LaTeX-formatted string representation of the computed matrix, or an error message if the operations cannot be performed due to dimensional mismatches.
|
190
|
+
|
191
|
+
• Example:
|
192
|
+
|
193
|
+
from rgwfuncs import compute_constant_expression_involving_matrices
|
194
|
+
|
195
|
+
# Example with addition of 2D matrices
|
196
|
+
result = compute_constant_expression_involving_matrices("[[2, 6, 9], [1, 3, 5]] + [[1, 2, 3], [4, 5, 6]]")
|
197
|
+
print(result) # Output: \begin{bmatrix}3 & 8 & 12\\5 & 8 & 11\end{bmatrix}
|
198
|
+
|
199
|
+
# Example of mixed operations with 1D matrices treated as 2D
|
200
|
+
result = compute_constant_expression_involving_matrices("[3, 6, 9] + [1, 2, 3] - [2, 2, 2]")
|
201
|
+
print(result) # Output: \begin{bmatrix}2 & 6 & 10\end{bmatrix}
|
202
|
+
|
203
|
+
# Example with dimension mismatch
|
204
|
+
result = compute_constant_expression_involving_matrices("[[4, 3, 51]] + [[1, 1]]")
|
205
|
+
print(result) # Output: Operations between matrices must involve matrices of the same dimension
|
206
|
+
|
207
|
+
--------------------------------------------------------------------------------
|
208
|
+
|
209
|
+
### 3. `compute_constant_expression_involving_ordered_series`
|
210
|
+
|
211
|
+
Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
|
212
|
+
|
213
|
+
|
214
|
+
• Parameters:
|
215
|
+
- `expression` (str): A series operation expression. Supports operations such as "+", "-", "*", "/", and `dd()` for discrete differences.
|
216
|
+
|
217
|
+
• Returns:
|
218
|
+
- `str`: The string representation of the resultant series after performing operations, or an error message if series lengths do not match.
|
219
|
+
|
220
|
+
• Example:
|
221
|
+
|
222
|
+
from rgwfuncs import compute_constant_expression_involving_ordered_series
|
223
|
+
|
224
|
+
# Example with addition and discrete differences
|
225
|
+
result = compute_constant_expression_involving_ordered_series("dd([2, 6, 9, 60]) + dd([78, 79, 80])")
|
226
|
+
print(result) # Output: [4, 3, 51] + [1, 1]
|
227
|
+
|
228
|
+
# Example with elementwise subtraction
|
229
|
+
result = compute_constant_expression_involving_ordered_series("[10, 15, 21] - [5, 5, 5]")
|
230
|
+
print(result) # Output: [5, 10, 16]
|
231
|
+
|
232
|
+
# Example with length mismatch
|
233
|
+
result = compute_constant_expression_involving_ordered_series("[4, 3, 51] + [1, 1]")
|
234
|
+
print(result) # Output: Operations between ordered series must involve series of equal length
|
235
|
+
|
236
|
+
--------------------------------------------------------------------------------
|
237
|
+
|
238
|
+
### 4. `python_polynomial_expression_to_latex`
|
158
239
|
|
159
240
|
Converts a polynomial expression written in Python syntax to a LaTeX formatted string. This function parses algebraic expressions provided as strings using Python’s syntax and translates them into equivalent LaTeX representations, making them suitable for academic or professional documentation. The function supports inclusion of named variables, with an option to substitute specific values into the expression.
|
160
241
|
|
@@ -194,31 +275,7 @@ Converts a polynomial expression written in Python syntax to a LaTeX formatted s
|
|
194
275
|
|
195
276
|
--------------------------------------------------------------------------------
|
196
277
|
|
197
|
-
###
|
198
|
-
|
199
|
-
Computes the numerical result of a given expression, which can evaluate to a constant, represented as a float. Evaluates an constant expression provided as a string and returns the computed result. Supports various arithmetic operations, including addition, subtraction, multiplication, division, and modulo, as well as mathematical functions from the math module.
|
200
|
-
|
201
|
-
• Parameters:
|
202
|
-
- `expression` (str): The constant expression to compute. This should be a string consisting of arithmetic operations and Python's math module functions.
|
203
|
-
|
204
|
-
• Returns:
|
205
|
-
- `float`: The computed numerical result.
|
206
|
-
|
207
|
-
• Example:
|
208
|
-
|
209
|
-
from rgwfuncs import compute_constant_expression
|
210
|
-
result1 = compute_constant_expression("2 + 2")
|
211
|
-
print(result1) # Output: 4.0
|
212
|
-
|
213
|
-
result2 = compute_constant_expression("10 % 3")
|
214
|
-
print(result2) # Output: 1.0
|
215
|
-
|
216
|
-
result3 = compute_constant_expression("math.gcd(36, 60) * math.sin(math.radians(45)) * 10000")
|
217
|
-
print(result3) # Output: 84852.8137423857
|
218
|
-
|
219
|
-
--------------------------------------------------------------------------------
|
220
|
-
|
221
|
-
### 3. `simplify_polynomial_expression`
|
278
|
+
### 5. `simplify_polynomial_expression`
|
222
279
|
|
223
280
|
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.
|
224
281
|
|
@@ -251,7 +308,7 @@ Simplifies an algebraic expression in polynomial form and returns it in LaTeX fo
|
|
251
308
|
|
252
309
|
--------------------------------------------------------------------------------
|
253
310
|
|
254
|
-
###
|
311
|
+
### 6. `solve_homogeneous_polynomial_expression`
|
255
312
|
|
256
313
|
Solves a homogeneous polynomial expression for a specified variable and returns solutions in LaTeX format. Assumes that the expression is homoegeneous (i.e. equal to zero), and solves for a designated variable. May optionally include substitutions for other variables in the equation. The solutions are provided as a LaTeX formatted string. The method solves equations for specified variables, with optional substitutions, returning LaTeX-formatted solutions.
|
257
314
|
|
@@ -274,7 +331,7 @@ Solves a homogeneous polynomial expression for a specified variable and returns
|
|
274
331
|
|
275
332
|
--------------------------------------------------------------------------------
|
276
333
|
|
277
|
-
###
|
334
|
+
### 7. `get_prime_factors_latex`
|
278
335
|
|
279
336
|
Computes prime factors of a number and presents them in LaTeX format.
|
280
337
|
|
@@ -298,62 +355,6 @@ Computes prime factors of a number and presents them in LaTeX format.
|
|
298
355
|
|
299
356
|
--------------------------------------------------------------------------------
|
300
357
|
|
301
|
-
### 6. `compute_matrix_expression`
|
302
|
-
|
303
|
-
Computes the results of expressions containing 1D or 2D matrix operations and formats them as LaTeX strings.
|
304
|
-
|
305
|
-
• Parameters:
|
306
|
-
- `expression` (str): A string representing a sequence of matrix operations involving either 1D or 2D lists. Supported operations include addition (`+`), subtraction (`-`), multiplication (`*`), and division (`/`).
|
307
|
-
|
308
|
-
• Returns:
|
309
|
-
- `str`: The LaTeX-formatted string representation of the computed matrix, or an error message if the operations cannot be performed due to dimensional mismatches.
|
310
|
-
|
311
|
-
• Example:
|
312
|
-
|
313
|
-
from rgwfuncs import compute_matrix_expression
|
314
|
-
|
315
|
-
# Example with addition of 2D matrices
|
316
|
-
result = compute_matrix_expression("[[2, 6, 9], [1, 3, 5]] + [[1, 2, 3], [4, 5, 6]]")
|
317
|
-
print(result) # Output: \begin{bmatrix}3 & 8 & 12\\5 & 8 & 11\end{bmatrix}
|
318
|
-
|
319
|
-
# Example of mixed operations with 1D matrices treated as 2D
|
320
|
-
result = compute_matrix_expression("[3, 6, 9] + [1, 2, 3] - [2, 2, 2]")
|
321
|
-
print(result) # Output: \begin{bmatrix}2 & 6 & 10\end{bmatrix}
|
322
|
-
|
323
|
-
# Example with dimension mismatch
|
324
|
-
result = compute_matrix_expression("[[4, 3, 51]] + [[1, 1]]")
|
325
|
-
print(result) # Output: Operations between matrices must involve matrices of the same dimension
|
326
|
-
|
327
|
-
--------------------------------------------------------------------------------
|
328
|
-
|
329
|
-
### 7. `compute_ordered_series_expression`
|
330
|
-
|
331
|
-
Computes the result of expressions containing operations on ordered series expressed as 1D lists. The syntax of the expression supports the discrete difference operator via the `ddd()` method.
|
332
|
-
|
333
|
-
• Parameters:
|
334
|
-
- `expression` (str): A series operation expression. Supports operations such as "+", "-", "*", "/", and `ddd()` for discrete differences.
|
335
|
-
|
336
|
-
• Returns:
|
337
|
-
- `str`: The string representation of the resultant series after performing operations, or an error message if series lengths do not match.
|
338
|
-
|
339
|
-
• Example:
|
340
|
-
|
341
|
-
from rgwfuncs import compute_ordered_series_expression
|
342
|
-
|
343
|
-
# Example with addition and discrete differences
|
344
|
-
result = compute_ordered_series_expression("ddd([2, 6, 9, 60]) + ddd([78, 79, 80])")
|
345
|
-
print(result) # Output: [4, 3, 51] + [1, 1]
|
346
|
-
|
347
|
-
# Example with elementwise subtraction
|
348
|
-
result = compute_ordered_series_expression("[10, 15, 21] - [5, 5, 5]")
|
349
|
-
print(result) # Output: [5, 10, 16]
|
350
|
-
|
351
|
-
# Example with length mismatch
|
352
|
-
result = compute_ordered_series_expression("[4, 3, 51] + [1, 1]")
|
353
|
-
print(result) # Output: Operations between ordered series must involve series of equal length
|
354
|
-
|
355
|
-
--------------------------------------------------------------------------------
|
356
|
-
|
357
358
|
## String Based Functions
|
358
359
|
|
359
360
|
### 1. send_telegram_message
|
@@ -0,0 +1,11 @@
|
|
1
|
+
rgwfuncs/__init__.py,sha256=Xei98Hu6tuFZMCAthCMgmkiD2ZWKKypArV4zcJ9Qtds,1469
|
2
|
+
rgwfuncs/algebra_lib.py,sha256=96rXb82urUVlrRgkpaNYNsap_ndSQc3NeWjFCG3aTYc,21587
|
3
|
+
rgwfuncs/df_lib.py,sha256=G_H3PXNVeseX2YLjkkrmO9eXA_7r29swUZlbPBDZjXA,66612
|
4
|
+
rgwfuncs/docs_lib.py,sha256=y3wSAOPO3qsA4HZ7xAtW8HimM8w-c8hjcEzMRLJ96ao,1960
|
5
|
+
rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
|
6
|
+
rgwfuncs-0.0.31.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
7
|
+
rgwfuncs-0.0.31.dist-info/METADATA,sha256=_oeyab985L-gFGP6woQfHRIg3jnX4XlLX6lU3BuxOts,44925
|
8
|
+
rgwfuncs-0.0.31.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
9
|
+
rgwfuncs-0.0.31.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
10
|
+
rgwfuncs-0.0.31.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
11
|
+
rgwfuncs-0.0.31.dist-info/RECORD,,
|
rgwfuncs-0.0.30.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
rgwfuncs/__init__.py,sha256=hHXrHxIBSBVvmuVswZkr56sG4RhlGbx6LM_wRazsJkk,1429
|
2
|
-
rgwfuncs/algebra_lib.py,sha256=O0ux_y9Yt07S3_N0XfzNRFqnolKRxeEIK8eIdperG9Y,21653
|
3
|
-
rgwfuncs/df_lib.py,sha256=G_H3PXNVeseX2YLjkkrmO9eXA_7r29swUZlbPBDZjXA,66612
|
4
|
-
rgwfuncs/docs_lib.py,sha256=y3wSAOPO3qsA4HZ7xAtW8HimM8w-c8hjcEzMRLJ96ao,1960
|
5
|
-
rgwfuncs/str_lib.py,sha256=rtAdRlnSJIu3JhI-tA_A0wCiPK2m-zn5RoGpBxv_g-4,2228
|
6
|
-
rgwfuncs-0.0.30.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
7
|
-
rgwfuncs-0.0.30.dist-info/METADATA,sha256=-Xi5O4P_KhBLCiRQq8w1j41ClVTOo9qGCyviqskVTcs,44923
|
8
|
-
rgwfuncs-0.0.30.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
9
|
-
rgwfuncs-0.0.30.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
10
|
-
rgwfuncs-0.0.30.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
11
|
-
rgwfuncs-0.0.30.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|