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

Method test_reindex_fill_value

xarray/tests/test_dataarray.py:1878–1896  ·  view source on GitHub ↗
(self, fill_value)

Source from the content-addressed store, hash-verified

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:
1879 x = DataArray([10, 20], dims="y", coords={"y": [0, 1], "u": ("y", [1, 2])})
1880 y = [0, 1, 2]
1881 if fill_value == dtypes.NA:
1882 # if we supply the default, we expect the missing value for a
1883 # float array
1884 fill_value_var = fill_value_u = np.nan
1885 elif isinstance(fill_value, dict):
1886 fill_value_var = fill_value[None]
1887 fill_value_u = fill_value["u"]
1888 else:
1889 fill_value_var = fill_value_u = fill_value
1890 actual = x.reindex(y=y, fill_value=fill_value)
1891 expected = DataArray(
1892 [10, 20, fill_value_var],
1893 dims="y",
1894 coords={"y": y, "u": ("y", [1, 2, fill_value_u])},
1895 )
1896 assert_identical(expected, actual)
1897
1898 @pytest.mark.parametrize("dtype", [str, bytes])
1899 def test_reindex_str_dtype(self, dtype) -> None:

Callers

nothing calls this directly

Calls 3

reindexMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected