sisl / GridInterpolations.jl

Multidimensional grid interpolation in arbitrary dimensions
Other
52 stars 12 forks source link

handling of NaNs in interpolants() #24

Closed mattuntergassmair closed 4 years ago

mattuntergassmair commented 4 years ago

What is the expected / desired behavior for the last line in this snippet?

using GridInterpolations
r = GridInterpolations.RectangleGrid(1:4, 1:4)
interpolants(r, [2.5, 3.5])  # business as usual
interpolants(r, [2.5, NaN])  # expected behavior?

The output is ([-2, -1, 2, 3], [NaN, NaN, NaN, NaN]). While NaN weights seem to make sense, the indices seem kind of dangerous (imagine someone is just checking for the support, not the actual weights).

What would be a sane behavior? Maybe ([0], [NaN]) or ([NaN],[NaN])? Or just checking for NaNs at the beginning of the call? Throwing an error?

@MaximeBouton

MaximeBouton commented 4 years ago

The interpolants method should probably check that there is no NaN in the input, and throw an error otherwise.