nrumpy 0.1.0__tar.gz → 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.
- {nrumpy-0.1.0 → nrumpy-0.2.0}/PKG-INFO +5 -5
- {nrumpy-0.1.0 → nrumpy-0.2.0}/README.md +4 -4
- {nrumpy-0.1.0 → nrumpy-0.2.0}/pyproject.toml +7 -6
- {nrumpy-0.1.0/python/rumpy → nrumpy-0.2.0/python/nrumpy}/__init__.py +6 -6
- {nrumpy-0.1.0/python/rumpy → nrumpy-0.2.0/python/nrumpy}/__init__.pyi +1 -1
- {nrumpy-0.1.0/python/rumpy → nrumpy-0.2.0/python/nrumpy}/_convert.py +4 -4
- {nrumpy-0.1.0/python/rumpy → nrumpy-0.2.0/python/nrumpy}/core.py +7 -7
- {nrumpy-0.1.0/python/rumpy → nrumpy-0.2.0/python/nrumpy}/errors.py +5 -5
- {nrumpy-0.1.0 → nrumpy-0.2.0}/Cargo.lock +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/Cargo.toml +0 -0
- {nrumpy-0.1.0/python/rumpy → nrumpy-0.2.0/python/nrumpy}/py.typed +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/Cargo.toml +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/benches/matmul.rs +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/benches/matrix.rs +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/src/error.rs +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/src/lib.rs +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/src/matrix.rs +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/src/naive.rs +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/src/strassen.rs +0 -0
- {nrumpy-0.1.0 → nrumpy-0.2.0}/rumpy-core/tests/matmul.rs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nrumpy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -65,12 +65,12 @@ A zero side is not padded. `next_power_of_two(0)` is `1`, which would turn an em
|
|
|
65
65
|
## Python
|
|
66
66
|
|
|
67
67
|
```python
|
|
68
|
-
|
|
68
|
+
import nrumpy
|
|
69
69
|
|
|
70
|
-
matmul([[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]])
|
|
70
|
+
nrumpy.matmul([[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]])
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
`matmul` accepts nested lists, tuples of rows, and 2-D NumPy arrays. A NumPy left-hand matrix returns a `float64` array. Any other left-hand matrix returns a nested list. `leaf_size` defaults to 64. `leaf_size=0` skips Strassen and uses the plain triple loop. Importing `
|
|
73
|
+
`matmul` accepts nested lists, tuples of rows, and 2-D NumPy arrays. A NumPy left-hand matrix returns a `float64` array. Any other left-hand matrix returns a nested list. `leaf_size` defaults to 64. `leaf_size=0` skips Strassen and uses the plain triple loop. Importing `nrumpy` does not require the extension to be built.
|
|
74
74
|
|
|
75
75
|
`pyproject.toml` sets `extension-module`, so these commands from the repository root pass that feature through:
|
|
76
76
|
|
|
@@ -83,7 +83,7 @@ maturin develop --release
|
|
|
83
83
|
|
|
84
84
|
# wheel, then install
|
|
85
85
|
maturin build --release
|
|
86
|
-
pip install target/wheels/
|
|
86
|
+
pip install target/wheels/nrumpy-*.whl
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
`make dev`, `make test`, `make fmt`, and `make lint` run those steps from the repository root. `make dev` is `maturin develop --release`.
|
|
@@ -38,12 +38,12 @@ A zero side is not padded. `next_power_of_two(0)` is `1`, which would turn an em
|
|
|
38
38
|
## Python
|
|
39
39
|
|
|
40
40
|
```python
|
|
41
|
-
|
|
41
|
+
import nrumpy
|
|
42
42
|
|
|
43
|
-
matmul([[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]])
|
|
43
|
+
nrumpy.matmul([[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]])
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
`matmul` accepts nested lists, tuples of rows, and 2-D NumPy arrays. A NumPy left-hand matrix returns a `float64` array. Any other left-hand matrix returns a nested list. `leaf_size` defaults to 64. `leaf_size=0` skips Strassen and uses the plain triple loop. Importing `
|
|
46
|
+
`matmul` accepts nested lists, tuples of rows, and 2-D NumPy arrays. A NumPy left-hand matrix returns a `float64` array. Any other left-hand matrix returns a nested list. `leaf_size` defaults to 64. `leaf_size=0` skips Strassen and uses the plain triple loop. Importing `nrumpy` does not require the extension to be built.
|
|
47
47
|
|
|
48
48
|
`pyproject.toml` sets `extension-module`, so these commands from the repository root pass that feature through:
|
|
49
49
|
|
|
@@ -56,7 +56,7 @@ maturin develop --release
|
|
|
56
56
|
|
|
57
57
|
# wheel, then install
|
|
58
58
|
maturin build --release
|
|
59
|
-
pip install target/wheels/
|
|
59
|
+
pip install target/wheels/nrumpy-*.whl
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
`make dev`, `make test`, `make fmt`, and `make lint` run those steps from the repository root. `make dev` is `maturin develop --release`.
|
|
@@ -3,9 +3,9 @@ requires = ["maturin>=1.7,<2.0"]
|
|
|
3
3
|
build-backend = "maturin"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
|
-
# Distribution name
|
|
6
|
+
# Distribution name and import name are both `nrumpy`.
|
|
7
7
|
name = "nrumpy"
|
|
8
|
-
version = "0.
|
|
8
|
+
version = "0.2.0"
|
|
9
9
|
description = "Strassen matrix multiplication for NumPy arrays and nested lists"
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3.10"
|
|
@@ -38,14 +38,15 @@ Repository = "https://github.com/jaysit-gif/rumpy"
|
|
|
38
38
|
Documentation = "https://github.com/jaysit-gif/rumpy/blob/main/DOCS.md"
|
|
39
39
|
|
|
40
40
|
[tool.maturin]
|
|
41
|
-
# Mixed layout: python/
|
|
41
|
+
# Mixed layout: python/nrumpy is bundled next to the compiled extension.
|
|
42
42
|
# The workspace root is a virtual manifest, so the crate is rumpy-core.
|
|
43
|
-
# Its #[pymodule] is rumpy_core
|
|
44
|
-
#
|
|
43
|
+
# Its #[pymodule] is rumpy_core, so the extension import is nrumpy.rumpy_core.
|
|
44
|
+
# extension-module builds a cdylib that does not link libpython; the
|
|
45
|
+
# interpreter provides those symbols at import time.
|
|
45
46
|
# "pypi" rejects platform tags that PyPI will not accept.
|
|
46
47
|
manifest-path = "rumpy-core/Cargo.toml"
|
|
47
48
|
python-source = "python"
|
|
48
|
-
module-name = "
|
|
49
|
+
module-name = "nrumpy.rumpy_core"
|
|
49
50
|
features = ["extension-module"]
|
|
50
51
|
bindings = "pyo3"
|
|
51
52
|
compatibility = "pypi"
|
|
@@ -7,10 +7,10 @@ Importing this package does not import that extension.
|
|
|
7
7
|
operand returns an array. A list left operand returns a list.
|
|
8
8
|
|
|
9
9
|
Examples:
|
|
10
|
-
>>> import
|
|
11
|
-
>>> callable(
|
|
10
|
+
>>> import nrumpy
|
|
11
|
+
>>> callable(nrumpy.matmul)
|
|
12
12
|
True
|
|
13
|
-
>>> isinstance(
|
|
13
|
+
>>> isinstance(nrumpy.__version__, str)
|
|
14
14
|
True
|
|
15
15
|
"""
|
|
16
16
|
|
|
@@ -18,8 +18,8 @@ from typing import TypeAlias, Union
|
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
|
|
21
|
-
from
|
|
22
|
-
from
|
|
21
|
+
from nrumpy.core import matmul, matmul_into
|
|
22
|
+
from nrumpy.errors import (
|
|
23
23
|
CoreError,
|
|
24
24
|
DimensionMismatchError,
|
|
25
25
|
InvalidInputError,
|
|
@@ -40,4 +40,4 @@ __all__ = [
|
|
|
40
40
|
"matmul_into",
|
|
41
41
|
]
|
|
42
42
|
|
|
43
|
-
__version__ = "0.
|
|
43
|
+
__version__ = "0.2.0"
|
|
@@ -14,7 +14,7 @@ list when the left operand is a list.
|
|
|
14
14
|
__version__: str
|
|
15
15
|
|
|
16
16
|
class RumpyError(Exception):
|
|
17
|
-
"""Base class for errors raised by
|
|
17
|
+
"""Base class for errors raised by nrumpy."""
|
|
18
18
|
|
|
19
19
|
class DimensionMismatchError(RumpyError):
|
|
20
20
|
"""The inner dimensions of the two operands disagree."""
|
|
@@ -10,7 +10,7 @@ from typing import TypeGuard
|
|
|
10
10
|
|
|
11
11
|
import numpy as np
|
|
12
12
|
|
|
13
|
-
from
|
|
13
|
+
from nrumpy.errors import InvalidInputError
|
|
14
14
|
|
|
15
15
|
# ``tolist()`` should yield a list, tuple, or ndarray. A small cap stops a
|
|
16
16
|
# converter that returns another converter from recursing forever.
|
|
@@ -35,7 +35,7 @@ def to_2d_list(obj: object) -> list[list[float]]:
|
|
|
35
35
|
contains a non-numeric element.
|
|
36
36
|
|
|
37
37
|
Examples:
|
|
38
|
-
>>> from
|
|
38
|
+
>>> from nrumpy._convert import to_2d_list
|
|
39
39
|
>>> to_2d_list(((1, 2), (3, 4)))
|
|
40
40
|
[[1.0, 2.0], [3.0, 4.0]]
|
|
41
41
|
"""
|
|
@@ -53,7 +53,7 @@ def shape_of(rows: list[list[float]]) -> tuple[int, int]:
|
|
|
53
53
|
``(row count, column count)``. An empty list returns ``(0, 0)``.
|
|
54
54
|
|
|
55
55
|
Examples:
|
|
56
|
-
>>> from
|
|
56
|
+
>>> from nrumpy._convert import shape_of
|
|
57
57
|
>>> shape_of([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
|
|
58
58
|
(2, 3)
|
|
59
59
|
"""
|
|
@@ -79,7 +79,7 @@ def from_2d_list(
|
|
|
79
79
|
|
|
80
80
|
Examples:
|
|
81
81
|
>>> import numpy as np
|
|
82
|
-
>>> from
|
|
82
|
+
>>> from nrumpy._convert import from_2d_list
|
|
83
83
|
>>> rows = [[1.0, 2.0], [3.0, 4.0]]
|
|
84
84
|
>>> from_2d_list(rows, like=np.zeros((2, 2))).shape
|
|
85
85
|
(2, 2)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""User-facing matrix product.
|
|
2
2
|
|
|
3
3
|
``matmul`` checks shapes in Python, then calls ``rumpy_core.matmul``.
|
|
4
|
-
The extension import is inside the call, so ``import
|
|
4
|
+
The extension import is inside the call, so ``import nrumpy`` succeeds before
|
|
5
5
|
the extension is built.
|
|
6
6
|
"""
|
|
7
7
|
|
|
@@ -11,8 +11,8 @@ import sys
|
|
|
11
11
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
|
|
14
|
-
from
|
|
15
|
-
from
|
|
14
|
+
from nrumpy._convert import from_2d_list, shape_of, to_2d_list
|
|
15
|
+
from nrumpy.errors import CoreError, DimensionMismatchError, InvalidInputError
|
|
16
16
|
|
|
17
17
|
__all__ = ["matmul", "matmul_into"]
|
|
18
18
|
|
|
@@ -55,7 +55,7 @@ def matmul(a, b, *, leaf_size: int = 64, out=None):
|
|
|
55
55
|
failures.
|
|
56
56
|
|
|
57
57
|
Examples:
|
|
58
|
-
>>> from
|
|
58
|
+
>>> from nrumpy import matmul
|
|
59
59
|
>>> matmul([[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]])
|
|
60
60
|
[[19.0, 22.0], [43.0, 50.0]]
|
|
61
61
|
"""
|
|
@@ -100,7 +100,7 @@ def matmul_into(a, b, out, leaf_size: int = 64):
|
|
|
100
100
|
|
|
101
101
|
Examples:
|
|
102
102
|
>>> import numpy as np
|
|
103
|
-
>>> from
|
|
103
|
+
>>> from nrumpy import matmul_into
|
|
104
104
|
>>> buffer = np.zeros((2, 2))
|
|
105
105
|
>>> matmul_into(
|
|
106
106
|
... [[1.0, 2.0], [3.0, 4.0]],
|
|
@@ -164,12 +164,12 @@ def _validate_out(out: object, shape: tuple[int, int]) -> None:
|
|
|
164
164
|
def _load_extension():
|
|
165
165
|
"""Import the compiled extension.
|
|
166
166
|
|
|
167
|
-
Maturin places the mixed-project module at ``
|
|
167
|
+
Maturin places the mixed-project module at ``nrumpy.rumpy_core``. A
|
|
168
168
|
top-level ``rumpy_core`` is the older layout. ``sys.modules`` is checked
|
|
169
169
|
first so a test can substitute either name.
|
|
170
170
|
"""
|
|
171
171
|
last_error: ImportError | None = None
|
|
172
|
-
for name in ("
|
|
172
|
+
for name in ("nrumpy.rumpy_core", "rumpy_core"):
|
|
173
173
|
cached = sys.modules.get(name)
|
|
174
174
|
if cached is not None:
|
|
175
175
|
return cached
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class RumpyError(Exception):
|
|
5
|
-
"""Base class for errors raised by
|
|
5
|
+
"""Base class for errors raised by nrumpy.
|
|
6
6
|
|
|
7
7
|
Examples:
|
|
8
|
-
>>> from
|
|
8
|
+
>>> from nrumpy import RumpyError
|
|
9
9
|
>>> issubclass(RumpyError, Exception)
|
|
10
10
|
True
|
|
11
11
|
"""
|
|
@@ -19,7 +19,7 @@ class DimensionMismatchError(RumpyError):
|
|
|
19
19
|
``shapes (2,3) and (4,5) not aligned: 3 (dim 1) != 4 (dim 0)``.
|
|
20
20
|
|
|
21
21
|
Examples:
|
|
22
|
-
>>> from
|
|
22
|
+
>>> from nrumpy import DimensionMismatchError, RumpyError
|
|
23
23
|
>>> issubclass(DimensionMismatchError, RumpyError)
|
|
24
24
|
True
|
|
25
25
|
"""
|
|
@@ -34,7 +34,7 @@ class InvalidInputError(RumpyError):
|
|
|
34
34
|
``ValueError``.
|
|
35
35
|
|
|
36
36
|
Examples:
|
|
37
|
-
>>> from
|
|
37
|
+
>>> from nrumpy import InvalidInputError, RumpyError
|
|
38
38
|
>>> issubclass(InvalidInputError, RumpyError)
|
|
39
39
|
True
|
|
40
40
|
"""
|
|
@@ -47,7 +47,7 @@ class CoreError(RumpyError):
|
|
|
47
47
|
exception with ``raise CoreError(str(exc)) from exc``.
|
|
48
48
|
|
|
49
49
|
Examples:
|
|
50
|
-
>>> from
|
|
50
|
+
>>> from nrumpy import CoreError, RumpyError
|
|
51
51
|
>>> issubclass(CoreError, RumpyError)
|
|
52
52
|
True
|
|
53
53
|
"""
|
|
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
|