Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError for RegularGridInterpolator with big-endian data #3703

Closed
cdeil opened this issue Jun 3, 2014 · 3 comments · Fixed by #3707
Closed

TypeError for RegularGridInterpolator with big-endian data #3703

cdeil opened this issue Jun 3, 2014 · 3 comments · Fixed by #3707
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.interpolate
Milestone

Comments

@cdeil
Copy link
Contributor

cdeil commented Jun 3, 2014

I ran into this TypeError with the RegularGridInterpolator for some big-endian data:

>>> import numpy as np
>>> from scipy import interpolate
>>> 
>>> values = np.ones((10, 20 , 30), dtype='>f4')
>>> points = map(np.arange, values.shape)
>>> xi = [(1, 1, 1)]
>>> interpolator = interpolate.RegularGridInterpolator(points, values)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 1495, in __init__
    raise ValueError("fill_value must be either 'None' or "
ValueError: fill_value must be either 'None' or of a type compatible with values
>>> interpolator = interpolate.RegularGridInterpolator(points, values, fill_value=0.)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 1495, in __init__
    raise ValueError("fill_value must be either 'None' or "
ValueError: fill_value must be either 'None' or of a type compatible with values

I think this is a small bug because the Python float 0. should be compatible with a dtype of >f4, no?

cc @andreas-h @pv

@cdeil
Copy link
Contributor Author

cdeil commented Jun 3, 2014

Also it took me a few minutes to figure out what to pass for points ... I guess using "pixel coordinates" is a very common use case and this could be shown in an example?

points = map(np.arange, values.shape)

Am I correct that there is no 3-dim spline interpolation available in scipy?

@andreas-h
Copy link
Contributor

thanks for reporting, christoph!

@pv I'm by no means a dtype expert ... can you give me a hint how to tackle this?

@pv
Copy link
Member

pv commented Jun 3, 2014

Maybe can_cast(..., casting='same_kind'). This may be need to be
guarded with Numpy version checks, as the kwarg is added only in Numpy
1.6 (i.e. don't make any checks at all for Numpy < 1.6). The intent is
just to catch early errors due to assigning floats to integers or
complexes to floats.

Do version check by adding a global variable NUMPY_LT_160 = NumpyVersion(np.__version__) < '1.6.0' (needs to be global as
NumpyVersion is a slow operation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants