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

Method test_reindex_method

xarray/tests/test_dataarray.py:1861–1875  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1859 assert x.dtype == re_dtype
1860
1861 def test_reindex_method(self) -> None:
1862 x = DataArray([10, 20], dims="y", coords={"y": [0, 1]})
1863 y = [-0.1, 0.5, 1.1]
1864 actual = x.reindex(y=y, method="backfill", tolerance=0.2)
1865 expected = DataArray([10, np.nan, np.nan], coords=[("y", y)])
1866 assert_identical(expected, actual)
1867
1868 actual = x.reindex(y=y, method="backfill", tolerance=[0.1, 0.1, 0.01])
1869 expected = DataArray([10, np.nan, np.nan], coords=[("y", y)])
1870 assert_identical(expected, actual)
1871
1872 alt = Dataset({"y": y})
1873 actual = x.reindex_like(alt, method="backfill")
1874 expected = DataArray([10, 20, np.nan], coords=[("y", y)])
1875 assert_identical(expected, actual)
1876
1877 @pytest.mark.parametrize("fill_value", [dtypes.NA, 2, 2.0, {None: 2, "u": 1}])
1878 def test_reindex_fill_value(self, fill_value) -> None:

Callers

nothing calls this directly

Calls 5

reindexMethod · 0.95
reindex_likeMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90
DatasetClass · 0.90

Tested by

no test coverage detected