From 5d76f62924b674a65cbe4483670f2b3ddfa0c86a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Jan 2024 09:19:59 +0100 Subject: interp:Interp2D_C: support arbitrarily shaped arrays --- interp.py | 13 ++++++++----- 1 file 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) -- cgit v1.2.3