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

Method test_index_repr

xarray/tests/test_formatting.py:234–251  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

232 assert "\t" not in tabs
233
234 def test_index_repr(self) -> None:
235 coord_names = ("x", "y")
236 index = CustomIndex(coord_names)
237 names = ("x",)
238
239 normal = formatting.summarize_index(names, index, col_width=20)
240 assert names[0] in normal
241 assert len(normal.splitlines()) == len(names)
242 assert "CustomIndex" in normal
243
244 class IndexWithInlineRepr(CustomIndex):
245 def _repr_inline_(self, max_width: int):
246 return f"CustomIndex[{', '.join(self.names)}]"
247
248 index = IndexWithInlineRepr(coord_names)
249 inline = formatting.summarize_index(names, index, col_width=20)
250 assert names[0] in inline
251 assert index._repr_inline_(max_width=40) in inline
252
253 @pytest.mark.parametrize(
254 "names",

Callers

nothing calls this directly

Calls 3

_repr_inline_Method · 0.95
IndexWithInlineReprClass · 0.85
CustomIndexClass · 0.70

Tested by

no test coverage detected