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

Method test_drop_duplicates_1d

xarray/tests/test_dataset.py:8284–8315  ·  view source on GitHub ↗
(self, keep)

Source from the content-addressed store, hash-verified

8282class TestDropDuplicates:
8283 @pytest.mark.parametrize("keep", ["first", "last", False])
8284 def test_drop_duplicates_1d(self, keep) -> None:
8285 ds = xr.Dataset(
8286 {"a": ("time", [0, 5, 6, 7]), "b": ("time", [9, 3, 8, 2])},
8287 coords={"time": [0, 0, 1, 2]},
8288 )
8289
8290 if keep == "first":
8291 a = [0, 6, 7]
8292 b = [9, 8, 2]
8293 time = [0, 1, 2]
8294 elif keep == "last":
8295 a = [5, 6, 7]
8296 b = [3, 8, 2]
8297 time = [0, 1, 2]
8298 else:
8299 a = [6, 7]
8300 b = [8, 2]
8301 time = [1, 2]
8302
8303 expected = xr.Dataset(
8304 {"a": ("time", a), "b": ("time", b)}, coords={"time": time}
8305 )
8306 result = ds.drop_duplicates("time", keep=keep)
8307 assert_equal(expected, result)
8308
8309 with pytest.raises(
8310 ValueError,
8311 match=re.escape(
8312 "Dimensions ('space',) not found in data dimensions ('time',)"
8313 ),
8314 ):
8315 ds.drop_duplicates("space", keep=keep)
8316
8317
8318class TestNumpyCoercion:

Callers

nothing calls this directly

Calls 2

drop_duplicatesMethod · 0.95
assert_equalFunction · 0.90

Tested by

no test coverage detected