interpn 0.2.0__tar.gz → 0.2.1__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.
Files changed (50) hide show
  1. {interpn-0.2.0 → interpn-0.2.1}/Cargo.lock +20 -12
  2. {interpn-0.2.0 → interpn-0.2.1}/Cargo.toml +2 -2
  3. {interpn-0.2.0 → interpn-0.2.1}/PKG-INFO +41 -7
  4. {interpn-0.2.0 → interpn-0.2.1}/README.md +40 -6
  5. interpn-0.2.1/docs/1d_quality_of_fit_Rectilinear.svg +5356 -0
  6. interpn-0.2.1/docs/1d_quality_of_fit_Regular.svg +4771 -0
  7. interpn-0.2.1/docs/2d_quality_of_fit_Rectilinear.svg +3435 -0
  8. interpn-0.2.1/docs/2d_quality_of_fit_Regular.svg +3458 -0
  9. interpn-0.2.0/docs/3d_no_prealloc.svg → interpn-0.2.1/docs/3d_throughput_vs_nobs.svg +367 -395
  10. interpn-0.2.1/docs/3d_throughput_vs_nobs_prealloc.svg +2754 -0
  11. interpn-0.2.0/docs/6d_no_prealloc.svg → interpn-0.2.1/docs/6d_throughput_vs_nobs.svg +457 -507
  12. interpn-0.2.1/docs/6d_throughput_vs_nobs_prealloc.svg +2740 -0
  13. interpn-0.2.1/docs/index.md +104 -0
  14. {interpn-0.2.0 → interpn-0.2.1}/docs/perf.md +9 -12
  15. interpn-0.2.0/docs/nd_memory.svg → interpn-0.2.1/docs/ram_vs_dims.svg +236 -185
  16. interpn-0.2.0/docs/nd_throughput_1000obs.svg → interpn-0.2.1/docs/throughput_vs_dims_1000_obs.svg +358 -307
  17. interpn-0.2.0/docs/nd_throughput_1obs.svg → interpn-0.2.1/docs/throughput_vs_dims_1_obs.svg +372 -307
  18. interpn-0.2.1/examples/cubic_comparison.py +120 -0
  19. {interpn-0.2.0 → interpn-0.2.1}/interpn/__init__.py +2 -0
  20. interpn-0.2.1/interpn/multicubic_rectilinear.py +221 -0
  21. {interpn-0.2.0 → interpn-0.2.1}/interpn/multicubic_regular.py +1 -1
  22. {interpn-0.2.0 → interpn-0.2.1}/interpn/multilinear_rectilinear.py +1 -1
  23. {interpn-0.2.0 → interpn-0.2.1}/interpn/raw.py +4 -0
  24. {interpn-0.2.0 → interpn-0.2.1}/pyproject.toml +1 -1
  25. {interpn-0.2.0 → interpn-0.2.1}/src/lib.rs +37 -0
  26. {interpn-0.2.0 → interpn-0.2.1}/test/bench_cpu.py +128 -51
  27. {interpn-0.2.0 → interpn-0.2.1}/test/bench_mem.py +35 -9
  28. interpn-0.2.1/test/test_multicubic_rectilinear.py +75 -0
  29. interpn-0.2.0/docs/1d_cubic_quality_of_fit.svg +0 -5004
  30. interpn-0.2.0/docs/2d_cubic_quality_of_fit.svg +0 -3538
  31. interpn-0.2.0/docs/3d_no_prealloc_cubic.svg +0 -1748
  32. interpn-0.2.0/docs/6d_no_prealloc_cubic.svg +0 -1797
  33. interpn-0.2.0/docs/index.md +0 -68
  34. interpn-0.2.0/examples/cubic_comparison.py +0 -94
  35. {interpn-0.2.0 → interpn-0.2.1}/.github/workflows/CI.yml +0 -0
  36. {interpn-0.2.0 → interpn-0.2.1}/.github/workflows/test.yml +0 -0
  37. {interpn-0.2.0 → interpn-0.2.1}/.gitignore +0 -0
  38. {interpn-0.2.0 → interpn-0.2.1}/.readthedocs.yml +0 -0
  39. {interpn-0.2.0 → interpn-0.2.1}/LICENSE-APACHE +0 -0
  40. {interpn-0.2.0 → interpn-0.2.1}/LICENSE-MIT +0 -0
  41. {interpn-0.2.0 → interpn-0.2.1}/docs/API_Docs.md +0 -0
  42. {interpn-0.2.0 → interpn-0.2.1}/docs/requirements.txt +0 -0
  43. {interpn-0.2.0 → interpn-0.2.1}/interpn/multilinear_regular.py +0 -0
  44. {interpn-0.2.0 → interpn-0.2.1}/interpn/py.typed +0 -0
  45. {interpn-0.2.0 → interpn-0.2.1}/interpn/serialization.py +0 -0
  46. {interpn-0.2.0 → interpn-0.2.1}/mkdocs.yml +0 -0
  47. {interpn-0.2.0 → interpn-0.2.1}/test/test_docs.py +0 -0
  48. {interpn-0.2.0 → interpn-0.2.1}/test/test_multicubic_regular.py +0 -0
  49. {interpn-0.2.0 → interpn-0.2.1}/test/test_multilinear_rectilinear.py +0 -0
  50. {interpn-0.2.0 → interpn-0.2.1}/test/test_multilinear_regular.py +0 -0
