Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 29, 2025
1 parent 2627ffc commit a33e674
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions virtualizarr/tests/test_readers/test_netcdf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@
import xarray.testing as xrt

from virtualizarr import open_virtual_dataset
from virtualizarr.manifests import ChunkManifest, ManifestArray
from virtualizarr.tests import requires_scipy
from virtualizarr.manifests import ManifestArray, ChunkManifest
from virtualizarr.zarr import ZArray


@requires_scipy
def test_read_netcdf3(netcdf3_file):
filepath = str(netcdf3_file)
vds = open_virtual_dataset(filepath)

assert isinstance(vds, xr.Dataset)
assert list(vds.variables.keys()) == ["foo"]
assert isinstance(vds["foo"].data, ManifestArray)

expected_manifest = ChunkManifest(
entries={"0": {"path": filepath, "offset": 80, "length": 12}}
)
expected_zarray = ZArray(dtype=np.dtype(">i4"), shape=(3,), chunks=(3,))
expected_ma = ManifestArray(chunkmanifest=expected_manifest, zarray=expected_zarray)
expected_vds = xr.Dataset(
{"foo": xr.Variable(data=expected_ma, dims=["x"])}
)
expected_vds = xr.Dataset({"foo": xr.Variable(data=expected_ma, dims=["x"])})

xrt.assert_identical(vds, expected_vds)
4 changes: 2 additions & 2 deletions virtualizarr/vendor/kerchunk/netCDF3.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from functools import reduce
from operator import mul

import fsspec
import numpy as np
from fsspec.implementations.reference import LazyReferenceMapper
import fsspec

from virtualizarr.vendor.kerchunk.utils import _encode_for_JSON, inline_array

try:
from scipy.io._netcdf import ZERO, NC_VARIABLE, netcdf_file, netcdf_variable
from scipy.io._netcdf import NC_VARIABLE, ZERO, netcdf_file, netcdf_variable
except ModuleNotFoundError: # pragma: no cover
raise ImportError(
"Scipy is required for kerchunking NetCDF3 files. Please install with "
Expand Down

0 comments on commit a33e674

Please sign in to comment.