def test_interp1_editable_module(dtype, device, method): dtype_device_kwargs = {"dtype": dtype, "device": device} x = torch.tensor([0.0, 0.2, 0.3, 0.5, 0.8, 1.0], **dtype_device_kwargs).requires_grad_() y = torch.tensor([[1.0, 1.5, 2.1, 1.1, 2.3, 2.5], [0.8, 1.2, 2.2, 0.4, 3.2, 1.2]], **dtype_device_kwargs).requires_grad_() xq = torch.linspace(0, 1, 10, **dtype_device_kwargs).requires_grad_() cls1 = Interp1D(x, y, method=method) cls2 = Interp1D(x, method=method) with warnings.catch_warnings(): warnings.simplefilter("error") cls1.assertparams(cls1.__call__, xq) cls2.assertparams(cls2.__call__, xq, y)
def interp(x, y, xq, extrap): return Interp1D(x, y, extrap=extrap, method="cspline", bc_type="natural")(xq)
def interp(x, y, xq): return Interp1D(x, y, method="cspline", bc_type=bc_type)(xq)
def interp(x, y, xq): return Interp1D(x, y, method="linear")(xq)
def interp(x, y, xq): return Interp1D(x, y, method="cspline", bc_type=bc_type, extrap="mirror")(xq)