MCPcopy Index your code
hub / github.com/pydata/xarray / test_interpolate_pd_compat_non_uniform_index

Function test_interpolate_pd_compat_non_uniform_index

xarray/tests/test_missing.py:156–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154
155@requires_scipy
156def test_interpolate_pd_compat_non_uniform_index():
157 shapes = [(8, 8), (1, 20), (20, 1), (100, 100)]
158 frac_nans = [0, 0.5, 1]
159 methods = ["time", "index", "values"]
160
161 for shape, frac_nan, method in itertools.product(shapes, frac_nans, methods):
162 da, df = make_interpolate_example_data(shape, frac_nan, non_uniform=True)
163 for dim in ["time", "x"]:
164 if method == "time" and dim != "time":
165 continue
166 actual = da.interpolate_na(
167 method="linear", dim=dim, use_coordinate=True, fill_value=np.nan
168 )
169 expected = df.interpolate(
170 method=method,
171 axis=da.get_axis_num(dim),
172 )
173
174 # Note, Pandas does some odd things with the left/right fill_value
175 # for the linear methods. This next line inforces the xarray
176 # fill_value convention on the pandas output. Therefore, this test
177 # only checks that interpolated values are the same (not nans)
178 expected_values = expected.values.copy()
179 expected_values[pd.isnull(actual.values)] = np.nan
180
181 np.testing.assert_allclose(actual.values, expected_values)
182
183
184@requires_scipy

Callers

nothing calls this directly

Calls 6

interpolateMethod · 0.80
interpolate_naMethod · 0.45
get_axis_numMethod · 0.45
copyMethod · 0.45
isnullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…