EconForge / interpolation.py

BSD 2-Clause "Simplified" License
123 stars 35 forks source link

Linear interpolation fails on ints #49

Closed jstac closed 5 years ago

jstac commented 5 years ago

Hi @albop, catching any trout recently?

The following gives me Exception: Undetected evaluation type. But it works fine if 5 is replaced with 5.0. Please let me know if you have issues reproducing.

from interpolation import interp
a = np.linspace(0, 10, 10)
b = 2 * a
interp(a, b, 5)
albop commented 5 years ago

@jstac Nope, no trout. Not even a rainbow one. But I did catch some cod up north... As for the bug, it's easy to fix, it comes frome the way type dispatch is done. The types we are currently using for dispatch are arrays of floats, arrays of ints, tuples, and float. I don't think there is any problem in replacing the latter by scalar=float or int. This is fixed in pr #50, now in master. Can you try it ?

jstac commented 5 years ago

Just tested and it works perfectly at my end. Thanks!