rgwfuncs 0.0.31__tar.gz → 0.0.32__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.31/src/rgwfuncs.egg-info → rgwfuncs-0.0.32}/PKG-INFO +31 -31
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/README.md +30 -30
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/pyproject.toml +1 -1
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/setup.cfg +1 -1
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs/__init__.py +1 -1
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs/algebra_lib.py +31 -31
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32/src/rgwfuncs.egg-info}/PKG-INFO +31 -31
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/tests/test_algebra_lib.py +16 -13
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/LICENSE +0 -0
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs/df_lib.py +0 -0
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs/docs_lib.py +0 -0
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs/str_lib.py +0 -0
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs.egg-info/SOURCES.txt +0 -0
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs.egg-info/dependency_links.txt +0 -0
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs.egg-info/entry_points.txt +0 -0
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs.egg-info/requires.txt +0 -0
- {rgwfuncs-0.0.31 → rgwfuncs-0.0.32}/src/rgwfuncs.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: rgwfuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.32
|
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,31 @@ 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_prime_factors_latex`
|
158
|
+
|
159
|
+
Computes prime factors of a number and presents them in LaTeX format.
|
160
|
+
|
161
|
+
• Parameters:
|
162
|
+
- `n` (int): The integer to factorize.
|
163
|
+
|
164
|
+
• Returns:
|
165
|
+
- `str`: Prime factorization in LaTeX.
|
166
|
+
|
167
|
+
• Example:
|
168
|
+
|
169
|
+
from rgwfuncs import compute_prime_factors_latex
|
170
|
+
factors_1 = compute_prime_factors_latex(100)
|
171
|
+
print(factors_1) # Output: "2^{2} \cdot 5^{2}"
|
172
|
+
|
173
|
+
factors_2 = compute_prime_factors_latex(60)
|
174
|
+
print(factors_2) # Output: "2^{2} \cdot 3 \cdot 5"
|
175
|
+
|
176
|
+
factors_3 = compute_prime_factors_latex(17)
|
177
|
+
print(factors_3) # Output: "17"
|
178
|
+
|
179
|
+
--------------------------------------------------------------------------------
|
180
|
+
|
181
|
+
### 2. `compute_constant_expression`
|
158
182
|
|
159
183
|
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
184
|
|
@@ -178,7 +202,7 @@ Computes the numerical result of a given expression, which can evaluate to a con
|
|
178
202
|
|
179
203
|
--------------------------------------------------------------------------------
|
180
204
|
|
181
|
-
###
|
205
|
+
### 3. `compute_constant_expression_involving_matrices`
|
182
206
|
|
183
207
|
Computes the result of a constant expression involving matrices and returns it as a LaTeX string.
|
184
208
|
|
@@ -206,7 +230,7 @@ Computes the result of a constant expression involving matrices and returns it a
|
|
206
230
|
|
207
231
|
--------------------------------------------------------------------------------
|
208
232
|
|
209
|
-
###
|
233
|
+
### 4. `compute_constant_expression_involving_ordered_series`
|
210
234
|
|
211
235
|
Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
|
212
236
|
|
@@ -235,7 +259,7 @@ Computes the result of a constant expression involving ordered series, and retur
|
|
235
259
|
|
236
260
|
--------------------------------------------------------------------------------
|
237
261
|
|
238
|
-
###
|
262
|
+
### 5. `python_polynomial_expression_to_latex`
|
239
263
|
|
240
264
|
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.
|
241
265
|
|
@@ -275,7 +299,7 @@ Converts a polynomial expression written in Python syntax to a LaTeX formatted s
|
|
275
299
|
|
276
300
|
--------------------------------------------------------------------------------
|
277
301
|
|
278
|
-
###
|
302
|
+
### 6. `simplify_polynomial_expression`
|
279
303
|
|
280
304
|
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.
|
281
305
|
|
@@ -308,7 +332,7 @@ Simplifies an algebraic expression in polynomial form and returns it in LaTeX fo
|
|
308
332
|
|
309
333
|
--------------------------------------------------------------------------------
|
310
334
|
|
311
|
-
###
|
335
|
+
### 7. `solve_homogeneous_polynomial_expression`
|
312
336
|
|
313
337
|
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.
|
314
338
|
|
@@ -331,30 +355,6 @@ Solves a homogeneous polynomial expression for a specified variable and returns
|
|
331
355
|
|
332
356
|
--------------------------------------------------------------------------------
|
333
357
|
|
334
|
-
### 7. `get_prime_factors_latex`
|
335
|
-
|
336
|
-
Computes prime factors of a number and presents them in LaTeX format.
|
337
|
-
|
338
|
-
• Parameters:
|
339
|
-
- `n` (int): The integer to factorize.
|
340
|
-
|
341
|
-
• Returns:
|
342
|
-
- `str`: Prime factorization in LaTeX.
|
343
|
-
|
344
|
-
• Example:
|
345
|
-
|
346
|
-
from rgwfuncs import get_prime_factors_latex
|
347
|
-
factors1 = get_prime_factors_latex(100)
|
348
|
-
print(factors1) # Output: "2^{2} \cdot 5^{2}"
|
349
|
-
|
350
|
-
factors2 = get_prime_factors_latex(60)
|
351
|
-
print(factors2) # Output: "2^{2} \cdot 3 \cdot 5"
|
352
|
-
|
353
|
-
factors3 = get_prime_factors_latex(17)
|
354
|
-
print(factors3) # Output: "17"
|
355
|
-
|
356
|
-
--------------------------------------------------------------------------------
|
357
|
-
|
358
358
|
## String Based Functions
|
359
359
|
|
360
360
|
### 1. send_telegram_message
|
@@ -128,7 +128,31 @@ Print a list of available function names in alphabetical order. If a filter is p
|
|
128
128
|
|
129
129
|
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.
|
130
130
|
|
131
|
-
### 1. `
|
131
|
+
### 1. `compute_prime_factors_latex`
|
132
|
+
|
133
|
+
Computes prime factors of a number and presents them in LaTeX format.
|
134
|
+
|
135
|
+
• Parameters:
|
136
|
+
- `n` (int): The integer to factorize.
|
137
|
+
|
138
|
+
• Returns:
|
139
|
+
- `str`: Prime factorization in LaTeX.
|
140
|
+
|
141
|
+
• Example:
|
142
|
+
|
143
|
+
from rgwfuncs import compute_prime_factors_latex
|
144
|
+
factors_1 = compute_prime_factors_latex(100)
|
145
|
+
print(factors_1) # Output: "2^{2} \cdot 5^{2}"
|
146
|
+
|
147
|
+
factors_2 = compute_prime_factors_latex(60)
|
148
|
+
print(factors_2) # Output: "2^{2} \cdot 3 \cdot 5"
|
149
|
+
|
150
|
+
factors_3 = compute_prime_factors_latex(17)
|
151
|
+
print(factors_3) # Output: "17"
|
152
|
+
|
153
|
+
--------------------------------------------------------------------------------
|
154
|
+
|
155
|
+
### 2. `compute_constant_expression`
|
132
156
|
|
133
157
|
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.
|
134
158
|
|
@@ -152,7 +176,7 @@ Computes the numerical result of a given expression, which can evaluate to a con
|
|
152
176
|
|
153
177
|
--------------------------------------------------------------------------------
|
154
178
|
|
155
|
-
###
|
179
|
+
### 3. `compute_constant_expression_involving_matrices`
|
156
180
|
|
157
181
|
Computes the result of a constant expression involving matrices and returns it as a LaTeX string.
|
158
182
|
|
@@ -180,7 +204,7 @@ Computes the result of a constant expression involving matrices and returns it a
|
|
180
204
|
|
181
205
|
--------------------------------------------------------------------------------
|
182
206
|
|
183
|
-
###
|
207
|
+
### 4. `compute_constant_expression_involving_ordered_series`
|
184
208
|
|
185
209
|
Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
|
186
210
|
|
@@ -209,7 +233,7 @@ Computes the result of a constant expression involving ordered series, and retur
|
|
209
233
|
|
210
234
|
--------------------------------------------------------------------------------
|
211
235
|
|
212
|
-
###
|
236
|
+
### 5. `python_polynomial_expression_to_latex`
|
213
237
|
|
214
238
|
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.
|
215
239
|
|
@@ -249,7 +273,7 @@ Converts a polynomial expression written in Python syntax to a LaTeX formatted s
|
|
249
273
|
|
250
274
|
--------------------------------------------------------------------------------
|
251
275
|
|
252
|
-
###
|
276
|
+
### 6. `simplify_polynomial_expression`
|
253
277
|
|
254
278
|
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.
|
255
279
|
|
@@ -282,7 +306,7 @@ Simplifies an algebraic expression in polynomial form and returns it in LaTeX fo
|
|
282
306
|
|
283
307
|
--------------------------------------------------------------------------------
|
284
308
|
|
285
|
-
###
|
309
|
+
### 7. `solve_homogeneous_polynomial_expression`
|
286
310
|
|
287
311
|
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.
|
288
312
|
|
@@ -305,30 +329,6 @@ Solves a homogeneous polynomial expression for a specified variable and returns
|
|
305
329
|
|
306
330
|
--------------------------------------------------------------------------------
|
307
331
|
|
308
|
-
### 7. `get_prime_factors_latex`
|
309
|
-
|
310
|
-
Computes prime factors of a number and presents them in LaTeX format.
|
311
|
-
|
312
|
-
• Parameters:
|
313
|
-
- `n` (int): The integer to factorize.
|
314
|
-
|
315
|
-
• Returns:
|
316
|
-
- `str`: Prime factorization in LaTeX.
|
317
|
-
|
318
|
-
• Example:
|
319
|
-
|
320
|
-
from rgwfuncs import get_prime_factors_latex
|
321
|
-
factors1 = get_prime_factors_latex(100)
|
322
|
-
print(factors1) # Output: "2^{2} \cdot 5^{2}"
|
323
|
-
|
324
|
-
factors2 = get_prime_factors_latex(60)
|
325
|
-
print(factors2) # Output: "2^{2} \cdot 3 \cdot 5"
|
326
|
-
|
327
|
-
factors3 = get_prime_factors_latex(17)
|
328
|
-
print(factors3) # Output: "17"
|
329
|
-
|
330
|
-
--------------------------------------------------------------------------------
|
331
|
-
|
332
332
|
## String Based Functions
|
333
333
|
|
334
334
|
### 1. send_telegram_message
|
@@ -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,
|
4
|
+
from .algebra_lib import compute_constant_expression, compute_constant_expression_involving_matrices, compute_constant_expression_involving_ordered_series, compute_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
|
@@ -10,6 +10,37 @@ from sympy.parsing.sympy_parser import (standard_transformations, implicit_multi
|
|
10
10
|
from typing import Tuple, List, Dict, Optional
|
11
11
|
|
12
12
|
|
13
|
+
def compute_prime_factors_latex(n: int) -> str:
|
14
|
+
"""
|
15
|
+
Computes the prime factors of a number and returns the factorization as a LaTeX string.
|
16
|
+
|
17
|
+
Determines the prime factorization of the given integer. The result is formatted as a LaTeX
|
18
|
+
string, enabling easy integration into documents or presentations that require mathematical notation.
|
19
|
+
|
20
|
+
Parameters:
|
21
|
+
n (int): The number for which to compute prime factors.
|
22
|
+
|
23
|
+
Returns:
|
24
|
+
str: The LaTeX representation of the prime factorization.
|
25
|
+
"""
|
26
|
+
|
27
|
+
factors = []
|
28
|
+
while n % 2 == 0:
|
29
|
+
factors.append(2)
|
30
|
+
n //= 2
|
31
|
+
for i in range(3, int(math.sqrt(n)) + 1, 2):
|
32
|
+
while n % i == 0:
|
33
|
+
factors.append(i)
|
34
|
+
n //= i
|
35
|
+
if n > 2:
|
36
|
+
factors.append(n)
|
37
|
+
|
38
|
+
factor_counts = {factor: factors.count(factor) for factor in set(factors)}
|
39
|
+
latex_factors = [f"{factor}^{{{count}}}" if count > 1 else str(
|
40
|
+
factor) for factor, count in factor_counts.items()]
|
41
|
+
return " \\cdot ".join(latex_factors)
|
42
|
+
|
43
|
+
|
13
44
|
def compute_constant_expression(expression: str) -> float:
|
14
45
|
"""
|
15
46
|
Computes the numerical result of a given expression, which can evaluate to a constant,
|
@@ -520,34 +551,3 @@ def solve_homogeneous_polynomial_expression(
|
|
520
551
|
raise ValueError(f"Error solving the expression: {e}")
|
521
552
|
|
522
553
|
|
523
|
-
|
524
|
-
|
525
|
-
def get_prime_factors_latex(n: int) -> str:
|
526
|
-
"""
|
527
|
-
Computes the prime factors of a number and returns the factorization as a LaTeX string.
|
528
|
-
|
529
|
-
Determines the prime factorization of the given integer. The result is formatted as a LaTeX
|
530
|
-
string, enabling easy integration into documents or presentations that require mathematical notation.
|
531
|
-
|
532
|
-
Parameters:
|
533
|
-
n (int): The number for which to compute prime factors.
|
534
|
-
|
535
|
-
Returns:
|
536
|
-
str: The LaTeX representation of the prime factorization.
|
537
|
-
"""
|
538
|
-
|
539
|
-
factors = []
|
540
|
-
while n % 2 == 0:
|
541
|
-
factors.append(2)
|
542
|
-
n //= 2
|
543
|
-
for i in range(3, int(math.sqrt(n)) + 1, 2):
|
544
|
-
while n % i == 0:
|
545
|
-
factors.append(i)
|
546
|
-
n //= i
|
547
|
-
if n > 2:
|
548
|
-
factors.append(n)
|
549
|
-
|
550
|
-
factor_counts = {factor: factors.count(factor) for factor in set(factors)}
|
551
|
-
latex_factors = [f"{factor}^{{{count}}}" if count > 1 else str(
|
552
|
-
factor) for factor, count in factor_counts.items()]
|
553
|
-
return " \\cdot ".join(latex_factors)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: rgwfuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.32
|
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,31 @@ 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_prime_factors_latex`
|
158
|
+
|
159
|
+
Computes prime factors of a number and presents them in LaTeX format.
|
160
|
+
|
161
|
+
• Parameters:
|
162
|
+
- `n` (int): The integer to factorize.
|
163
|
+
|
164
|
+
• Returns:
|
165
|
+
- `str`: Prime factorization in LaTeX.
|
166
|
+
|
167
|
+
• Example:
|
168
|
+
|
169
|
+
from rgwfuncs import compute_prime_factors_latex
|
170
|
+
factors_1 = compute_prime_factors_latex(100)
|
171
|
+
print(factors_1) # Output: "2^{2} \cdot 5^{2}"
|
172
|
+
|
173
|
+
factors_2 = compute_prime_factors_latex(60)
|
174
|
+
print(factors_2) # Output: "2^{2} \cdot 3 \cdot 5"
|
175
|
+
|
176
|
+
factors_3 = compute_prime_factors_latex(17)
|
177
|
+
print(factors_3) # Output: "17"
|
178
|
+
|
179
|
+
--------------------------------------------------------------------------------
|
180
|
+
|
181
|
+
### 2. `compute_constant_expression`
|
158
182
|
|
159
183
|
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
184
|
|
@@ -178,7 +202,7 @@ Computes the numerical result of a given expression, which can evaluate to a con
|
|
178
202
|
|
179
203
|
--------------------------------------------------------------------------------
|
180
204
|
|
181
|
-
###
|
205
|
+
### 3. `compute_constant_expression_involving_matrices`
|
182
206
|
|
183
207
|
Computes the result of a constant expression involving matrices and returns it as a LaTeX string.
|
184
208
|
|
@@ -206,7 +230,7 @@ Computes the result of a constant expression involving matrices and returns it a
|
|
206
230
|
|
207
231
|
--------------------------------------------------------------------------------
|
208
232
|
|
209
|
-
###
|
233
|
+
### 4. `compute_constant_expression_involving_ordered_series`
|
210
234
|
|
211
235
|
Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
|
212
236
|
|
@@ -235,7 +259,7 @@ Computes the result of a constant expression involving ordered series, and retur
|
|
235
259
|
|
236
260
|
--------------------------------------------------------------------------------
|
237
261
|
|
238
|
-
###
|
262
|
+
### 5. `python_polynomial_expression_to_latex`
|
239
263
|
|
240
264
|
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.
|
241
265
|
|
@@ -275,7 +299,7 @@ Converts a polynomial expression written in Python syntax to a LaTeX formatted s
|
|
275
299
|
|
276
300
|
--------------------------------------------------------------------------------
|
277
301
|
|
278
|
-
###
|
302
|
+
### 6. `simplify_polynomial_expression`
|
279
303
|
|
280
304
|
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.
|
281
305
|
|
@@ -308,7 +332,7 @@ Simplifies an algebraic expression in polynomial form and returns it in LaTeX fo
|
|
308
332
|
|
309
333
|
--------------------------------------------------------------------------------
|
310
334
|
|
311
|
-
###
|
335
|
+
### 7. `solve_homogeneous_polynomial_expression`
|
312
336
|
|
313
337
|
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.
|
314
338
|
|
@@ -331,30 +355,6 @@ Solves a homogeneous polynomial expression for a specified variable and returns
|
|
331
355
|
|
332
356
|
--------------------------------------------------------------------------------
|
333
357
|
|
334
|
-
### 7. `get_prime_factors_latex`
|
335
|
-
|
336
|
-
Computes prime factors of a number and presents them in LaTeX format.
|
337
|
-
|
338
|
-
• Parameters:
|
339
|
-
- `n` (int): The integer to factorize.
|
340
|
-
|
341
|
-
• Returns:
|
342
|
-
- `str`: Prime factorization in LaTeX.
|
343
|
-
|
344
|
-
• Example:
|
345
|
-
|
346
|
-
from rgwfuncs import get_prime_factors_latex
|
347
|
-
factors1 = get_prime_factors_latex(100)
|
348
|
-
print(factors1) # Output: "2^{2} \cdot 5^{2}"
|
349
|
-
|
350
|
-
factors2 = get_prime_factors_latex(60)
|
351
|
-
print(factors2) # Output: "2^{2} \cdot 3 \cdot 5"
|
352
|
-
|
353
|
-
factors3 = get_prime_factors_latex(17)
|
354
|
-
print(factors3) # Output: "17"
|
355
|
-
|
356
|
-
--------------------------------------------------------------------------------
|
357
|
-
|
358
358
|
## String Based Functions
|
359
359
|
|
360
360
|
### 1. send_telegram_message
|
@@ -7,13 +7,27 @@ import math
|
|
7
7
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
8
8
|
|
9
9
|
from src.rgwfuncs.algebra_lib import (
|
10
|
+
compute_prime_factors_latex,
|
10
11
|
compute_constant_expression,
|
11
12
|
compute_constant_expression_involving_matrices,
|
12
13
|
compute_constant_expression_involving_ordered_series,
|
13
14
|
python_polynomial_expression_to_latex,
|
14
15
|
simplify_polynomial_expression,
|
15
|
-
solve_homogeneous_polynomial_expression
|
16
|
-
|
16
|
+
solve_homogeneous_polynomial_expression)
|
17
|
+
|
18
|
+
|
19
|
+
def test_compute_prime_factors_latex():
|
20
|
+
test_cases = [
|
21
|
+
(100, "2^{2} \\cdot 5^{2}"),
|
22
|
+
(60, "2^{2} \\cdot 3 \\cdot 5"),
|
23
|
+
(45, "3^{2} \\cdot 5"),
|
24
|
+
(1, ""), # Handle case with 1, which has no prime factors
|
25
|
+
(17, "17") # Prime number itself
|
26
|
+
]
|
27
|
+
|
28
|
+
for n, expected_output in test_cases:
|
29
|
+
result = compute_prime_factors_latex(n)
|
30
|
+
assert result == expected_output, f"Failed for {n}, got {result}"
|
17
31
|
|
18
32
|
|
19
33
|
def test_compute_constant_expression():
|
@@ -127,15 +141,4 @@ def test_solve_homogeneous_polynomial_expression():
|
|
127
141
|
assert solve_homogeneous_polynomial_expression(expression, variable, subs) == expected_output
|
128
142
|
|
129
143
|
|
130
|
-
def test_get_prime_factors_latex():
|
131
|
-
test_cases = [
|
132
|
-
(100, "2^{2} \\cdot 5^{2}"),
|
133
|
-
(60, "2^{2} \\cdot 3 \\cdot 5"),
|
134
|
-
(45, "3^{2} \\cdot 5"),
|
135
|
-
(1, ""), # Handle case with 1, which has no prime factors
|
136
|
-
(17, "17") # Prime number itself
|
137
|
-
]
|
138
144
|
|
139
|
-
for n, expected_output in test_cases:
|
140
|
-
result = get_prime_factors_latex(n)
|
141
|
-
assert result == expected_output, f"Failed for {n}, got {result}"
|
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
|