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

Method test_sel

xarray/tests/test_indexes.py:488–510  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

486 assert actual[k].dtype == index.level_coords_dtype[k]
487
488 def test_sel(self) -> None:
489 index = PandasMultiIndex(
490 pd.MultiIndex.from_product([["a", "b"], [1, 2]], names=("one", "two")), "x"
491 )
492
493 # test tuples inside slice are considered as scalar indexer values
494 actual = index.sel({"x": slice(("a", 1), ("b", 2))})
495 expected_dim_indexers = {"x": slice(0, 4)}
496 assert actual.dim_indexers == expected_dim_indexers
497
498 with pytest.raises(KeyError, match=r"not all values found"):
499 index.sel({"x": [0]})
500 with pytest.raises(KeyError):
501 index.sel({"x": 0})
502 with pytest.raises(ValueError, match=r"cannot provide labels for both.*"):
503 index.sel({"one": 0, "x": "a"})
504 with pytest.raises(
505 ValueError,
506 match=r"multi-index level names \('three',\) not found in indexes",
507 ):
508 index.sel({"x": {"three": 0}})
509 with pytest.raises(IndexError):
510 index.sel({"x": (slice(None), 1, "no_level")})
511
512 def test_join(self):
513 midx = pd.MultiIndex.from_product([["a", "aa"], [1, 2]], names=("one", "two"))

Callers

nothing calls this directly

Calls 2

selMethod · 0.95
PandasMultiIndexClass · 0.90

Tested by

no test coverage detected