|
1 | | -import pytest |
2 | 1 | import xarray as xr |
3 | 2 | import xarray.testing as xrt |
4 | 3 |
|
5 | 4 | from virtualizarr import open_virtual_dataset |
6 | | -from virtualizarr.manifests import ChunkManifest, ManifestArray |
7 | 5 | from virtualizarr.parsers import NetCDF3Parser |
8 | | -from virtualizarr.tests import requires_network, requires_scipy |
| 6 | +from virtualizarr.tests import requires_kerchunk, requires_network, requires_scipy |
9 | 7 | from virtualizarr.tests.utils import obstore_http, obstore_local |
10 | 8 |
|
11 | 9 |
|
12 | 10 | @requires_scipy |
13 | | -@pytest.mark.xfail( |
14 | | - reason="Big endian not yet supported by zarr-python 3.0" |
15 | | -) # https://github.com/zarr-developers/zarr-python/issues/2324 |
16 | 11 | def test_read_netcdf3(netcdf3_file, array_v3_metadata): |
17 | 12 | filepath = str(netcdf3_file) |
18 | 13 | store = obstore_local(file_url=filepath) |
19 | 14 | parser = NetCDF3Parser() |
20 | | - with open_virtual_dataset( |
21 | | - file_url=filepath, |
22 | | - parser=parser, |
23 | | - object_store=store, |
24 | | - ) as vds: |
25 | | - assert isinstance(vds, xr.Dataset) |
26 | | - assert list(vds.variables.keys()) == ["foo"] |
27 | | - assert isinstance(vds["foo"].data, ManifestArray) |
28 | | - |
29 | | - expected_manifest = ChunkManifest( |
30 | | - entries={"0": {"path": filepath, "offset": 80, "length": 12}} |
| 15 | + with ( |
| 16 | + parser(file_url=filepath, object_store=store) as manifest_store, |
| 17 | + xr.open_dataset(filepath) as expected, |
| 18 | + ): |
| 19 | + observed = xr.open_dataset( |
| 20 | + manifest_store, engine="zarr", consolidated=False, zarr_format=3 |
31 | 21 | ) |
32 | | - metadata = array_v3_metadata(shape=(3,), chunks=(3,)) |
33 | | - expected_ma = ManifestArray(chunkmanifest=expected_manifest, metadata=metadata) |
34 | | - expected_vds = xr.Dataset({"foo": xr.Variable(data=expected_ma, dims=["x"])}) |
35 | | - |
36 | | - xrt.assert_identical(vds, expected_vds) |
| 22 | + assert isinstance(observed, xr.Dataset) |
| 23 | + assert list(observed.variables.keys()) == ["foo"] |
| 24 | + xrt.assert_identical(observed.load(), expected.load()) |
37 | 25 |
|
38 | 26 |
|
| 27 | +@requires_kerchunk |
39 | 28 | @requires_network |
40 | | -@pytest.mark.xfail( |
41 | | - reason="Big endian not yet supported by zarr-python 3.0" |
42 | | -) # https://github.com/zarr-developers/zarr-python/issues/2324 |
43 | 29 | def test_read_http_netcdf3(array_v3_metadata): |
44 | 30 | file_url = "https://github.com/pydata/xarray-data/raw/master/air_temperature.nc" |
45 | 31 | store = obstore_http(file_url=file_url) |
|
0 commit comments