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

Method test_drop_labels_by_position

xarray/tests/test_dataset.py:3117–3143  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3115 data.drop(dim="x", x="a")
3116
3117 def test_drop_labels_by_position(self) -> None:
3118 data = Dataset(
3119 {"A": (["x", "y"], np.random.randn(2, 6)), "x": ["a", "b"], "y": range(6)}
3120 )
3121 # Basic functionality.
3122 assert len(data.coords["x"]) == 2
3123
3124 actual = data.drop_isel(x=0)
3125 expected = data.drop_sel(x="a")
3126 assert_identical(expected, actual)
3127
3128 actual = data.drop_isel(x=[0])
3129 expected = data.drop_sel(x=["a"])
3130 assert_identical(expected, actual)
3131
3132 actual = data.drop_isel(x=[0, 1])
3133 expected = data.drop_sel(x=["a", "b"])
3134 assert_identical(expected, actual)
3135 assert actual.coords["x"].size == 0
3136
3137 actual = data.drop_isel(x=[0, 1], y=range(0, 6, 2))
3138 expected = data.drop_sel(x=["a", "b"], y=range(0, 6, 2))
3139 assert_identical(expected, actual)
3140 assert actual.coords["x"].size == 0
3141
3142 with pytest.raises(KeyError):
3143 data.drop_isel(z=1)
3144
3145 def test_drop_indexes(self) -> None:
3146 ds = Dataset(

Callers

nothing calls this directly

Calls 4

drop_iselMethod · 0.95
drop_selMethod · 0.95
DatasetClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected