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

Method test_default_indexes

xarray/tests/test_backends_api.py:292–307  ·  view source on GitHub ↗

Create default indexes if the backend does not create them.

(self, create_default_indexes)

Source from the content-addressed store, hash-verified

290
291 @pytest.mark.parametrize("create_default_indexes", [True, False])
292 def test_default_indexes(self, create_default_indexes):
293 """Create default indexes if the backend does not create them."""
294 coords = xr.Coordinates({"x": ("x", [0, 1]), "y": list("abc")}, indexes={})
295 initial = xr.Dataset({"a": ("x", [1, 2])}, coords=coords)
296
297 with assert_no_warnings():
298 final = xr.open_dataset(
299 initial,
300 engine=PassThroughBackendEntrypoint,
301 create_default_indexes=create_default_indexes,
302 )
303
304 if create_default_indexes:
305 assert all(name in final.xindexes for name in ["x", "y"])
306 else:
307 assert len(final.xindexes) == 0
308
309 @pytest.mark.parametrize("create_default_indexes", [True, False])
310 def test_default_indexes_passthrough(self, create_default_indexes):

Callers

nothing calls this directly

Calls 2

assert_no_warningsFunction · 0.90
open_datasetMethod · 0.45

Tested by

no test coverage detected