@@ -43,9 +43,9 @@ checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
43
43
 
44
44
  [[package]]
45
45
  name = "interpn"
46
- version = "0.4.1"
46
+ version = "0.4.2"
47
47
  source = "registry+https://github.com/rust-lang/crates.io-index"
48
- checksum = "82ec859d62d17054a7314d5bb47d7e4eeb4648b87b7c1e0e33de1d4df21e0375"
48
+ checksum = "f37cc48f61030a3bed5eb01e583af8ae1248f3e3bf63d05d87a18f27a98a426b"
49
49
  dependencies = [
50
50
  "num-traits",
51
51
  ]
@@ -177,6 +177,12 @@ dependencies = [
177
177
  "windows-targets",
178
178
  ]
179
179
 
180
+ [[package]]
181
+ name = "portable-atomic"
182
+ version = "1.6.0"
183
+ source = "registry+https://github.com/rust-lang/crates.io-index"
184
+ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
185
+
180
186
  [[package]]
181
187
  name = "proc-macro2"
182
188
  version = "1.0.69"
@@ -188,15 +194,16 @@ dependencies = [
188
194
 
189
195
  [[package]]
190
196
  name = "pyo3"
191
- version = "0.20.0"
197
+ version = "0.20.3"
192
198
  source = "registry+https://github.com/rust-lang/crates.io-index"
193
- checksum = "04e8453b658fe480c3e70c8ed4e3d3ec33eb74988bd186561b0cc66b85c3bc4b"
199
+ checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233"
194
200
  dependencies = [
195
201
  "cfg-if",
196
202
  "indoc",
197
203
  "libc",
198
204
  "memoffset",
199
205
  "parking_lot",
206
+ "portable-atomic",
200
207
  "pyo3-build-config",
201
208
  "pyo3-ffi",
202
209
  "pyo3-macros",
@@ -205,9 +212,9 @@ dependencies = [
205
212
 
206
213
  [[package]]
207
214
  name = "pyo3-build-config"
208
- version = "0.20.0"
215
+ version = "0.20.3"
209
216
  source = "registry+https://github.com/rust-lang/crates.io-index"
210
- checksum = "a96fe70b176a89cff78f2fa7b3c930081e163d5379b4dcdf993e3ae29ca662e5"
217
+ checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7"
211
218
  dependencies = [
212
219
  "once_cell",
213
220
  "target-lexicon",
@@ -215,9 +222,9 @@ dependencies = [
215
222
 
216
223
  [[package]]
217
224
  name = "pyo3-ffi"
218
- version = "0.20.0"
225
+ version = "0.20.3"
219
226
  source = "registry+https://github.com/rust-lang/crates.io-index"
220
- checksum = "214929900fd25e6604661ed9cf349727c8920d47deff196c4e28165a6ef2a96b"
227
+ checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa"
221
228
  dependencies = [
222
229
  "libc",
223
230
  "pyo3-build-config",
@@ -225,9 +232,9 @@ dependencies = [
225
232
 
226
233
  [[package]]
227
234
  name = "pyo3-macros"
228
- version = "0.20.0"
235
+ version = "0.20.3"
229
236
  source = "registry+https://github.com/rust-lang/crates.io-index"
230
- checksum = "dac53072f717aa1bfa4db832b39de8c875b7c7af4f4a6fe93cdbf9264cf8383b"
237
+ checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158"
231
238
  dependencies = [
232
239
  "proc-macro2",
233
240
  "pyo3-macros-backend",
@@ -237,12 +244,13 @@ dependencies = [
237
244
 
238
245
  [[package]]
239
246
  name = "pyo3-macros-backend"
240
- version = "0.20.0"
247
+ version = "0.20.3"
241
248
  source = "registry+https://github.com/rust-lang/crates.io-index"
242
- checksum = "7774b5a8282bd4f25f803b1f0d945120be959a36c72e08e7cd031c792fdfd424"
249
+ checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185"
243
250
  dependencies = [
244
251
  "heck",
245
252
  "proc-macro2",
253
+ "pyo3-build-config",
246
254
  "quote",
247
255
  "syn",
248
256
  ]
@@ -9,9 +9,9 @@ name = "_interpn"
9
9
  crate-type = ["cdylib"]
10
10
 
11
11
  [dependencies]
12
- pyo3 = "0.20.0"
12
+ pyo3 = "0.20.3"
13
13
  numpy = "0.20.0"
14
- interpn = {version = "0.4.1", default_features = false}
14
+ interpn = {version = "0.4.2", default_features = false}
15
15
  #interpn = { path = "../interpn/interpn" }
16
16
 
17
17
  [profile.release]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: interpn
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -42,7 +42,7 @@ Python bindings to the `interpn` Rust library for N-dimensional interpolation an
42
42
  | Feature →<br>↓ Interpolant Method | Regular<br>Grid | Rectilinear<br>Grid | Json<br>Serialization |
43
43
  |-----------------------------------|-----------------|---------------------|-----------------------|
44
44
  | Linear | ✅ | ✅ | ✅ |
45
- | Cubic | ✅ | 💡 | ✅ |
45
+ | Cubic | ✅ | | ✅ |
46
46
 
47
47
  The methods provided here, while more limited in scope than scipy's, are
48
48
  * significantly faster for higher dimensions (1-3 orders of magnitude under most conditions)
@@ -50,18 +50,54 @@ The methods provided here, while more limited in scope than scipy's, are
50
50
  * produce significantly improved floating-point error (by 1-2 orders of magnitude)
51
51
  * are json-serializable using Pydantic
52
52
  * can also be used easily in web and embedded applications via the Rust library
53
+ * are permissively licensed
54
+
55
+ ![ND throughput 1 obs](./docs/throughput_vs_dims_1_obs.svg)
53
56
 
54
57
  See [here](https://interpnpy.readthedocs.io/en/latest/perf/) for more info about quality-of-fit, throughput, and memory usage.
55
58
 
59
+ ## Installation
60
+
61
+ ```bash
62
+ pip install interpn
63
+ ```
64
+
65
+ ## Example: Available Methods
66
+
67
+ ```python
68
+ import interpn
69
+ import numpy as np
70
+
71
+ # Build grid
72
+ x = np.linspace(0.0, 10.0, 5)
73
+ y = np.linspace(20.0, 30.0, 4)
74
+ grids = [x, y]
75
+
76
+ xgrid, ygrid = np.meshgrid(x, y, indexing="ij")
77
+ zgrid = (xgrid + 2.0 * ygrid) # Values at grid points
78
+
79
+ # Grid inputs for true regular grid
80
+ dims = [x.size, y.size]
81
+ starts = np.array([x[0], y[0]])
82
+ steps = np.array([x[1] - x[0], y[1] - y[0]])
83
+
84
+ # Initialize different interpolators
85
+ # Call like `linear_regular.eval([xs, ys])`
86
+ linear_regular = interpn.MultilinearRegular.new(dims, starts, steps, zgrid)
87
+ cubic_regular = interpn.MulticubicRegular.new(dims, starts, steps, zgrid)
88
+ linear_rectilinear = interpn.MultilinearRectilinear.new(grids, zgrid)
89
+ cubic_rectilinear = interpn.MulticubicRectilinear.new(grids, zgrid)
90
+ ```
56
91
 
57
92
  ## Example: Multilinear Interpolation on a Regular Grid
93
+
58
94
  ```python
59
95
  import interpn
60
96
  import numpy as np
61
97
 
62
98
  # Build grid
63
99
  x = np.linspace(0.0, 10.0, 5)
64
- y = np.linspace(20.0, 30.0, 3)
100
+ y = np.linspace(20.0, 30.0, 4)
65
101
 
66
102
  xgrid, ygrid = np.meshgrid(x, y, indexing="ij")
67
103
  zgrid = (xgrid + 2.0 * ygrid) # Values at grid points
@@ -75,15 +111,13 @@ steps = np.array([x[1] - x[0], y[1] - y[0]])
75
111
  obs = [xgrid.flatten(), ygrid.flatten()]
76
112
 
77
113
  # Initialize
78
- interpolator = interpn.MultilinearRegular.new(
79
- dims, starts, steps, zgrid.flatten()
80
- )
114
+ interpolator = interpn.MultilinearRegular.new(dims, starts, steps, zgrid.flatten())
81
115
 
82
116
  # Interpolate
83
117
  out = interpolator.eval(obs)
84
118
 
85
119
  # Check result
86
- assert np.all(out == zgrid.flatten())
120
+ assert np.allclose(out, zgrid.flatten(), rtol=1e-13)
87
121
 
88
122
  # Serialize and deserialize
89
123
  roundtrip_interpolator = interpn.MultilinearRegular.model_validate_json(
@@ -11,7 +11,7 @@ Python bindings to the `interpn` Rust library for N-dimensional interpolation an
11
11
  | Feature →<br>↓ Interpolant Method | Regular<br>Grid | Rectilinear<br>Grid | Json<br>Serialization |
12
12
  |-----------------------------------|-----------------|---------------------|-----------------------|
13
13
  | Linear | ✅ | ✅ | ✅ |
14
- | Cubic | ✅ | 💡 | ✅ |
14
+ | Cubic | ✅ | | ✅ |
15
15
 
16
16
  The methods provided here, while more limited in scope than scipy's, are
17
17
  * significantly faster for higher dimensions (1-3 orders of magnitude under most conditions)
@@ -19,18 +19,54 @@ The methods provided here, while more limited in scope than scipy's, are
19
19
  * produce significantly improved floating-point error (by 1-2 orders of magnitude)
20
20
  * are json-serializable using Pydantic
21
21
  * can also be used easily in web and embedded applications via the Rust library
22
+ * are permissively licensed
23
+
24
+ ![ND throughput 1 obs](./docs/throughput_vs_dims_1_obs.svg)
22
25
 
23
26
  See [here](https://interpnpy.readthedocs.io/en/latest/perf/) for more info about quality-of-fit, throughput, and memory usage.
24
27
 
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install interpn
32
+ ```
33
+
34
+ ## Example: Available Methods
35
+
36
+ ```python
37
+ import interpn
38
+ import numpy as np
39
+
40
+ # Build grid
41
+ x = np.linspace(0.0, 10.0, 5)
42
+ y = np.linspace(20.0, 30.0, 4)
43
+ grids = [x, y]
44
+
45
+ xgrid, ygrid = np.meshgrid(x, y, indexing="ij")
46
+ zgrid = (xgrid + 2.0 * ygrid) # Values at grid points
47
+
48
+ # Grid inputs for true regular grid
49
+ dims = [x.size, y.size]
50
+ starts = np.array([x[0], y[0]])
51
+ steps = np.array([x[1] - x[0], y[1] - y[0]])
52
+
53
+ # Initialize different interpolators
54
+ # Call like `linear_regular.eval([xs, ys])`
55
+ linear_regular = interpn.MultilinearRegular.new(dims, starts, steps, zgrid)
56
+ cubic_regular = interpn.MulticubicRegular.new(dims, starts, steps, zgrid)
57
+ linear_rectilinear = interpn.MultilinearRectilinear.new(grids, zgrid)
58
+ cubic_rectilinear = interpn.MulticubicRectilinear.new(grids, zgrid)
59
+ ```
25
60
 
26
61
  ## Example: Multilinear Interpolation on a Regular Grid
62
+
27
63
  ```python
28
64
  import interpn
29
65
  import numpy as np
30
66
 
31
67
  # Build grid
32
68
  x = np.linspace(0.0, 10.0, 5)
33
- y = np.linspace(20.0, 30.0, 3)
69
+ y = np.linspace(20.0, 30.0, 4)
34
70
 
35
71
  xgrid, ygrid = np.meshgrid(x, y, indexing="ij")
36
72
  zgrid = (xgrid + 2.0 * ygrid) # Values at grid points
@@ -44,15 +80,13 @@ steps = np.array([x[1] - x[0], y[1] - y[0]])
44
80
  obs = [xgrid.flatten(), ygrid.flatten()]
45
81
 
46
82
  # Initialize
47
- interpolator = interpn.MultilinearRegular.new(
48
- dims, starts, steps, zgrid.flatten()
49
- )
83
+ interpolator = interpn.MultilinearRegular.new(dims, starts, steps, zgrid.flatten())
50
84
 
51
85
  # Interpolate
52
86
  out = interpolator.eval(obs)
53
87
 
54
88
  # Check result
55
- assert np.all(out == zgrid.flatten())
89
+ assert np.allclose(out, zgrid.flatten(), rtol=1e-13)
56
90
 
57
91
  # Serialize and deserialize
58
92
  roundtrip_interpolator = interpn.MultilinearRegular.model_validate_json(