()
| 154 | |
| 155 | @requires_scipy |
| 156 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…