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

Function test_scipy_entrypoint

xarray/tests/test_backends.py:7477–7507  ·  view source on GitHub ↗
(tmp_path: Path)

Source from the content-addressed store, hash-verified

7475
7476@requires_scipy
7477def test_scipy_entrypoint(tmp_path: Path) -> None:
7478 entrypoint = ScipyBackendEntrypoint()
7479 ds = create_test_data()
7480
7481 path = tmp_path / "foo"
7482 ds.to_netcdf(path, engine="scipy")
7483 _check_guess_can_open_and_open(entrypoint, path, engine="scipy", expected=ds)
7484 _check_guess_can_open_and_open(entrypoint, str(path), engine="scipy", expected=ds)
7485 with open(path, "rb") as f:
7486 _check_guess_can_open_and_open(entrypoint, f, engine="scipy", expected=ds)
7487
7488 contents = ds.to_netcdf(engine="scipy")
7489 _check_guess_can_open_and_open(entrypoint, contents, engine="scipy", expected=ds)
7490 _check_guess_can_open_and_open(
7491 entrypoint, BytesIO(contents), engine="scipy", expected=ds
7492 )
7493
7494 path = tmp_path / "foo.nc.gz"
7495 with gzip.open(path, mode="wb") as f:
7496 f.write(contents)
7497 _check_guess_can_open_and_open(entrypoint, path, engine="scipy", expected=ds)
7498 _check_guess_can_open_and_open(entrypoint, str(path), engine="scipy", expected=ds)
7499
7500 assert entrypoint.guess_can_open("something-local.nc")
7501 assert entrypoint.guess_can_open("something-local.nc.gz")
7502 assert not entrypoint.guess_can_open("not-found-and-no-extension")
7503 assert not entrypoint.guess_can_open(b"not-a-netcdf-file")
7504 # Should not claim .gz files that aren't netCDF
7505 assert not entrypoint.guess_can_open("something.zarr.gz")
7506 assert not entrypoint.guess_can_open("something.tar.gz")
7507 assert not entrypoint.guess_can_open("something.txt.gz")
7508
7509
7510@requires_h5netcdf

Callers

nothing calls this directly

Calls 6

guess_can_openMethod · 0.95
create_test_dataFunction · 0.85
to_netcdfMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…