MCPcopy
hub / github.com/pydata/xarray / test_sel_method

Method test_sel_method

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

Source from the content-addressed store, hash-verified

1234 assert_identical(array[1], array.sel(x_meta=0.2))
1235
1236 def test_sel_method(self) -> None:
1237 data = DataArray(np.random.randn(3, 4), [("x", [0, 1, 2]), ("y", list("abcd"))])
1238
1239 with pytest.raises(KeyError, match="Try setting the `method`"):
1240 data.sel(y="ab")
1241
1242 expected = data.sel(y=["a", "b"])
1243 actual = data.sel(y=["ab", "ba"], method="pad")
1244 assert_identical(expected, actual)
1245
1246 expected = data.sel(x=[1, 2])
1247 actual = data.sel(x=[0.9, 1.9], method="backfill", tolerance=1)
1248 assert_identical(expected, actual)
1249
1250 def test_sel_drop(self) -> None:
1251 data = DataArray([1, 2, 3], [("x", [0, 1, 2])])

Callers

nothing calls this directly

Calls 3

selMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected