pythonic-fp-numpy 0.1.0__py3-none-any.whl → 0.1.2__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.
@@ -18,19 +18,17 @@ FP NumPy Tools
18
18
 
19
19
  Package implementing functional programming tools for NumPy.
20
20
 
21
- - wrapping a non-writable NDArray to make it hashable
22
-
23
21
  Modules
24
22
  -------
25
23
 
26
- +-------------------------------------------+-------------------------------------------+
27
- | Module | Description |
28
- +===========================================+===========================================+
29
- | **pythonic_fp_hashable_wrapped_ndarray** | Variable storage capacity circular array. |
30
- +-------------------------------------------+-------------------------------------------+
24
+ +-------------------------------+--------------------------------------+
25
+ | Module | Description |
26
+ +===============================+======================================+
27
+ | **hashable_wrapped_ndarray** | Make non-writable NDArrays hashable. |
28
+ +-------------------------------+--------------------------------------+
31
29
 
32
30
  """
33
31
 
34
32
  __author__ = 'Geoffrey R. Scheller'
35
- __copyright__ = 'Copyright (c) 2023-2025 Geoffrey R. Scheller'
33
+ __copyright__ = 'Copyright (c) 2023-2026 Geoffrey R. Scheller'
36
34
  __license__ = 'Apache License 2.0'
File without changes
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Geoffrey R. Scheller
1
+ # Copyright 2025-2026 Geoffrey R. Scheller
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -32,7 +32,18 @@ __all__ = [
32
32
 
33
33
 
34
34
  class DTypes(Enum):
35
- """Groups (Unions) of types closed to NumPy operations.
35
+ """Enumeration of closed NumPy datatypes.
36
+
37
+ .. admonition:: Groups (Unions) of NumPy datatypes closed to NumPy operations.
38
+
39
+ - number
40
+ - str\_
41
+ - bytes
42
+ - datetime64
43
+ - timedelta64
44
+ - bool\_
45
+ - void
46
+ - object\_
36
47
 
37
48
  While NumPy types are extensively covariant, the NumPy C internals
38
49
  are somewhat invariant. NumPy also suffers from what I call "Fortran
@@ -75,16 +86,16 @@ class HWrapNDArray(ABC):
75
86
  self._type = DTypes.str_
76
87
  elif issubclass(dtype, np.bytes_):
77
88
  self._type = DTypes.bytes
78
- elif issubclass(dtype, np.void):
79
- self._type = DTypes.void
80
- elif issubclass(dtype, np.object_):
81
- self._type = DTypes.object_
82
89
  elif issubclass(dtype, np.datetime64):
83
90
  self._type = DTypes.datetime64
84
91
  elif issubclass(dtype, np.timedelta64):
85
92
  self._type = DTypes.timedelta64
86
93
  elif issubclass(dtype, np.bool_):
87
94
  self._type = DTypes.bool_
95
+ elif issubclass(dtype, np.void):
96
+ self._type = DTypes.void
97
+ elif issubclass(dtype, np.object_):
98
+ self._type = DTypes.object_
88
99
  else:
89
100
  msg = f"HWrapNDArray: Unknow np.dtype '{dtype}'"
90
101
  raise TypeError(msg)
@@ -125,7 +136,7 @@ class HWrapNDArray(ABC):
125
136
  return f'hwrap<\n{np_array_str}\n>'
126
137
 
127
138
  def _repr(self) -> str:
128
- stripped_repr = ' '.join(repr(self._ndarray).split())
139
+ stripped_repr = ''.join(repr(self._ndarray).split())
129
140
  return f'np.{stripped_repr}'
130
141
 
131
142
  def copy(self) -> npt.NDArray[np.number]:
@@ -163,44 +174,44 @@ class HWrapNDArrayBytes(HWrapNDArray):
163
174
  return f'HWrapNDArrayBytes({self._repr()})'
164
175
 
165
176
 
166
- class HWrapNDArrayVoid(HWrapNDArray):
167
- """Wrap NDArrays of arbitrary byte sequences."""
177
+ class HWrapNDArrayDateTime(HWrapNDArray):
178
+ """Wrap NDArrays of references to arbitrary Python objects."""
168
179
 
169
- def __init__(self, ndarray: npt.NDArray[np.void]) -> None:
180
+ def __init__(self, ndarray: npt.NDArray[np.datetime64]) -> None:
170
181
  super().__init__(ndarray)
171
182
 
172
183
  def __repr__(self) -> str:
173
- return f'HWrapNDArrayVoid({self._repr()})'
184
+ return f'HWrapNDArrayTimeDelta({self._repr()})'
174
185
 
175
186
 
176
- class HWrapNDArrayObject(HWrapNDArray):
187
+ class HWrapNDArrayTimeDelta(HWrapNDArray):
177
188
  """Wrap NDArrays of references to arbitrary Python objects."""
178
189
 
179
- def __init__(self, ndarray: npt.NDArray[np.object_]) -> None:
190
+ def __init__(self, ndarray: npt.NDArray[np.timedelta64]) -> None:
180
191
  super().__init__(ndarray)
181
192
 
182
193
  def __repr__(self) -> str:
183
- return f'HWrapNDArrayObject({self._repr()})'
194
+ return f'HWrapNDArrayTimeDelta({self._repr()})'
184
195
 
185
196
 
186
- class HWrapNDArrayDateTime(HWrapNDArray):
187
- """Wrap NDArrays of references to arbitrary Python objects."""
197
+ class HWrapNDArrayVoid(HWrapNDArray):
198
+ """Wrap NDArrays of arbitrary byte sequences."""
188
199
 
189
- def __init__(self, ndarray: npt.NDArray[np.datetime64]) -> None:
200
+ def __init__(self, ndarray: npt.NDArray[np.void]) -> None:
190
201
  super().__init__(ndarray)
191
202
 
192
203
  def __repr__(self) -> str:
193
- return f'HWrapNDArrayTimeDelta({self._repr()})'
204
+ return f'HWrapNDArrayVoid({self._repr()})'
194
205
 
195
206
 
196
- class HWrapNDArrayTimeDelta(HWrapNDArray):
207
+ class HWrapNDArrayObject(HWrapNDArray):
197
208
  """Wrap NDArrays of references to arbitrary Python objects."""
198
209
 
199
- def __init__(self, ndarray: npt.NDArray[np.timedelta64]) -> None:
210
+ def __init__(self, ndarray: npt.NDArray[np.object_]) -> None:
200
211
  super().__init__(ndarray)
201
212
 
202
213
  def __repr__(self) -> str:
203
- return f'HWrapNDArrayTimeDelta({self._repr()})'
214
+ return f'HWrapNDArrayObject({self._repr()})'
204
215
 
205
216
 
206
217
  class HWrapNDArrayBool(HWrapNDArray):
@@ -211,9 +222,9 @@ class HWrapNDArrayBool(HWrapNDArray):
211
222
 
212
223
  .. note::
213
224
 
214
- - ***** uses component-wise Boolean **and**
215
- - **+** uses component-wise Boolean **or**
216
- - **@** does matrix multiplication using **and** then **or**
225
+ - ``*`` uses component-wise Boolean **and**
226
+ - ``+`` uses component-wise Boolean **or**
227
+ - ``@`` does matrix multiplication using **and** then **or**
217
228
 
218
229
  """
219
230
 
@@ -0,0 +1,48 @@
1
+ import abc
2
+ import numpy as np
3
+ import numpy.typing as npt
4
+ from abc import ABC
5
+ from enum import Enum
6
+
7
+ __all__ = ['DTypes', 'HWrapNDArray', 'HWrapNDArrayNumber', 'HWrapNDArrayString', 'HWrapNDArrayBytes', 'HWrapNDArrayVoid', 'HWrapNDArrayObject', 'HWrapNDArrayDateTime', 'HWrapNDArrayTimeDelta', 'HWrapNDArrayBool']
8
+
9
+ class DTypes(Enum):
10
+ number = ...
11
+ str_ = ...
12
+ bytes = ...
13
+ void = ...
14
+ object_ = ...
15
+ datetime64 = ...
16
+ timedelta64 = ...
17
+ bool_ = ...
18
+
19
+ class HWrapNDArray(ABC, metaclass=abc.ABCMeta):
20
+ def __init__(self, ndarray: npt.NDArray[np.generic]) -> None: ...
21
+ def __call__(self) -> npt.NDArray[np.number]: ...
22
+ def __hash__(self) -> int: ...
23
+ def __eq__(self, other: object) -> bool: ...
24
+ def copy(self) -> npt.NDArray[np.number]: ...
25
+
26
+ class HWrapNDArrayNumber(HWrapNDArray):
27
+ def __init__(self, ndarray: npt.NDArray[np.number]) -> None: ...
28
+
29
+ class HWrapNDArrayString(HWrapNDArray):
30
+ def __init__(self, ndarray: npt.NDArray[np.str_]) -> None: ...
31
+
32
+ class HWrapNDArrayBytes(HWrapNDArray):
33
+ def __init__(self, ndarray: npt.NDArray[np.bytes_]) -> None: ...
34
+
35
+ class HWrapNDArrayVoid(HWrapNDArray):
36
+ def __init__(self, ndarray: npt.NDArray[np.void]) -> None: ...
37
+
38
+ class HWrapNDArrayObject(HWrapNDArray):
39
+ def __init__(self, ndarray: npt.NDArray[np.object_]) -> None: ...
40
+
41
+ class HWrapNDArrayDateTime(HWrapNDArray):
42
+ def __init__(self, ndarray: npt.NDArray[np.datetime64]) -> None: ...
43
+
44
+ class HWrapNDArrayTimeDelta(HWrapNDArray):
45
+ def __init__(self, ndarray: npt.NDArray[np.timedelta64]) -> None: ...
46
+
47
+ class HWrapNDArrayBool(HWrapNDArray):
48
+ def __init__(self, ndarray: npt.NDArray[np.bool_]) -> None: ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonic-fp-numpy
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: FP NumPy Tools
5
5
  Keywords: numpy,ndarray,hashable,wrap
