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

Method test_rank

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

Source from the content-addressed store, hash-verified

6483
6484 @requires_bottleneck
6485 def test_rank(self) -> None:
6486 ds = create_test_data(seed=1234)
6487 # only ds.var3 depends on dim3
6488 z = ds.rank("dim3")
6489 assert ["var3"] == list(z.data_vars)
6490 # same as dataarray version
6491 x = z.var3
6492 y = ds.var3.rank("dim3")
6493 assert_equal(x, y)
6494 # coordinates stick
6495 assert list(z.coords) == list(ds.coords)
6496 assert list(x.coords) == list(y.coords)
6497 # invalid dim
6498 with pytest.raises(
6499 ValueError,
6500 match=re.escape(
6501 "Dimension 'invalid_dim' not found in data dimensions ('dim3', 'dim1')"
6502 ),
6503 ):
6504 x.rank("invalid_dim")
6505
6506 def test_rank_use_bottleneck(self) -> None:
6507 ds = Dataset({"a": ("x", [0, np.nan, 2]), "b": ("y", [4, 6, 3, 4])})

Callers

nothing calls this directly

Calls 3

create_test_dataFunction · 0.90
assert_equalFunction · 0.90
rankMethod · 0.45

Tested by

no test coverage detected