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

Improve docs and add test case for RegularGridInterpolator #22138

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jax/_src/third_party/scipy/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class RegularGridInterpolator:
values: N-dimensional array specifying the grid values.
method: interpolation method, either ``"linear"`` or ``"nearest"``.
bounds_error: not implemented by JAX
fill_value: value returned for points outside the grid, defaults to NaN.
fill_value: value returned for points outside the grid. If None, values outside the
grid are extrapolated. Defaults to NaN.

Returns:
interpolator: callable interpolation object.
Expand Down
4 changes: 2 additions & 2 deletions tests/scipy_interpolate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class LaxBackedScipyInterpolateTests(jtu.JaxTestCase):
@jtu.sample_product(
spaces=(((0., 10., 10),), ((-15., 20., 12), (3., 4., 24))),
method=("linear", "nearest"),
fill_value=(np.nan, None),
)
def testRegularGridInterpolator(self, spaces, method):
def testRegularGridInterpolator(self, spaces, method, fill_value):
rng = jtu.rand_default(self.rng())
scipy_fun = lambda init_args, call_args: sp_interp.RegularGridInterpolator(
*init_args[:2], method, False, *init_args[2:])(*call_args)
Expand All @@ -44,7 +45,6 @@ def testRegularGridInterpolator(self, spaces, method):
def args_maker():
points = tuple(map(lambda x: np.linspace(*x), spaces))
values = rng(reduce(operator.add, tuple(map(np.shape, points))), float)
fill_value = np.nan

init_args = (points, values, fill_value)
n_validation_points = 50
Expand Down