question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: RBFInterpolator fails when calling it with a slice of a (1, n) array

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
rgommerscommented, Jan 1, 2022

Fixed by gh-15322, which will be released in 1.8.0.

1reaction
treverhinescommented, Aug 6, 2021

This issue is resolved when building with the latest version of pythran (since this commit https://github.com/serge-sans-paille/pythran/commit/3f9090067179e00b1923ae57deadb6cfbf21b1d3).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing needs & infrastructure for Pythran extensions #14544
see BUG: RBFInterpolator fails when calling it with a slice of a (1, n) array #14420 for a relevant bug report for non-contiguous...
Read more >
memory - Python MemoryError in Scipy Radial Basis Function ...
Your dataset should be fine: the error appears because you don't have enough RAM to store the result of the subtraction.
Read more >
SciPy 1.9.0 Release Notes — SciPy v1.9.3 Manual
Object arrays in sparse matrices now raise an error. Inexact indices into sparse matrices now raise an error. Passing radius=None to scipy.spatial.
Read more >
SciPy: doc/release/1.8.0-notes.rst - Fossies
#14420: BUG: RBFInterpolator fails when calling it with a slice of a... #14425: Running tests in parallel is not any faster than without...
Read more >
Mailman 3 ANN: SciPy 1.8.0 - NumPy-Discussion - python.org
`#14217 https://github.com/scipy/scipy/issues/14217`__: Error in documentation for ... BUG: RBFInterpolator fails when calling it with a slice of a.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found