6
6
  Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
@@ -15,11 +15,12 @@ Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Typing :: Typed
16
16
  License-File: LICENSE
17
17
  Requires-Dist: numpy>=2.3.4
18
+ Requires-Dist: boring-math-abstract-algebra>=1.1.0 ; extra == "test"
18
19
  Requires-Dist: pytest>=8.4.1 ; extra == "test"
19
- Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-circulararray/blob/main/CHANGELOG.rst
20
- Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/circulararray/development/build/html/
20
+ Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-numpy/blob/main/CHANGELOG.rst
21
+ Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/numpy/development/build/html/
21
22
  Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/homepage/build/html/
22
- Project-URL: Source, https://github.com/grscheller/pythonic-fp-circulararray
23
+ Project-URL: Source, https://github.com/grscheller/pythonic-fp-numpy
23
24
  Provides-Extra: test
24
25
 
25
26
  Pythonic FP - FP NumPy
@@ -29,17 +30,20 @@ PyPI project
29
30
  `pythonic-fp-numpy
30
31
  <https://pypi.org/project/pythonic-fp-numpy>`_.
31
32
 
32
- Python module implementing functional programming for NumPy.
33
+ Python package implementing functional programming for NumPy.
33
34
 
34
35
  Part of the
35
36
  `pythonic-fp
36
37
  <https://grscheller.github.io/pythonic-fp>`_
37
38
  PyPI projects.
38
39
 
40
+ Modules
41
+ -------
42
+
39
43
  Module hashable_wrapped_ndarray
40
44
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41
45
 
42
- - wrap an NDArray and make it hashable
46
+ - wrap readonly NDArrays to make them hashable
43
47
  - prioritize performance over safety
44
48
  - see PyPI project boring-math-abstract-algebra for a use case
45
49
 
@@ -53,6 +57,6 @@ Documentation for this project is hosted on
53
57
  Copyright and License
54
58
  ---------------------
55
59
 
56
- Copyright (c) 2025 Geoffrey R. Scheller. Licensed under the Apache
60
+ Copyright (c) 2025-2026 Geoffrey R. Scheller. Licensed under the Apache
57
61
  License, Version 2.0. See the LICENSE file for details.
58
62
 
@@ -0,0 +1,9 @@
1
+ pythonic_fp/numpy/__init__.py,sha256=lXFznwyXPi4HeoJDOi0Y-CeMBcMlYgx5x92TZxU001U,1209
2
+ pythonic_fp/numpy/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ pythonic_fp/numpy/hashable_wrapped_ndarray.py,sha256=IfZvEwjSHJxCjFdAP_4tO6UGts1WjiBa8clQuFsL9nE,7016
4
+ pythonic_fp/numpy/hashable_wrapped_ndarray.pyi,sha256=J4jsl5q5Lz15-Amunh824R5JOxZk8hnSUlDuPXa5lcs,1666
5
+ pythonic_fp/numpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ pythonic_fp_numpy-0.1.2.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
7
+ pythonic_fp_numpy-0.1.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
8
+ pythonic_fp_numpy-0.1.2.dist-info/METADATA,sha256=OIHPnGrhVoPhFrPBi_DGHDSWDDgLoMJyPdrk4waMmno,1917
9
+ pythonic_fp_numpy-0.1.2.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- pythonic_fp/numpy/__init__.py,sha256=m4lHMlHUem6qWnVan0rzdjlCTrXYG7HJuFreFpfjqrE,1349
2
- pythonic_fp/numpy/hashable_wrapped_ndarray.py,sha256=IUy3XjNfBsKMRUQu5X7HWRV_dv5wGfC65_6oFmyoxi8,6798
3
- pythonic_fp/numpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- pythonic_fp_numpy-0.1.0.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
5
- pythonic_fp_numpy-0.1.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
6
- pythonic_fp_numpy-0.1.0.dist-info/METADATA,sha256=tC4RFYiDOpWXJJ9fy9QJ5rW_tBAHA7DRYiyTp4LKiYM,1841
7
- pythonic_fp_numpy-0.1.0.dist-info/RECORD,,