interpn 0.1.5__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.
- {interpn-0.1.5 → interpn-0.2.0}/.github/workflows/test.yml +4 -2
- {interpn-0.1.5 → interpn-0.2.0}/Cargo.lock +2 -18
- {interpn-0.1.5 → interpn-0.2.0}/Cargo.toml +3 -2
- interpn-0.2.0/PKG-INFO +105 -0
- interpn-0.2.0/README.md +74 -0
- interpn-0.2.0/docs/1d_cubic_quality_of_fit.svg +5004 -0
- interpn-0.2.0/docs/2d_cubic_quality_of_fit.svg +3538 -0
- interpn-0.2.0/docs/3d_no_prealloc.svg +2710 -0
- interpn-0.1.5/docs/3d_no_prealloc.svg → interpn-0.2.0/docs/3d_no_prealloc_cubic.svg +330 -515
- interpn-0.2.0/docs/6d_no_prealloc.svg +2718 -0
- interpn-0.1.5/docs/8d_no_prealloc.svg → interpn-0.2.0/docs/6d_no_prealloc_cubic.svg +331 -422
- {interpn-0.1.5 → interpn-0.2.0}/docs/index.md +20 -4
- interpn-0.2.0/docs/nd_memory.svg +1985 -0
- interpn-0.2.0/docs/nd_throughput_1000obs.svg +2566 -0
- interpn-0.2.0/docs/nd_throughput_1obs.svg +2414 -0
- interpn-0.2.0/docs/perf.md +64 -0
- interpn-0.2.0/examples/cubic_comparison.py +94 -0
- {interpn-0.1.5 → interpn-0.2.0}/interpn/__init__.py +2 -0
- interpn-0.2.0/interpn/multicubic_regular.py +232 -0
- {interpn-0.1.5 → interpn-0.2.0}/interpn/multilinear_rectilinear.py +4 -4
- {interpn-0.1.5 → interpn-0.2.0}/interpn/multilinear_regular.py +4 -4
- {interpn-0.1.5 → interpn-0.2.0}/interpn/raw.py +12 -8
- {interpn-0.1.5 → interpn-0.2.0}/mkdocs.yml +10 -1
- {interpn-0.1.5 → interpn-0.2.0}/pyproject.toml +6 -3
- {interpn-0.1.5 → interpn-0.2.0}/src/lib.rs +67 -16
- interpn-0.2.0/test/bench_cpu.py +537 -0
- interpn-0.2.0/test/bench_mem.py +118 -0
- interpn-0.2.0/test/test_docs.py +7 -0
- interpn-0.2.0/test/test_multicubic_regular.py +90 -0
- {interpn-0.1.5 → interpn-0.2.0}/test/test_multilinear_rectilinear.py +2 -2
- {interpn-0.1.5 → interpn-0.2.0}/test/test_multilinear_regular.py +2 -2
- interpn-0.1.5/PKG-INFO +0 -42
- interpn-0.1.5/README.md +0 -14
- interpn-0.1.5/docs/perf.md +0 -28
- interpn-0.1.5/test/bench.py +0 -359
- interpn-0.1.5/test/test_docs.py +0 -7
- {interpn-0.1.5 → interpn-0.2.0}/.github/workflows/CI.yml +0 -0
- {interpn-0.1.5 → interpn-0.2.0}/.gitignore +0 -0
- {interpn-0.1.5 → interpn-0.2.0}/.readthedocs.yml +0 -0
- {interpn-0.1.5 → interpn-0.2.0}/LICENSE-APACHE +0 -0
- {interpn-0.1.5 → interpn-0.2.0}/LICENSE-MIT +0 -0
- {interpn-0.1.5 → interpn-0.2.0}/docs/API_Docs.md +0 -0
- {interpn-0.1.5 → interpn-0.2.0}/docs/requirements.txt +0 -0
- {interpn-0.1.5 → interpn-0.2.0}/interpn/py.typed +0 -0
- {interpn-0.1.5 → interpn-0.2.0}/interpn/serialization.py +0 -0
|
@@ -4,7 +4,7 @@ on:
|
|
|
4
4
|
branches: [ "*" ]
|
|
5
5
|
workflow_dispatch:
|
|
6
6
|
workflow_call:
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
jobs:
|
|
9
9
|
test:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
@@ -35,4 +35,6 @@ jobs:
|
|
|
35
35
|
- name: Static typing - python
|
|
36
36
|
run: source ../env/bin/activate; pyright ./interpn
|
|
37
37
|
- name: Test - python
|
|
38
|
-
run:
|
|
38
|
+
run: |
|
|
39
|
+
source ../env/bin/activate; pytest .
|
|
40
|
+
python ./examples/cubic_comparison.py test
|
|
@@ -29,12 +29,6 @@ version = "1.0.0"
|
|
|
29
29
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
30
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
31
31
|
|
|
32
|
-
[[package]]
|
|
33
|
-
name = "either"
|
|
34
|
-
version = "1.9.0"
|
|
35
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
-
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
|
37
|
-
|
|
38
32
|
[[package]]
|
|
39
33
|
name = "heck"
|
|
40
34
|
version = "0.4.1"
|
|
@@ -49,23 +43,13 @@ checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
|
|
|
49
43
|
|
|
50
44
|
[[package]]
|
|
51
45
|
name = "interpn"
|
|
52
|
-
version = "0.
|
|
46
|
+
version = "0.4.1"
|
|
53
47
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
54
|
-
checksum = "
|
|
48
|
+
checksum = "82ec859d62d17054a7314d5bb47d7e4eeb4648b87b7c1e0e33de1d4df21e0375"
|
|
55
49
|
dependencies = [
|
|
56
|
-
"itertools",
|
|
57
50
|
"num-traits",
|
|
58
51
|
]
|
|
59
52
|
|
|
60
|
-
[[package]]
|
|
61
|
-
name = "itertools"
|
|
62
|
-
version = "0.12.0"
|
|
63
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
-
checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0"
|
|
65
|
-
dependencies = [
|
|
66
|
-
"either",
|
|
67
|
-
]
|
|
68
|
-
|
|
69
53
|
[[package]]
|
|
70
54
|
name = "libc"
|
|
71
55
|
version = "0.2.150"
|
|
@@ -11,14 +11,15 @@ crate-type = ["cdylib"]
|
|
|
11
11
|
[dependencies]
|
|
12
12
|
pyo3 = "0.20.0"
|
|
13
13
|
numpy = "0.20.0"
|
|
14
|
-
interpn = "0.
|
|
15
|
-
#
|
|
14
|
+
interpn = {version = "0.4.1", default_features = false}
|
|
15
|
+
#interpn = { path = "../interpn/interpn" }
|
|
16
16
|
|
|
17
17
|
[profile.release]
|
|
18
18
|
opt-level = 3
|
|
19
19
|
codegen-units = 1
|
|
20
20
|
lto = true
|
|
21
21
|
strip = true
|
|
22
|
+
overflow-checks = true
|
|
22
23
|
|
|
23
24
|
[profile.dev]
|
|
24
25
|
opt-level = 3
|
interpn-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: interpn
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
Requires-Dist: numpy >=1
|
|
8
|
+
Requires-Dist: pydantic >=2.5.2
|
|
9
|
+
Requires-Dist: pytest >=7.4.3 ; extra == 'test'
|
|
10
|
+
Requires-Dist: coverage >=7.3.2 ; extra == 'test'
|
|
11
|
+
Requires-Dist: ruff >=0.1.6 ; extra == 'test'
|
|
12
|
+
Requires-Dist: pyright >=1.1.337 ; extra == 'test'
|
|
13
|
+
Requires-Dist: mktestdocs >=0.2.1 ; extra == 'test'
|
|
14
|
+
Requires-Dist: scipy >=1.11.4 ; extra == 'test'
|
|
15
|
+
Requires-Dist: matplotlib >=3.8 ; extra == 'test'
|
|
16
|
+
Requires-Dist: scipy >=1.11.4 ; extra == 'bench'
|
|
17
|
+
Requires-Dist: matplotlib >=3.8 ; extra == 'bench'
|
|
18
|
+
Requires-Dist: memory-profiler >=0.61.0 ; extra == 'bench'
|
|
19
|
+
Requires-Dist: mkdocs >=1.5.3 ; extra == 'doc'
|
|
20
|
+
Requires-Dist: mkdocstrings-python >=1.7.5 ; extra == 'doc'
|
|
21
|
+
Requires-Dist: mkdocs-material >=9.4.10 ; extra == 'doc'
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Provides-Extra: bench
|
|
24
|
+
Provides-Extra: doc
|
|
25
|
+
License-File: LICENSE-APACHE
|
|
26
|
+
License-File: LICENSE-MIT
|
|
27
|
+
Summary: N-dimensional interpolation/extrapolation methods
|
|
28
|
+
Author-email: jlogan03@gmail.com
|
|
29
|
+
Requires-Python: >=3.9, <3.12
|
|
30
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
31
|
+
|
|
32
|
+
# interpn
|
|
33
|
+
|
|
34
|
+
Python bindings to the `interpn` Rust library for N-dimensional interpolation and extrapolation.
|
|
35
|
+
|
|
36
|
+
[Docs](https://interpnpy.readthedocs.io/en/latest/) |
|
|
37
|
+
[Repo](https://github.com/jlogan03/interpnpy) |
|
|
38
|
+
[Rust Library (github)](https://github.com/jlogan03/interpn) |
|
|
39
|
+
[Rust Docs (docs.rs)](https://docs.rs/interpn/latest/interpn/)
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
| Feature →<br>↓ Interpolant Method | Regular<br>Grid | Rectilinear<br>Grid | Json<br>Serialization |
|
|
43
|
+
|-----------------------------------|-----------------|---------------------|-----------------------|
|
|
44
|
+
| Linear | ✅ | ✅ | ✅ |
|
|
45
|
+
| Cubic | ✅ | 💡 | ✅ |
|
|
46
|
+
|
|
47
|
+
The methods provided here, while more limited in scope than scipy's, are
|
|
48
|
+
* significantly faster for higher dimensions (1-3 orders of magnitude under most conditions)
|
|
49
|
+
* use almost no RAM (and perform no heap allocations at all)
|
|
50
|
+
* produce significantly improved floating-point error (by 1-2 orders of magnitude)
|
|
51
|
+
* are json-serializable using Pydantic
|
|
52
|
+
* can also be used easily in web and embedded applications via the Rust library
|
|
53
|
+
|
|
54
|
+
See [here](https://interpnpy.readthedocs.io/en/latest/perf/) for more info about quality-of-fit, throughput, and memory usage.
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Example: Multilinear Interpolation on a Regular Grid
|
|
58
|
+
```python
|
|
59
|
+
import interpn
|
|
60
|
+
import numpy as np
|
|
61
|
+
|
|
62
|
+
# Build grid
|
|
63
|
+
x = np.linspace(0.0, 10.0, 5)
|
|
64
|
+
y = np.linspace(20.0, 30.0, 3)
|
|
65
|
+
|
|
66
|
+
xgrid, ygrid = np.meshgrid(x, y, indexing="ij")
|
|
67
|
+
zgrid = (xgrid + 2.0 * ygrid) # Values at grid points
|
|
68
|
+
|
|
69
|
+
# Grid inputs for true regular grid
|
|
70
|
+
dims = [x.size, y.size]
|
|
71
|
+
starts = np.array([x[0], y[0]])
|
|
72
|
+
steps = np.array([x[1] - x[0], y[1] - y[0]])
|
|
73
|
+
|
|
74
|
+
# Observation points pointed back at the grid
|
|
75
|
+
obs = [xgrid.flatten(), ygrid.flatten()]
|
|
76
|
+
|
|
77
|
+
# Initialize
|
|
78
|
+
interpolator = interpn.MultilinearRegular.new(
|
|
79
|
+
dims, starts, steps, zgrid.flatten()
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Interpolate
|
|
83
|
+
out = interpolator.eval(obs)
|
|
84
|
+
|
|
85
|
+
# Check result
|
|
86
|
+
assert np.all(out == zgrid.flatten())
|
|
87
|
+
|
|
88
|
+
# Serialize and deserialize
|
|
89
|
+
roundtrip_interpolator = interpn.MultilinearRegular.model_validate_json(
|
|
90
|
+
interpolator.model_dump_json()
|
|
91
|
+
)
|
|
92
|
+
out2 = roundtrip_interpolator.eval(obs)
|
|
93
|
+
|
|
94
|
+
# Check result from roundtrip serialized/deserialized interpolator
|
|
95
|
+
assert np.all(out == out2)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# License
|
|
100
|
+
Licensed under either of
|
|
101
|
+
|
|
102
|
+
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
103
|
+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
|
104
|
+
|
|
105
|
+
at your option.
|
interpn-0.2.0/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# interpn
|
|
2
|
+
|
|
3
|
+
Python bindings to the `interpn` Rust library for N-dimensional interpolation and extrapolation.
|
|
4
|
+
|
|
5
|
+
[Docs](https://interpnpy.readthedocs.io/en/latest/) |
|
|
6
|
+
[Repo](https://github.com/jlogan03/interpnpy) |
|
|
7
|
+
[Rust Library (github)](https://github.com/jlogan03/interpn) |
|
|
8
|
+
[Rust Docs (docs.rs)](https://docs.rs/interpn/latest/interpn/)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
| Feature →<br>↓ Interpolant Method | Regular<br>Grid | Rectilinear<br>Grid | Json<br>Serialization |
|
|
12
|
+
|-----------------------------------|-----------------|---------------------|-----------------------|
|
|
13
|
+
| Linear | ✅ | ✅ | ✅ |
|
|
14
|
+
| Cubic | ✅ | 💡 | ✅ |
|
|
15
|
+
|
|
16
|
+
The methods provided here, while more limited in scope than scipy's, are
|
|
17
|
+
* significantly faster for higher dimensions (1-3 orders of magnitude under most conditions)
|
|
18
|
+
* use almost no RAM (and perform no heap allocations at all)
|
|
19
|
+
* produce significantly improved floating-point error (by 1-2 orders of magnitude)
|
|
20
|
+
* are json-serializable using Pydantic
|
|
21
|
+
* can also be used easily in web and embedded applications via the Rust library
|
|
22
|
+
|
|
23
|
+
See [here](https://interpnpy.readthedocs.io/en/latest/perf/) for more info about quality-of-fit, throughput, and memory usage.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Example: Multilinear Interpolation on a Regular Grid
|
|
27
|
+
```python
|
|
28
|
+
import interpn
|
|
29
|
+
import numpy as np
|
|
30
|
+
|
|
31
|
+
# Build grid
|
|
32
|
+
x = np.linspace(0.0, 10.0, 5)
|
|
33
|
+
y = np.linspace(20.0, 30.0, 3)
|
|
34
|
+
|
|
35
|
+
xgrid, ygrid = np.meshgrid(x, y, indexing="ij")
|
|
36
|
+
zgrid = (xgrid + 2.0 * ygrid) # Values at grid points
|
|
37
|
+
|
|
38
|
+
# Grid inputs for true regular grid
|
|
39
|
+
dims = [x.size, y.size]
|
|
40
|
+
starts = np.array([x[0], y[0]])
|
|
41
|
+
steps = np.array([x[1] - x[0], y[1] - y[0]])
|
|
42
|
+
|
|
43
|
+
# Observation points pointed back at the grid
|
|
44
|
+
obs = [xgrid.flatten(), ygrid.flatten()]
|
|
45
|
+
|
|
46
|
+
# Initialize
|
|
47
|
+
interpolator = interpn.MultilinearRegular.new(
|
|
48
|
+
dims, starts, steps, zgrid.flatten()
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Interpolate
|
|
52
|
+
out = interpolator.eval(obs)
|
|
53
|
+
|
|
54
|
+
# Check result
|
|
55
|
+
assert np.all(out == zgrid.flatten())
|
|
56
|
+
|
|
57
|
+
# Serialize and deserialize
|
|
58
|
+
roundtrip_interpolator = interpn.MultilinearRegular.model_validate_json(
|
|
59
|
+
interpolator.model_dump_json()
|
|
60
|
+
)
|
|
61
|
+
out2 = roundtrip_interpolator.eval(obs)
|
|
62
|
+
|
|
63
|
+
# Check result from roundtrip serialized/deserialized interpolator
|
|
64
|
+
assert np.all(out == out2)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# License
|
|
69
|
+
Licensed under either of
|
|
70
|
+
|
|
71
|
+
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
72
|
+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
|
73
|
+
|
|
74
|
+
at your option.
|