def test_interpolate(self): src = np.arange(10)[:, None] trg = np.linspace(0, 20, 40)[:, None] vals = np.hstack((np.sin(src), 10. + np.sin(src))) vals[3:5, 1] = np.nan ipol_result = ipol.interpolate(src, trg, vals, ipol.Idw, remove_missing=True, nnearest=2) np.testing.assert_allclose(ipol_result[3:5, 1], np.array([10.880571, 10.909297])) ipol_result = ipol.interpolate(src, trg, vals[:, 1], ipol.Idw, remove_missing=True, nnearest=2) np.testing.assert_allclose(ipol_result[3:5], np.array([10.880571, 10.909136])) vals = np.dstack((np.sin(src), 10. + np.sin(src))) vals[3:5, :, 1] = np.nan
def test_interpolate(self): src = np.arange(10)[:, None] trg = np.linspace(0, 20, 40)[:, None] vals = np.hstack((np.sin(src), 10. + np.sin(src))) vals[3:5, 1] = np.nan print(np.any(np.isnan(vals.ravel()))) ipol_result = ipol.interpolate(src, trg, vals, ipol.Idw, nnearest=2) np.testing.assert_allclose(ipol_result[3:5, 1], np.array([10.880571, 10.909137])) ipol_result = ipol.interpolate(src, trg, vals[:, 1], ipol.Idw, nnearest=2) np.testing.assert_allclose(ipol_result[3:5], np.array([10.880571, 10.909137])) vals = np.dstack((np.sin(src), 10. + np.sin(src))) vals[3:5, :, 1] = np.nan self.assertRaises( NotImplementedError, lambda: ipol.interpolate(src, trg, vals, ipol.Idw, nnearest=2))