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

Example mlinterp not working #51

Closed
dangom opened this issue Jul 31, 2019 · 1 comment
Closed

Example mlinterp not working #51

dangom opened this issue Jul 31, 2019 · 1 comment

Comments

@dangom
Copy link

dangom commented Jul 31, 2019

I tried to evaluate the example code:

from interpolation import mlinterp

x1 = np.linspace(0,1,100)**2 # non-uniform points for first dimensoin
x2 = (0,1,100) # uniform points for second dimension
grid = (x1,x2)
y = np.array([[np.sqrt(u1**2 + u2**2) for u2 in x2] for u1 in x1])


points = np.random.random((1000,2))

# vectorized call:
mlinterp(grid, y, points)

# non-vectorized call (note third argument must be a tuple of floats of right size)
mlinterp(grid, y, (0.4, 0.2))

But that gives:

TypeError                          Traceback (most recent call last)
<ipython-input-41-1cbb81f46b37> in <module>
     10 
     11 # vectorized call:
---> 12 mlinterp(grid, y, points)
     13 
     14 # non-vectorized call (note third argument must be a tuple of floats of right size)

TypeError: fmap() takes 0 positional arguments but 3 were given

Is the issue only at my end?

Installed interpolation with conda, as suggested in the README.
Python 3.7.3
MacOS 10.13.6

@albop
Copy link
Member

albop commented Aug 6, 2019

Hey @dangom. It is the example code which is wrong (I'm fixing it). Everything is based on type dispatch so the specification of the grid must respect the type. In particular, floats and ints are two different types.
So it should be x2 = (0.0,1.0,100) instead of x2 = (0,1,100).

@albop albop closed this as completed Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants