scipy: BUG: RBFInterpolator fails when calling it with a slice of a (1, n) array
RBFInterpolator has a bug where it throws an error when calling it with a slice of a (1, n) array. The below code reproduces the error:
import numpy as np
from scipy.interpolate import RBFInterpolator
y = np.random.random((3, 2))
d = np.random.random((3,))
x = np.random.random((1, 3))[:, :2]
RBFInterpolator(y, d)(x)
which throws this error:
Traceback (most recent call last):
File "rbfinterp_bug.py", line 7, in <module>
RBFInterpolator(y, d)(x)
File "/home/hinest/miniconda3/lib/python3.8/site-packages/scipy/interpolate/_rbfinterp.py", line 416, in __call__
out = _evaluate(
TypeError: Invalid call to pythranized function `_evaluate(float64[:, :] (reshaped), float64[:, :], str, float, int64[:, :], float64[:], float64[:], float64[:, :] (reshaped))'
Candidates are:
- _evaluate(float[:,:], float[:,:], str, float, int[:,:], float[:], float[:], float[:,:])
The issue is that x
has shape (1, 2) and stride (24, 8), which allows it to pass through x = np.asarray(x, dtype=float, order="C")
at this line of RBFInterpolator.__call__
because it still is C-contiguous, but pythran throws an error saying that x
is reshaped. @serge-sans-paille is this the expected behavior for pythran? If so, is there a better way to sanitize the input for pythranized functions than np.asarray
with order
specified?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (15 by maintainers)
Fixed by gh-15322, which will be released in
1.8.0
.This issue is resolved when building with the latest version of pythran (since this commit https://github.com/serge-sans-paille/pythran/commit/3f9090067179e00b1923ae57deadb6cfbf21b1d3).