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

Method test_set_xindex_options

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

Source from the content-addressed store, hash-verified

4066 assert_identical(result_custom, expected)
4067
4068 def test_set_xindex_options(self) -> None:
4069 ds = Dataset(coords={"foo": ("x", ["a", "a", "b", "b"])})
4070
4071 class IndexWithOptions(Index):
4072 def __init__(self, opt):
4073 self.opt = opt
4074
4075 @classmethod
4076 def from_variables(cls, variables, options):
4077 return cls(options["opt"])
4078
4079 indexed = ds.set_xindex("foo", IndexWithOptions, opt=1)
4080 assert indexed.xindexes["foo"].opt == 1 # type: ignore[attr-defined]
4081
4082 def test_stack(self) -> None:
4083 ds = Dataset(

Callers

nothing calls this directly

Calls 2

set_xindexMethod · 0.95
DatasetClass · 0.90

Tested by

no test coverage detected