MCPcopy Create free account
hub / github.com/pydata/xarray / test_create_default_indexes

Method test_create_default_indexes

xarray/tests/test_backends.py:2244–2261  ·  view source on GitHub ↗
(self, tmp_path, create_default_indexes)

Source from the content-addressed store, hash-verified

2242
2243 @pytest.mark.parametrize("create_default_indexes", [True, False])
2244 def test_create_default_indexes(self, tmp_path, create_default_indexes) -> None:
2245 store_path = tmp_path / "tmp.nc"
2246 original_ds = xr.Dataset(
2247 {"data": ("x", np.arange(3))}, coords={"x": [-1, 0, 1]}
2248 )
2249 original_ds.to_netcdf(store_path, engine=self.engine, mode="w")
2250
2251 with open_dataset(
2252 store_path,
2253 engine=self.engine,
2254 create_default_indexes=create_default_indexes,
2255 ) as loaded_ds:
2256 if create_default_indexes:
2257 assert list(loaded_ds.xindexes) == ["x"] and isinstance(
2258 loaded_ds.xindexes["x"], PandasIndex
2259 )
2260 else:
2261 assert len(loaded_ds.xindexes) == 0
2262
2263 @requires_dask
2264 def test_encoding_masked_arrays(self, tmp_path) -> None:

Callers

nothing calls this directly

Calls 3

to_netcdfMethod · 0.95
open_datasetFunction · 0.90
arangeMethod · 0.80

Tested by

no test coverage detected