mumpy-toolkit 0.2.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 salim-studio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,200 @@
1
+ Metadata-Version: 2.4
2
+ Name: mumpy-toolkit
3
+ Version: 0.2.0
4
+ Summary: NumPy-compatible array library with multithreaded ufuncs, fused ops, plus built-in IO, SQL databases, DataFrame, stats, preprocessing, metrics, ML and tiny DL
5
+ Author-email: salim-studio <salim-studio@users.noreply.github.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/salim-studio/mumpy
8
+ Project-URL: Repository, https://github.com/salim-studio/mumpy
9
+ Project-URL: Issues, https://github.com/salim-studio/mumpy/issues
10
+ Project-URL: Documentation, https://github.com/salim-studio/mumpy#readme
11
+ Project-URL: Changelog, https://github.com/salim-studio/mumpy/blob/main/CHANGELOG.md
12
+ Keywords: numpy,arrays,dataframe,sql,machine-learning,deep-learning,statistics,preprocessing
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
24
+ Classifier: Topic :: Database
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: numpy>=1.24
29
+ Provides-Extra: fast
30
+ Requires-Dist: scipy>=1.10; extra == "fast"
31
+ Provides-Extra: io
32
+ Requires-Dist: pandas>=1.5; extra == "io"
33
+ Requires-Dist: pyarrow>=10; extra == "io"
34
+ Provides-Extra: db
35
+ Requires-Dist: sqlalchemy>=2.0; extra == "db"
36
+ Requires-Dist: duckdb>=0.8; extra == "db"
37
+ Provides-Extra: viz
38
+ Requires-Dist: matplotlib>=3.5; extra == "viz"
39
+ Provides-Extra: all
40
+ Requires-Dist: scipy>=1.10; extra == "all"
41
+ Requires-Dist: pandas>=1.5; extra == "all"
42
+ Requires-Dist: pyarrow>=10; extra == "all"
43
+ Requires-Dist: sqlalchemy>=2.0; extra == "all"
44
+ Requires-Dist: duckdb>=0.8; extra == "all"
45
+ Requires-Dist: matplotlib>=3.5; extra == "all"
46
+ Dynamic: license-file
47
+
48
+ <p align="center">
49
+ <img src="assets/banner.svg" alt="mumpy banner" width="100%"/>
50
+ </p>
51
+
52
+ <p align="center">
53
+ <img src="assets/logo.svg" alt="mumpy logo" width="96"/>
54
+ </p>
55
+
56
+ <h1 align="center">mumpy</h1>
57
+
58
+ <p align="center"><strong>NumPy you know. Speed you feel. Tools you actually need.</strong></p>
59
+
60
+ <p align="center">
61
+ <a href="https://github.com/salim-studio/mumpy/actions"><img src="https://github.com/salim-studio/mumpy/actions/workflows/ci.yml/badge.svg" alt="CI"/></a>
62
+ <img src="https://img.shields.io/badge/version-0.2.0-4F46E5" alt="version"/>
63
+ <img src="https://img.shields.io/badge/python-3.9%2B-06B6D4" alt="python"/>
64
+ <img src="https://img.shields.io/badge/numpy-compatible-013243" alt="numpy compatible"/>
65
+ <img src="https://img.shields.io/badge/license-MIT-FDE047" alt="license"/>
66
+ </p>
67
+
68
+ **mumpy** is a drop-in, NumPy-compatible library that goes further: multithreaded compute,
69
+ fused operations, plus a built-in toolkit for data loading, SQL databases, dataframes,
70
+ statistics, preprocessing, classic ML and tiny deep learning — with zero hard dependencies
71
+ beyond NumPy.
72
+
73
+ ```python
74
+ import mumpy as mp
75
+
76
+ # 1) Faster NumPy (parallel ufuncs + fused ops)
77
+ a = mp.arange(10_000_000)
78
+ b = mp.sqrt(a) # multithreaded over all cores
79
+ c = mp.fma(a, b, 1.0) # a*b+c in a single pass, half the peak memory
80
+
81
+ # 2) Databases (sqlite built-in; postgres/mysql via SQLAlchemy, OLAP via DuckDB)
82
+ db = mp.db.connect("data.db")
83
+ db.create_table("users", {"id": "INTEGER PRIMARY KEY", "name": "TEXT", "age": "INTEGER"})
84
+ db.insert_many("users", [{"name": "ada", "age": 36}])
85
+ ages = db.read_numpy("SELECT age FROM users")
86
+
87
+ # 3) Lightweight DataFrame for analysts (no pandas required)
88
+ df = mp.frame.DataFrame({"age": [20, 30, 40], "salary": [100, 200, 300]})
89
+ df.describe()
90
+ df.groupby("age").mean()
91
+ df.query("age > 25")
92
+
93
+ # 4) Classic ML with a scikit-learn-like API (pure NumPy)
94
+ model = mp.ml.LogisticRegression().fit(X_train, y_train)
95
+ pred = model.predict(X_test)
96
+
97
+ # 5) Tiny deep learning (pure NumPy)
98
+ net = mp.nn.Sequential([mp.nn.Dense(4, 16), mp.nn.ReLU(), mp.nn.Dense(16, 1)])
99
+ net.fit(X, y, epochs=200, lr=0.01)
100
+ ```
101
+
102
+ ## Why faster than NumPy?
103
+
104
+ | Technique | Detail |
105
+ |---|---|
106
+ | Parallel ufuncs | Compute-bound element-wise ops (`sqrt/exp/sin/cos/…`) split across a thread pool |
107
+ | Fused ops | `fma/fms/fnma/lerp` instead of `a*b+c` (half the peak memory, one pass) |
108
+ | Parallel FFT | `scipy.fft` with `workers=-1` when SciPy is installed |
109
+ | `einsum(optimize=True)` | Faster contraction paths |
110
+ | Contiguous linalg | `batch_matmul/cho_solve/ridge_solve` ensure cache-friendly layouts |
111
+
112
+ > Honest note: bandwidth-bound reductions (`sum/mean`) delegate to NumPy directly —
113
+ > a single thread already saturates RAM bandwidth, and threading only adds overhead there.
114
+
115
+ ## Modules
116
+
117
+ | Module | For | Highlights |
118
+ |---|---|---|
119
+ | `mp.io` | Everyone | `load_csv/save_csv/load_npy/load_npz/load_json/memmap/load_parquet/load_excel/read_auto` |
120
+ | `mp.db` | Backend devs & analysts | `connect/read_numpy/read_pandas/write_numpy/from_csv/query/to_parquet` |
121
+ | `mp.frame` | Data analysts | `DataFrame/filter/sort/groupby/merge/describe/corr/read_csv/read_sql/to_pandas` |
122
+ | `mp.stats` | Exploratory analysis | `describe/corr/zscore/iqr_outliers/histogram/skew/kurtosis/crosstab` |
123
+ | `mp.preprocessing` | Data science | `StandardScaler/MinMaxScaler/RobustScaler/OneHotEncoder/LabelEncoder/SimpleImputer/train_test_split/Pipeline` |
124
+ | `mp.metrics` | Model evaluation | `mse/rmse/mae/r2/accuracy/precision/recall/f1/confusion_matrix/roc_auc/log_loss` |
125
+ | `mp.ml` | Machine learning | `LinearRegression/Ridge/LogisticRegression/KNN/NaiveBayes/DecisionTree/RandomForest/KMeans/PCA` |
126
+ | `mp.nn` | Deep learning | `Sequential/Dense/ReLU/Sigmoid/Tanh/Softmax/Dropout/Adam/SGD/MSE/BCE/CrossEntropy` |
127
+ | `mp.viz` | Quick plots | `hist/scatter/line/heatmap/corr_heatmap` (matplotlib, optional) |
128
+ | `mp.utils` | Everyone | `seed/timer/timeit/one_hot/standardize/fill_nan/memory_usage` |
129
+
130
+ ## Installation
131
+
132
+ ```bash
133
+ pip install mumpy-toolkit # core (numpy only)
134
+ pip install "mumpy-toolkit[fast]" # + scipy for parallel FFT
135
+ pip install "mumpy-toolkit[all]" # scipy, pandas, pyarrow, sqlalchemy, duckdb, matplotlib
136
+ ```
137
+
138
+ From source:
139
+
140
+ ```bash
141
+ git clone https://github.com/salim-studio/mumpy.git
142
+ cd mumpy
143
+ pip install -e ".[all]"
144
+ ```
145
+
146
+ ## Compatibility
147
+
148
+ - `mumpy.ndarray` subclasses `np.ndarray` — any NumPy-consuming code accepts it unchanged.
149
+ - `mp.asnumpy(x)` returns a plain zero-copy `np.ndarray` view.
150
+ - `mp.set_workers(1)` reproduces pure-NumPy behavior for fair comparison.
151
+ - `DataFrame.to_pandas()/from_pandas()` bridge to pandas; `Database` works with stdlib
152
+ sqlite and optionally SQLAlchemy (PostgreSQL/MySQL) and DuckDB.
153
+ - Migrating from the old name? `import cumpy` still works via a compatibility shim.
154
+
155
+ ## Benchmarks & tests
156
+
157
+ ```bash
158
+ python benchmarks/bench.py
159
+ python -m pytest tests/ -q
160
+ python examples_mumpy.py # end-to-end: synthetic data -> DB -> DataFrame -> ML
161
+ ```
162
+
163
+ ## End-to-end example (synthetic data → DB → ML)
164
+
165
+ ```python
166
+ import numpy as np
167
+ import mumpy as mp
168
+
169
+ rng = np.random.default_rng(0)
170
+ X = rng.normal(size=(200, 3))
171
+ y = (X[:, 0] + X[:, 1] > 0).astype(int)
172
+
173
+ with mp.db.connect(":memory:") as db:
174
+ db.write_numpy("data", np.column_stack([X, y]), columns=["f0", "f1", "f2", "label"])
175
+ df = mp.frame.DataFrame.read_sql("SELECT * FROM data", db)
176
+
177
+ print(df.describe())
178
+ Xtr, Xte, ytr, yte = mp.ml.train_test_split(
179
+ df.to_numpy(["f0", "f1", "f2"]), df["label"].to_numpy(), test_size=0.2)
180
+ acc = mp.metrics.accuracy(
181
+ yte, mp.ml.LogisticRegression(lr=0.5, epochs=500).fit(Xtr, ytr).predict(Xte))
182
+ print("accuracy:", acc)
183
+ ```
184
+
185
+ ## Roadmap
186
+
187
+ - [ ] PyPI release + versioned changelog
188
+ - [ ] Optional Rust/Numba backend for ufuncs
189
+ - [ ] `mp.sql` query builder + lazy frames
190
+ - [ ] More estimators (Gradient Boosting, Isolation Forest)
191
+ - [ ] ONNX export for `mp.nn`
192
+
193
+ ## Contributing
194
+
195
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Bug reports and feature requests are welcome via
196
+ [issues](https://github.com/salim-studio/mumpy/issues) — please use the templates.
197
+
198
+ ## License
199
+
200
+ MIT — see [LICENSE](LICENSE). © salim-studio.
@@ -0,0 +1,153 @@
1
+ <p align="center">
2
+ <img src="assets/banner.svg" alt="mumpy banner" width="100%"/>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <img src="assets/logo.svg" alt="mumpy logo" width="96"/>
7
+ </p>
8
+
9
+ <h1 align="center">mumpy</h1>
10
+
11
+ <p align="center"><strong>NumPy you know. Speed you feel. Tools you actually need.</strong></p>
12
+
13
+ <p align="center">
14
+ <a href="https://github.com/salim-studio/mumpy/actions"><img src="https://github.com/salim-studio/mumpy/actions/workflows/ci.yml/badge.svg" alt="CI"/></a>
15
+ <img src="https://img.shields.io/badge/version-0.2.0-4F46E5" alt="version"/>
16
+ <img src="https://img.shields.io/badge/python-3.9%2B-06B6D4" alt="python"/>
17
+ <img src="https://img.shields.io/badge/numpy-compatible-013243" alt="numpy compatible"/>
18
+ <img src="https://img.shields.io/badge/license-MIT-FDE047" alt="license"/>
19
+ </p>
20
+
21
+ **mumpy** is a drop-in, NumPy-compatible library that goes further: multithreaded compute,
22
+ fused operations, plus a built-in toolkit for data loading, SQL databases, dataframes,
23
+ statistics, preprocessing, classic ML and tiny deep learning — with zero hard dependencies
24
+ beyond NumPy.
25
+
26
+ ```python
27
+ import mumpy as mp
28
+
29
+ # 1) Faster NumPy (parallel ufuncs + fused ops)
30
+ a = mp.arange(10_000_000)
31
+ b = mp.sqrt(a) # multithreaded over all cores
32
+ c = mp.fma(a, b, 1.0) # a*b+c in a single pass, half the peak memory
33
+
34
+ # 2) Databases (sqlite built-in; postgres/mysql via SQLAlchemy, OLAP via DuckDB)
35
+ db = mp.db.connect("data.db")
36
+ db.create_table("users", {"id": "INTEGER PRIMARY KEY", "name": "TEXT", "age": "INTEGER"})
37
+ db.insert_many("users", [{"name": "ada", "age": 36}])
38
+ ages = db.read_numpy("SELECT age FROM users")
39
+
40
+ # 3) Lightweight DataFrame for analysts (no pandas required)
41
+ df = mp.frame.DataFrame({"age": [20, 30, 40], "salary": [100, 200, 300]})
42
+ df.describe()
43
+ df.groupby("age").mean()
44
+ df.query("age > 25")
45
+
46
+ # 4) Classic ML with a scikit-learn-like API (pure NumPy)
47
+ model = mp.ml.LogisticRegression().fit(X_train, y_train)
48
+ pred = model.predict(X_test)
49
+
50
+ # 5) Tiny deep learning (pure NumPy)
51
+ net = mp.nn.Sequential([mp.nn.Dense(4, 16), mp.nn.ReLU(), mp.nn.Dense(16, 1)])
52
+ net.fit(X, y, epochs=200, lr=0.01)
53
+ ```
54
+
55
+ ## Why faster than NumPy?
56
+
57
+ | Technique | Detail |
58
+ |---|---|
59
+ | Parallel ufuncs | Compute-bound element-wise ops (`sqrt/exp/sin/cos/…`) split across a thread pool |
60
+ | Fused ops | `fma/fms/fnma/lerp` instead of `a*b+c` (half the peak memory, one pass) |
61
+ | Parallel FFT | `scipy.fft` with `workers=-1` when SciPy is installed |
62
+ | `einsum(optimize=True)` | Faster contraction paths |
63
+ | Contiguous linalg | `batch_matmul/cho_solve/ridge_solve` ensure cache-friendly layouts |
64
+
65
+ > Honest note: bandwidth-bound reductions (`sum/mean`) delegate to NumPy directly —
66
+ > a single thread already saturates RAM bandwidth, and threading only adds overhead there.
67
+
68
+ ## Modules
69
+
70
+ | Module | For | Highlights |
71
+ |---|---|---|
72
+ | `mp.io` | Everyone | `load_csv/save_csv/load_npy/load_npz/load_json/memmap/load_parquet/load_excel/read_auto` |
73
+ | `mp.db` | Backend devs & analysts | `connect/read_numpy/read_pandas/write_numpy/from_csv/query/to_parquet` |
74
+ | `mp.frame` | Data analysts | `DataFrame/filter/sort/groupby/merge/describe/corr/read_csv/read_sql/to_pandas` |
75
+ | `mp.stats` | Exploratory analysis | `describe/corr/zscore/iqr_outliers/histogram/skew/kurtosis/crosstab` |
76
+ | `mp.preprocessing` | Data science | `StandardScaler/MinMaxScaler/RobustScaler/OneHotEncoder/LabelEncoder/SimpleImputer/train_test_split/Pipeline` |
77
+ | `mp.metrics` | Model evaluation | `mse/rmse/mae/r2/accuracy/precision/recall/f1/confusion_matrix/roc_auc/log_loss` |
78
+ | `mp.ml` | Machine learning | `LinearRegression/Ridge/LogisticRegression/KNN/NaiveBayes/DecisionTree/RandomForest/KMeans/PCA` |
79
+ | `mp.nn` | Deep learning | `Sequential/Dense/ReLU/Sigmoid/Tanh/Softmax/Dropout/Adam/SGD/MSE/BCE/CrossEntropy` |
80
+ | `mp.viz` | Quick plots | `hist/scatter/line/heatmap/corr_heatmap` (matplotlib, optional) |
81
+ | `mp.utils` | Everyone | `seed/timer/timeit/one_hot/standardize/fill_nan/memory_usage` |
82
+
83
+ ## Installation
84
+
85
+ ```bash
86
+ pip install mumpy-toolkit # core (numpy only)
87
+ pip install "mumpy-toolkit[fast]" # + scipy for parallel FFT
88
+ pip install "mumpy-toolkit[all]" # scipy, pandas, pyarrow, sqlalchemy, duckdb, matplotlib
89
+ ```
90
+
91
+ From source:
92
+
93
+ ```bash
94
+ git clone https://github.com/salim-studio/mumpy.git
95
+ cd mumpy
96
+ pip install -e ".[all]"
97
+ ```
98
+
99
+ ## Compatibility
100
+
101
+ - `mumpy.ndarray` subclasses `np.ndarray` — any NumPy-consuming code accepts it unchanged.
102
+ - `mp.asnumpy(x)` returns a plain zero-copy `np.ndarray` view.
103
+ - `mp.set_workers(1)` reproduces pure-NumPy behavior for fair comparison.
104
+ - `DataFrame.to_pandas()/from_pandas()` bridge to pandas; `Database` works with stdlib
105
+ sqlite and optionally SQLAlchemy (PostgreSQL/MySQL) and DuckDB.
106
+ - Migrating from the old name? `import cumpy` still works via a compatibility shim.
107
+
108
+ ## Benchmarks & tests
109
+
110
+ ```bash
111
+ python benchmarks/bench.py
112
+ python -m pytest tests/ -q
113
+ python examples_mumpy.py # end-to-end: synthetic data -> DB -> DataFrame -> ML
114
+ ```
115
+
116
+ ## End-to-end example (synthetic data → DB → ML)
117
+
118
+ ```python
119
+ import numpy as np
120
+ import mumpy as mp
121
+
122
+ rng = np.random.default_rng(0)
123
+ X = rng.normal(size=(200, 3))
124
+ y = (X[:, 0] + X[:, 1] > 0).astype(int)
125
+
126
+ with mp.db.connect(":memory:") as db:
127
+ db.write_numpy("data", np.column_stack([X, y]), columns=["f0", "f1", "f2", "label"])
128
+ df = mp.frame.DataFrame.read_sql("SELECT * FROM data", db)
129
+
130
+ print(df.describe())
131
+ Xtr, Xte, ytr, yte = mp.ml.train_test_split(
132
+ df.to_numpy(["f0", "f1", "f2"]), df["label"].to_numpy(), test_size=0.2)
133
+ acc = mp.metrics.accuracy(
134
+ yte, mp.ml.LogisticRegression(lr=0.5, epochs=500).fit(Xtr, ytr).predict(Xte))
135
+ print("accuracy:", acc)
136
+ ```
137
+
138
+ ## Roadmap
139
+
140
+ - [ ] PyPI release + versioned changelog
141
+ - [ ] Optional Rust/Numba backend for ufuncs
142
+ - [ ] `mp.sql` query builder + lazy frames
143
+ - [ ] More estimators (Gradient Boosting, Isolation Forest)
144
+ - [ ] ONNX export for `mp.nn`
145
+
146
+ ## Contributing
147
+
148
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Bug reports and feature requests are welcome via
149
+ [issues](https://github.com/salim-studio/mumpy/issues) — please use the templates.
150
+
151
+ ## License
152
+
153
+ MIT — see [LICENSE](LICENSE). © salim-studio.
@@ -0,0 +1,128 @@
1
+ """mumpy — drop-in numpy-compatible library + data-science / ML / DL toolkit.
2
+
3
+ Same API as numpy for the common 95%:
4
+ import mumpy as cp
5
+ a = cp.arange(10_000_000)
6
+ b = cp.sqrt(a) # multithreaded for large arrays
7
+ c = cp.fma(a, b, 1.0) # fused a*b+c, single pass
8
+
9
+ Beyond numpy — one import for the whole workflow:
10
+ cp.io / cp.db / cp.frame # IO, databases (sqlite/postgres/duckdb), DataFrame
11
+ cp.stats / cp.preprocessing # EDA, scalers, encoders, imputers
12
+ cp.metrics / cp.ml # metrics + classic ML (sklearn-like API)
13
+ cp.nn / cp.viz / cp.utils # tiny deep learning + one-line plots
14
+
15
+ Speed sources (no C compiler needed):
16
+ 1. chunked ThreadPool for compute-bound element-wise ufuncs,
17
+ 2. fused multiply-add fma/fms/fnma/lerp with half peak memory,
18
+ 3. scipy.fft with workers=-1 when available,
19
+ 4. einsum(optimize=True), contiguous-layout matmul.
20
+ """
21
+ from __future__ import annotations
22
+
23
+ import numpy as _np
24
+
25
+ from ._core import (
26
+ ndarray, array, asarray, asanyarray, ascontiguousarray, asnumpy, copy,
27
+ zeros, ones, empty, full, zeros_like, ones_like, empty_like, full_like,
28
+ arange, linspace, logspace, eye, identity, diag,
29
+ reshape, ravel, transpose, concatenate, stack, vstack, hstack,
30
+ split, tile, repeat,
31
+ )
32
+ from ._math import (
33
+ add, subtract, multiply, divide, power, sqrt, exp, log,
34
+ sin, cos, tan, abs, absolute, clip, where, fma, fms, fnma, lerp,
35
+ hypot, maximum, minimum, expm1, log1p, log2, log10, square, cbrt,
36
+ reciprocal, arcsin, arccos, arctan, arctan2, sinh, cosh, tanh,
37
+ floor, ceil, rint, sign, sinc,
38
+ sum, mean, min, max, amin, amax, prod, std, var,
39
+ nansum, nanmean, nanmin, nanmax, nanstd,
40
+ any, all, cumsum, cumprod, dot, matmul, einsum, tensordot,
41
+ vdot, inner, outer, kron, trace, sort, argsort,
42
+ )
43
+ from . import linalg, fft, random, io, db, frame, stats, preprocessing, metrics, ml, nn, utils
44
+ try:
45
+ from . import viz # optional matplotlib
46
+ except Exception:
47
+ viz = None # type: ignore
48
+ from ._parallel import MAX_WORKERS, PARALLEL_THRESHOLD, get_workers
49
+
50
+ __version__ = "0.2.0"
51
+
52
+ # ---- numpy compat: re-export everything else verbatim ----
53
+ _COMPAT = [
54
+ "pi", "e", "inf", "nan", "newaxis",
55
+ "float16", "float32", "float64", "int8", "int16", "int32", "int64",
56
+ "uint8", "uint16", "uint32", "uint64", "bool_", "complex64", "complex128",
57
+ "ndim", "shape", "size", "dtype", "result_type", "broadcast_arrays",
58
+ "broadcast_to", "expand_dims", "squeeze", "flatten", "moveaxis",
59
+ "swapaxes", "flip", "roll", "rot90", "pad", "meshgrid",
60
+ "unique", "intersect1d", "union1d", "setdiff1d", "isin", "in1d",
61
+ "take", "put", "compress", "extract", "argmax", "argmin", "nonzero",
62
+ "count_nonzero", "flatnonzero", "argwhere", "searchsorted", "digitize",
63
+ "histogram", "bincount", "corrcoef", "cov", "polyfit", "polyval",
64
+ "convolve", "gradient", "diff", "ediff1d", "interp", "percentile",
65
+ "quantile", "median", "average", "ptp", "allclose", "isclose",
66
+ "array_equal", "array_equiv", "isnan", "isinf", "isfinite",
67
+ "nan_to_num", "nansum", "nanmean", "nanmin", "nanmax",
68
+ "logical_and", "logical_or", "logical_not", "logical_xor",
69
+ "greater", "greater_equal", "less", "less_equal", "equal", "not_equal",
70
+ "fmax", "fmin",
71
+ "arctan2",
72
+ "round", "fix", "trunc",
73
+ "real", "imag", "conj", "conjugate", "angle",
74
+ "degrees", "radians", "mod", "remainder", "divmod", "fmod",
75
+ "bitwise_and", "bitwise_or", "bitwise_xor", "invert", "left_shift", "right_shift",
76
+ "vecdot",
77
+ ]
78
+ for _name in _COMPAT:
79
+ if hasattr(_np, _name) and _name not in globals():
80
+ globals()[_name] = getattr(_np, _name)
81
+
82
+ __all__ = [
83
+ "ndarray", "array", "asarray", "asanyarray", "ascontiguousarray", "asnumpy", "copy",
84
+ "zeros", "ones", "empty", "full", "zeros_like", "ones_like", "empty_like", "full_like",
85
+ "arange", "linspace", "logspace", "eye", "identity", "diag",
86
+ "reshape", "ravel", "transpose", "concatenate", "stack", "vstack", "hstack",
87
+ "split", "tile", "repeat",
88
+ "add", "subtract", "multiply", "divide", "power", "sqrt", "exp", "log",
89
+ "sin", "cos", "tan", "abs", "absolute", "clip", "where", "fma", "fms", "fnma", "lerp",
90
+ "hypot", "maximum", "minimum", "expm1", "log1p", "log2", "log10", "square", "cbrt",
91
+ "reciprocal", "arcsin", "arccos", "arctan", "arctan2", "sinh", "cosh", "tanh",
92
+ "floor", "ceil", "rint", "sign", "sinc",
93
+ "sum", "mean", "min", "max", "amin", "amax", "prod", "std", "var",
94
+ "nansum", "nanmean", "nanmin", "nanmax", "nanstd",
95
+ "any", "all", "cumsum", "cumprod", "dot", "matmul", "einsum", "tensordot",
96
+ "vdot", "inner", "outer", "kron", "trace", "sort", "argsort",
97
+ "linalg", "fft", "random", "io", "db", "frame", "stats", "preprocessing",
98
+ "metrics", "ml", "nn", "utils", "viz",
99
+ "MAX_WORKERS", "PARALLEL_THRESHOLD",
100
+ "__version__",
101
+ ]
102
+
103
+
104
+ def info():
105
+ import os
106
+ return {
107
+ "version": __version__,
108
+ "numpy": _np.__version__,
109
+ "workers": MAX_WORKERS,
110
+ "cpus": os.cpu_count(),
111
+ "parallel_threshold": PARALLEL_THRESHOLD,
112
+ "scipy_fft": fft.has_scipy(),
113
+ "modules": ["io", "db", "frame", "stats", "preprocessing",
114
+ "metrics", "ml", "nn", "utils", "viz"],
115
+ }
116
+
117
+
118
+ def set_workers(n: int):
119
+ """Tune parallelism. set_workers(1) == pure-numpy behavior."""
120
+ from . import _parallel
121
+ _parallel.MAX_WORKERS = max(1, int(n))
122
+ globals()["MAX_WORKERS"] = _parallel.MAX_WORKERS
123
+
124
+
125
+ def set_threshold(n: int):
126
+ from . import _parallel
127
+ _parallel.PARALLEL_THRESHOLD = int(n)
128
+ globals()["PARALLEL_THRESHOLD"] = int(n)