numpy2 1.0.0__tar.gz → 2.0.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.
- {numpy2-1.0.0/numpy2.egg-info → numpy2-2.0.0}/PKG-INFO +2 -2
- numpy2-2.0.0/numpy2/__init__.py +136 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/numpy2/core.py +30 -5
- {numpy2-1.0.0 → numpy2-2.0.0/numpy2.egg-info}/PKG-INFO +2 -2
- {numpy2-1.0.0 → numpy2-2.0.0}/pyproject.toml +2 -2
- {numpy2-1.0.0 → numpy2-2.0.0}/setup.py +2 -2
- numpy2-1.0.0/numpy2/__init__.py +0 -67
- {numpy2-1.0.0 → numpy2-2.0.0}/CONTRIBUTING.md +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/LICENSE +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/MANIFEST.in +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/README.md +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/numpy2/converters.py +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/numpy2/integrations.py +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/numpy2.egg-info/SOURCES.txt +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/numpy2.egg-info/dependency_links.txt +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/numpy2.egg-info/not-zip-safe +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/numpy2.egg-info/requires.txt +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/numpy2.egg-info/top_level.txt +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/setup.cfg +0 -0
- {numpy2-1.0.0 → numpy2-2.0.0}/tests/test_core.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: numpy2
|
|
3
|
-
Version:
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Drop-in NumPy replacement with web superpowers — full NumPy API + JSON serialization, FastAPI/Flask/Django integration
|
|
5
5
|
Home-page: https://github.com/maheshmakvana/numpy2
|
|
6
6
|
Author: Mahesh Makvana
|
|
7
7
|
Author-email: Mahesh Makvana <mahesh.makvana@example.com>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""
|
|
2
|
+
numpy2 - Drop-in NumPy replacement with Web Superpowers
|
|
3
|
+
========================================================
|
|
4
|
+
|
|
5
|
+
numpy2 is a 100% compatible drop-in replacement for NumPy.
|
|
6
|
+
Replace every ``import numpy as np`` with ``import numpy2 as np``
|
|
7
|
+
and everything works identically — PLUS you get built-in JSON
|
|
8
|
+
serialization, web framework integration, and type-safe conversions.
|
|
9
|
+
|
|
10
|
+
Built by: Mahesh Makvana
|
|
11
|
+
GitHub: https://github.com/maheshmakvana/numpy2
|
|
12
|
+
|
|
13
|
+
Drop-in usage:
|
|
14
|
+
>>> import numpy2 as np # replaces: import numpy as np
|
|
15
|
+
>>> arr = np.array([1, 2, 3]) # all numpy functions work
|
|
16
|
+
>>> arr.mean() # all numpy methods work
|
|
17
|
+
>>> np.linalg.inv(matrix) # all submodules work
|
|
18
|
+
>>> json_str = np.to_json(arr) # NEW: instant JSON serialization
|
|
19
|
+
|
|
20
|
+
Zero migration cost:
|
|
21
|
+
Just change your import line. Nothing else breaks.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
__version__ = "2.0.0"
|
|
25
|
+
__author__ = "Mahesh Makvana"
|
|
26
|
+
__email__ = "mahesh.makvana@example.com"
|
|
27
|
+
__license__ = "MIT"
|
|
28
|
+
|
|
29
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
30
|
+
# 1. Re-export the ENTIRE NumPy public API
|
|
31
|
+
# `from numpy import *` pulls in everything listed in numpy.__all__
|
|
32
|
+
# so any code doing `import numpy2 as np` gets full NumPy behaviour.
|
|
33
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
34
|
+
from numpy import * # noqa: F401, F403
|
|
35
|
+
|
|
36
|
+
import numpy as _np # internal reference used below
|
|
37
|
+
|
|
38
|
+
# Expose numpy itself as an attribute (e.g. numpy2.numpy.linalg)
|
|
39
|
+
numpy = _np
|
|
40
|
+
|
|
41
|
+
# ── Submodules ────────────────────────────────────────────────────────────────
|
|
42
|
+
# These must be imported explicitly; `from numpy import *` does NOT include them.
|
|
43
|
+
from numpy import linalg # noqa: F401
|
|
44
|
+
from numpy import fft # noqa: F401
|
|
45
|
+
from numpy import random # noqa: F401
|
|
46
|
+
from numpy import ma # noqa: F401
|
|
47
|
+
from numpy import polynomial # noqa: F401
|
|
48
|
+
from numpy import testing # noqa: F401
|
|
49
|
+
from numpy import lib # noqa: F401
|
|
50
|
+
from numpy import char # noqa: F401
|
|
51
|
+
|
|
52
|
+
# numpy.strings exists in NumPy 2.x; fall back silently on older versions
|
|
53
|
+
try:
|
|
54
|
+
from numpy import strings # noqa: F401
|
|
55
|
+
except ImportError:
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
# numpy.exceptions exists in NumPy 1.25+; fall back silently
|
|
59
|
+
try:
|
|
60
|
+
from numpy import exceptions # noqa: F401
|
|
61
|
+
except ImportError:
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
# ── Extra top-level names that numpy exposes but may not be in __all__ ────────
|
|
65
|
+
from numpy import ( # noqa: F401
|
|
66
|
+
# Index / grid helpers
|
|
67
|
+
c_, r_, s_, ix_, ogrid, mgrid, index_exp, ndindex,
|
|
68
|
+
# Functional
|
|
69
|
+
frompyfunc,
|
|
70
|
+
# Type aliases
|
|
71
|
+
int_, intp, intc,
|
|
72
|
+
bool_, object_, str_, bytes_,
|
|
73
|
+
# nditer
|
|
74
|
+
nditer, ndenumerate,
|
|
75
|
+
# Error handling
|
|
76
|
+
seterr, geterr, errstate, seterrcall, geterrcall,
|
|
77
|
+
# IO helpers
|
|
78
|
+
savetxt,
|
|
79
|
+
# Polynomial (legacy numpy.poly* API)
|
|
80
|
+
poly, poly1d, polyadd, polysub, polymul, polydiv,
|
|
81
|
+
polyder, polyint, polyval, polyfit,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
85
|
+
# 2. numpy2 Web Extras — new features on top of NumPy
|
|
86
|
+
# These additions make numpy2 superior to bare NumPy for web development.
|
|
87
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
88
|
+
from .core import ( # noqa: F401
|
|
89
|
+
to_json,
|
|
90
|
+
from_json,
|
|
91
|
+
serialize,
|
|
92
|
+
deserialize,
|
|
93
|
+
JSONEncoder,
|
|
94
|
+
JSONDecoder,
|
|
95
|
+
# Re-import our enhanced ndarray wrapper AFTER the star import so it
|
|
96
|
+
# takes precedence over numpy.ndarray for numpy2 users who call
|
|
97
|
+
# np2.ndarray([1,2,3]) and expect the web-enabled wrapper object.
|
|
98
|
+
ndarray as ndarray, # noqa: PLC0414
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
from .converters import ( # noqa: F401
|
|
102
|
+
numpy_to_python,
|
|
103
|
+
pandas_to_json,
|
|
104
|
+
python_to_numpy,
|
|
105
|
+
infer_dtype,
|
|
106
|
+
safe_cast,
|
|
107
|
+
batch_convert,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
from .integrations import ( # noqa: F401
|
|
111
|
+
FastAPIResponse,
|
|
112
|
+
FlaskResponse,
|
|
113
|
+
DjangoResponse,
|
|
114
|
+
setup_json_encoder,
|
|
115
|
+
create_response_handler,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
119
|
+
# 3. __all__ — NumPy's full list + numpy2 extras
|
|
120
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
121
|
+
_numpy2_extras = [
|
|
122
|
+
# Web / serialization
|
|
123
|
+
"to_json", "from_json", "serialize", "deserialize",
|
|
124
|
+
"JSONEncoder", "JSONDecoder",
|
|
125
|
+
# Type converters
|
|
126
|
+
"numpy_to_python", "pandas_to_json", "python_to_numpy",
|
|
127
|
+
"infer_dtype", "safe_cast", "batch_convert",
|
|
128
|
+
# Framework integrations
|
|
129
|
+
"FastAPIResponse", "FlaskResponse", "DjangoResponse",
|
|
130
|
+
"setup_json_encoder", "create_response_handler",
|
|
131
|
+
# Submodules
|
|
132
|
+
"linalg", "fft", "random", "ma", "polynomial",
|
|
133
|
+
"testing", "lib", "char", "numpy",
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
__all__ = list(getattr(_np, "__all__", [])) + _numpy2_extras
|
|
@@ -253,13 +253,38 @@ def serialize(obj: Any, include_metadata: bool = False) -> Dict[str, Any]:
|
|
|
253
253
|
return result
|
|
254
254
|
|
|
255
255
|
elif isinstance(obj, dict):
|
|
256
|
-
# Recursively serialize nested structures
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
# Recursively serialize nested structures.
|
|
257
|
+
# For plain ndarray values inside a dict we return the raw list so
|
|
258
|
+
# that callers get result['key'] == [1, 2, 3] rather than
|
|
259
|
+
# result['key'] == {'data': [1, 2, 3]}.
|
|
260
|
+
result = {}
|
|
261
|
+
for k, v in obj.items():
|
|
262
|
+
if isinstance(v, np.ndarray):
|
|
263
|
+
result[k] = v.tolist()
|
|
264
|
+
elif isinstance(v, pd.Series):
|
|
265
|
+
result[k] = v.to_dict()
|
|
266
|
+
elif isinstance(v, pd.DataFrame):
|
|
267
|
+
result[k] = v.to_dict(orient='records')
|
|
268
|
+
elif isinstance(v, (dict, list, tuple)):
|
|
269
|
+
result[k] = serialize(v, include_metadata)
|
|
270
|
+
else:
|
|
271
|
+
result[k] = v
|
|
272
|
+
return result
|
|
259
273
|
|
|
260
274
|
elif isinstance(obj, (list, tuple)):
|
|
261
|
-
|
|
262
|
-
|
|
275
|
+
out = []
|
|
276
|
+
for item in obj:
|
|
277
|
+
if isinstance(item, np.ndarray):
|
|
278
|
+
out.append(item.tolist())
|
|
279
|
+
elif isinstance(item, pd.Series):
|
|
280
|
+
out.append(item.to_dict())
|
|
281
|
+
elif isinstance(item, pd.DataFrame):
|
|
282
|
+
out.append(item.to_dict(orient='records'))
|
|
283
|
+
elif isinstance(item, (dict, list, tuple)):
|
|
284
|
+
out.append(serialize(item, include_metadata))
|
|
285
|
+
else:
|
|
286
|
+
out.append(item)
|
|
287
|
+
return out
|
|
263
288
|
|
|
264
289
|
else:
|
|
265
290
|
return json.loads(json.dumps(obj, cls=JSONEncoder))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: numpy2
|
|
3
|
-
Version:
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Drop-in NumPy replacement with web superpowers — full NumPy API + JSON serialization, FastAPI/Flask/Django integration
|
|
5
5
|
Home-page: https://github.com/maheshmakvana/numpy2
|
|
6
6
|
Author: Mahesh Makvana
|
|
7
7
|
Author-email: Mahesh Makvana <mahesh.makvana@example.com>
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "numpy2"
|
|
7
|
-
version = "
|
|
8
|
-
description = "
|
|
7
|
+
version = "2.0.0"
|
|
8
|
+
description = "Drop-in NumPy replacement with web superpowers — full NumPy API + JSON serialization, FastAPI/Flask/Django integration"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
11
11
|
license = {text = "MIT"}
|
|
@@ -15,10 +15,10 @@ long_description = readme_file.read_text(encoding="utf-8") if readme_file.exists
|
|
|
15
15
|
|
|
16
16
|
setup(
|
|
17
17
|
name="numpy2",
|
|
18
|
-
version="
|
|
18
|
+
version="2.0.0",
|
|
19
19
|
author="Mahesh Makvana",
|
|
20
20
|
author_email="mahesh.makvana@example.com",
|
|
21
|
-
description="
|
|
21
|
+
description="Drop-in NumPy replacement with web superpowers — full NumPy API + JSON serialization, FastAPI/Flask/Django integration",
|
|
22
22
|
long_description=long_description,
|
|
23
23
|
long_description_content_type="text/markdown",
|
|
24
24
|
url="https://github.com/maheshmakvana/numpy2",
|
numpy2-1.0.0/numpy2/__init__.py
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
numpy2 - Advanced NumPy for Web Applications
|
|
3
|
-
============================================
|
|
4
|
-
|
|
5
|
-
A powerful library that bridges NumPy and web frameworks, solving critical pain points:
|
|
6
|
-
- JSON serialization of NumPy types (int64, float64, etc.)
|
|
7
|
-
- Automatic type conversion for web APIs
|
|
8
|
-
- FastAPI/Flask/Django integration
|
|
9
|
-
- Zero-configuration setup
|
|
10
|
-
- Production-ready performance
|
|
11
|
-
|
|
12
|
-
Build by: Mahesh Makvana
|
|
13
|
-
GitHub: https://github.com/maheshmakvana/numpy2
|
|
14
|
-
|
|
15
|
-
Example:
|
|
16
|
-
>>> import numpy2 as np2
|
|
17
|
-
>>> arr = np2.array([1, 2, 3])
|
|
18
|
-
>>> json_safe = np2.to_json(arr)
|
|
19
|
-
>>> fastapi_response = np2.serialize(arr) # Ready for FastAPI JSONResponse
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
__version__ = "1.0.0"
|
|
23
|
-
__author__ = "Mahesh Makvana"
|
|
24
|
-
__email__ = "mahesh@example.com"
|
|
25
|
-
__license__ = "MIT"
|
|
26
|
-
|
|
27
|
-
from .core import (
|
|
28
|
-
array,
|
|
29
|
-
ndarray,
|
|
30
|
-
to_json,
|
|
31
|
-
from_json,
|
|
32
|
-
serialize,
|
|
33
|
-
deserialize,
|
|
34
|
-
JSONEncoder,
|
|
35
|
-
JSONDecoder,
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
from .converters import (
|
|
39
|
-
numpy_to_python,
|
|
40
|
-
pandas_to_json,
|
|
41
|
-
python_to_numpy,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
from .integrations import (
|
|
45
|
-
FastAPIResponse,
|
|
46
|
-
FlaskResponse,
|
|
47
|
-
DjangoResponse,
|
|
48
|
-
setup_json_encoder,
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
__all__ = [
|
|
52
|
-
"array",
|
|
53
|
-
"ndarray",
|
|
54
|
-
"to_json",
|
|
55
|
-
"from_json",
|
|
56
|
-
"serialize",
|
|
57
|
-
"deserialize",
|
|
58
|
-
"JSONEncoder",
|
|
59
|
-
"JSONDecoder",
|
|
60
|
-
"numpy_to_python",
|
|
61
|
-
"pandas_to_json",
|
|
62
|
-
"python_to_numpy",
|
|
63
|
-
"FastAPIResponse",
|
|
64
|
-
"FlaskResponse",
|
|
65
|
-
"DjangoResponse",
|
|
66
|
-
"setup_json_encoder",
|
|
67
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|