Skip to content

Commit

Permalink
mypy fix to use ChunkKey and empty dimensions list.
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkinsspatial committed Apr 22, 2024
1 parent 4c5f9bd commit 1dd3370
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions virtualizarr/readers/hdf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Mapping, Optional
from typing import List, Mapping, Optional, Union

import fsspec
import h5py
Expand All @@ -8,6 +8,8 @@
from virtualizarr.manifests import ChunkEntry, ChunkManifest, ManifestArray
from virtualizarr.zarr import ZArray

from virtualizarr.types import ChunkKey


def _dataset_chunk_manifest(path: str, dataset: h5py.Dataset) -> ChunkManifest:
"""
Expand Down Expand Up @@ -38,7 +40,8 @@ def _dataset_chunk_manifest(path: str, dataset: h5py.Dataset) -> ChunkManifest:
offset=dsid.get_offset(),
length=dsid.get_storage_size()
)
chunk_entries = {key: chunk_entry}
chunk_key = ChunkKey(key)
chunk_entries = {chunk_key: chunk_entry}
chunk_manifest = ChunkManifest(
entries=chunk_entries
)
Expand Down Expand Up @@ -75,7 +78,7 @@ def store_chunk_entry(blob):
return chunk_manifest


def _dataset_dims(dataset: h5py.Dataset) -> List[str]:
def _dataset_dims(dataset: h5py.Dataset) -> Union[List[str], List[None]]:
"""
Get a list of dimension scale names attached to input HDF5 dataset.
Expand Down Expand Up @@ -114,7 +117,7 @@ def _dataset_dims(dataset: h5py.Dataset) -> List[str]:
# In this case, we mimic netCDF4 and assign phony dimension names.
# See https://github.com/fsspec/kerchunk/issues/41
dims.append(f"phony_dim_{n}")
return dims
return dims


def _extract_attrs(dataset: h5py.Dataset):
Expand Down

0 comments on commit 1dd3370

Please sign in to comment.