summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-01-23 09:19:59 +0100
committerAnton Khirnov <anton@khirnov.net>2024-01-23 09:19:59 +0100
commit5d76f62924b674a65cbe4483670f2b3ddfa0c86a (patch)
tree567573cf782324d4c3c8eb44bfdfbd099f2b93c2
parent19b3a9b733e6b0636a3041d26a8cb9c03cb1103d (diff)
interp:Interp2D_C: support arbitrarily shaped arrays
-rw-r--r--interp.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/interp.py b/interp.py
index 778fc52..6ba20bc 100644
--- a/interp.py
+++ b/interp.py
@@ -130,16 +130,19 @@ class Interp2D_C:
except (AttributeError, IndexError):
y = np.array([y])
- if x.shape != self._x.shape:
- self._setup_arrays(x.shape)
+ x_interp = x.flatten()
+ y_interp = y.flatten()
- np.copyto(self._x, x)
- np.copyto(self._y, y)
+ if x_interp.shape != self._x.shape:
+ self._setup_arrays(x_interp.shape)
+
+ np.copyto(self._x, x_interp)
+ np.copyto(self._y, y_interp)
self._interp_func(self._src_start_c, self._src_step_c, self._src_val_c,
self._src_stride_c, self._src_len_c,
self._x.shape[0],
self._x_c, self._y_c, self._ret_c)
- return self._ret.copy()
+ return self._ret.copy().reshape(x.shape)
def __call__(self, x, y):
return self.interp(x, y)