rgwfuncs 0.0.33__py3-none-any.whl → 0.0.34__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 -0
- rgwfuncs/algebra_lib.py +3 -7
- rgwfuncs/interactive_shell_lib.py +32 -0
- {rgwfuncs-0.0.33.dist-info → rgwfuncs-0.0.34.dist-info}/METADATA +78 -1
- rgwfuncs-0.0.34.dist-info/RECORD +12 -0
- rgwfuncs-0.0.33.dist-info/RECORD +0 -11
- {rgwfuncs-0.0.33.dist-info → rgwfuncs-0.0.34.dist-info}/LICENSE +0 -0
- {rgwfuncs-0.0.33.dist-info → rgwfuncs-0.0.34.dist-info}/WHEEL +0 -0
- {rgwfuncs-0.0.33.dist-info → rgwfuncs-0.0.34.dist-info}/entry_points.txt +0 -0
- {rgwfuncs-0.0.33.dist-info → rgwfuncs-0.0.34.dist-info}/top_level.txt +0 -0
rgwfuncs/__init__.py
CHANGED
@@ -4,4 +4,5 @@
|
|
4
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
|
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
|
+
from .interactive_shell_lib import interactive_shell
|
7
8
|
from .str_lib import send_telegram_message
|
rgwfuncs/algebra_lib.py
CHANGED
@@ -76,7 +76,7 @@ def compute_constant_expression_involving_matrices(expression: str) -> str:
|
|
76
76
|
Computes the result of a constant expression involving matrices and returns it as a LaTeX string.
|
77
77
|
|
78
78
|
Parameters:
|
79
|
-
expression (str): The constant expression involving matrices. Example format includes operations such as "+",
|
79
|
+
expression (str): The constant expression involving matrices. Example format includes operations such as "+",
|
80
80
|
"-", "*", "/".
|
81
81
|
|
82
82
|
Returns:
|
@@ -161,9 +161,9 @@ def compute_constant_expression_involving_matrices(expression: str) -> str:
|
|
161
161
|
|
162
162
|
def compute_constant_expression_involving_ordered_series(expression: str) -> str:
|
163
163
|
"""
|
164
|
-
Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
|
164
|
+
Computes the result of a constant expression involving ordered series, and returns it as a Latex string.
|
165
165
|
Supports operations lile "+", "-", "*", "/", as well as "dd()" (the discrete difference operator).
|
166
|
-
|
166
|
+
|
167
167
|
The function first applies the discrete difference operator to any series where applicable, then evaluates
|
168
168
|
arithmetic operations between series.
|
169
169
|
|
@@ -261,8 +261,6 @@ def compute_constant_expression_involving_ordered_series(expression: str) -> str
|
|
261
261
|
return f"Error computing ordered series operation: {e}"
|
262
262
|
|
263
263
|
|
264
|
-
|
265
|
-
|
266
264
|
def python_polynomial_expression_to_latex(
|
267
265
|
expression: str,
|
268
266
|
subs: Optional[Dict[str, float]] = None
|
@@ -549,5 +547,3 @@ def solve_homogeneous_polynomial_expression(
|
|
549
547
|
|
550
548
|
except Exception as e:
|
551
549
|
raise ValueError(f"Error solving the expression: {e}")
|
552
|
-
|
553
|
-
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import code
|
2
|
+
import readline
|
3
|
+
import rlcompleter # noqa: F401
|
4
|
+
import sys # noqa: F401
|
5
|
+
from typing import Dict, Any
|
6
|
+
from .df_lib import * # noqa: F401, F403, E402
|
7
|
+
from .algebra_lib import * # noqa: F401, F403, E402
|
8
|
+
from .str_lib import * # noqa: F401, F403, E402
|
9
|
+
from .docs_lib import * # noqa: F401, F403, E402
|
10
|
+
|
11
|
+
|
12
|
+
def interactive_shell(local_vars: Dict[str, Any]) -> None:
|
13
|
+
"""
|
14
|
+
Launches an interactive prompt for inspecting and modifying local variables, making all methods
|
15
|
+
in the rgwfuncs library available by default.
|
16
|
+
|
17
|
+
Parameters:
|
18
|
+
local_vars (dict): Dictionary of local variables to be available in the interactive shell.
|
19
|
+
"""
|
20
|
+
if not isinstance(local_vars, dict):
|
21
|
+
raise TypeError("local_vars must be a dictionary")
|
22
|
+
|
23
|
+
readline.parse_and_bind("tab: complete")
|
24
|
+
|
25
|
+
# Make imported functions available in the REPL
|
26
|
+
local_vars.update(globals())
|
27
|
+
|
28
|
+
# Create interactive console with local context
|
29
|
+
console = code.InteractiveConsole(locals=local_vars)
|
30
|
+
|
31
|
+
# Start interactive session
|
32
|
+
console.interact(banner="Welcome to the rgwfuncs interactive shell.")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: rgwfuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.34
|
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
|
@@ -150,6 +150,83 @@ Print a list of available function names in alphabetical order. If a filter is p
|
|
150
150
|
|
151
151
|
--------------------------------------------------------------------------------
|
152
152
|
|
153
|
+
## Interactive Shell Function
|
154
|
+
|
155
|
+
This section includes functions that facilitate launching an interactive Python shell to inspect and modify local variables within the user's environment.
|
156
|
+
|
157
|
+
### 1. `interactive_shell`
|
158
|
+
|
159
|
+
#### Usage
|
160
|
+
|
161
|
+
Launches an interactive prompt for inspecting and modifying local variables, making all methods in the rgwfuncs library available by default. This REPL (Read-Eval-Print Loop) environment supports command history and autocompletion, making it easier to interact with your Python code.
|
162
|
+
|
163
|
+
• Parameters:
|
164
|
+
- `local_vars` (dict, optional): A dictionary of local variables to be accessible within the interactive shell. If not provided, defaults to an empty dictionary.
|
165
|
+
|
166
|
+
• Usage:
|
167
|
+
- You can call this function to enter an interactive shell where you can view and modify the variables in the given local scope.
|
168
|
+
|
169
|
+
• Example:
|
170
|
+
|
171
|
+
from rgwfuncs import interactive_shell
|
172
|
+
import pandas as pd
|
173
|
+
import numpy as np
|
174
|
+
|
175
|
+
# Example DataFrame
|
176
|
+
df = pd.DataFrame({
|
177
|
+
'id': [1, 2, 3, 4, 5],
|
178
|
+
'name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva'],
|
179
|
+
'age': [30, 25, 35, 28, 22],
|
180
|
+
'city': ['New York', 'Los Angeles', 'Chicago', 'San Francisco', 'Boston']
|
181
|
+
})
|
182
|
+
|
183
|
+
# Function to retrieve the first n rows of a DataFrame
|
184
|
+
def first_n_rows(df, n):
|
185
|
+
return df.head(n).to_dict('records')
|
186
|
+
|
187
|
+
# Launch the interactive shell with local variables
|
188
|
+
interactive_shell(locals())
|
189
|
+
|
190
|
+
- Once in the interactive shell, you are greeted with a welcome message. You can access the variables defined in the local scope where `interactive_shell(locals())` was called, including any imported modules such as `pandas` (accessed as `pd`) and `numpy` (accessed as `np`). This means you can directly use these modules in the interactive session. Type `exit()` to quit the shell.
|
191
|
+
|
192
|
+
#### Interactive Shell Example Sessions
|
193
|
+
|
194
|
+
1. DataFrame Inspection with Pandas:
|
195
|
+
|
196
|
+
Welcome to the rgwfuncs interactive shell.
|
197
|
+
>>> pirst_n_rows(df, 2)
|
198
|
+
Traceback (most recent call last):
|
199
|
+
File "<console>", line 1, in <module>
|
200
|
+
NameError: name 'pirst_n_rows' is not defined. Did you mean: 'first_n_rows'?
|
201
|
+
>>> first_n_rows(df, 2)
|
202
|
+
{'age': '30', 'city': 'New York', 'id': '1', 'name': 'Alice'}
|
203
|
+
{'age': '25', 'city': 'Los Angeles', 'id': '2', 'name': 'Bob'}
|
204
|
+
>>> print(df)
|
205
|
+
id name age city
|
206
|
+
0 1 Alice 30 New York
|
207
|
+
1 2 Bob 25 Los Angeles
|
208
|
+
2 3 Charlie 35 Chicago
|
209
|
+
3 4 David 28 San Francisco
|
210
|
+
4 5 Eva 22 Boston
|
211
|
+
|
212
|
+
2. Array Operations with NumPy:
|
213
|
+
|
214
|
+
Welcome to the rgwfuncs interactive shell.
|
215
|
+
>>> arr = np.array([1, 2, 3, 4, 5])
|
216
|
+
>>> arr
|
217
|
+
array([1, 2, 3, 4, 5])
|
218
|
+
|
219
|
+
These examples illustrate how you can use functions and variables within the interactive shell, handle errors with meaningful suggestions, and perform operations using external libraries like pandas and numpy.
|
220
|
+
|
221
|
+
#### Key Features
|
222
|
+
|
223
|
+
- Autocompletion: Uses the `rlcompleter` library to provide tab-completion of variables and functions names, enhancing ease of use.
|
224
|
+
- History Support: Utilizes `readline` for command-line history, allowing you to navigate through previous commands using the arrow keys.
|
225
|
+
|
226
|
+
This function is particularly useful for debugging purposes when you want real-time interaction with your program's execution environment.
|
227
|
+
|
228
|
+
--------------------------------------------------------------------------------
|
229
|
+
|
153
230
|
## Algebra Based Functions
|
154
231
|
|
155
232
|
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.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
rgwfuncs/__init__.py,sha256=CLPRpLtzXxyFHEjS-MrxnhXH0LdS6THjAC5sCHg0m3c,1520
|
2
|
+
rgwfuncs/algebra_lib.py,sha256=g-sNkf9Hz4i17uRIgLUYLQlyUu8yROgsoJMujdj0U3Y,21577
|
3
|
+
rgwfuncs/df_lib.py,sha256=G_H3PXNVeseX2YLjkkrmO9eXA_7r29swUZlbPBDZjXA,66612
|
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.34.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
8
|
+
rgwfuncs-0.0.34.dist-info/METADATA,sha256=JuG4wIxpjCaw7ST1u2lQHD9fBAUC9lC68X1E_4OztuM,48334
|
9
|
+
rgwfuncs-0.0.34.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
+
rgwfuncs-0.0.34.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
11
|
+
rgwfuncs-0.0.34.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
12
|
+
rgwfuncs-0.0.34.dist-info/RECORD,,
|
rgwfuncs-0.0.33.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
rgwfuncs/__init__.py,sha256=xs4RKtP6koffSxgfqG8b5E6qebsTmoQUMVj8-Hf2xj0,1467
|
2
|
-
rgwfuncs/algebra_lib.py,sha256=HAG57M5ce5RsPBcKX1LFwK7hr-b55vSRPmxjYxDdRkE,21585
|
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.33.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
7
|
-
rgwfuncs-0.0.33.dist-info/METADATA,sha256=7rjtuE5Q1RAd44zz995DwJXPdoGHEAp05cKkDQ_UKew,44916
|
8
|
-
rgwfuncs-0.0.33.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
9
|
-
rgwfuncs-0.0.33.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
|
10
|
-
rgwfuncs-0.0.33.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
|
11
|
-
rgwfuncs-0.0.33.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|