Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
magland committed May 14, 2024
1 parent ce75b32 commit 5dbf83b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lindi/LindiH5ZarrStore/LindiH5ZarrStore.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import base64
from typing import Tuple, Union, List, IO, Any, Dict
from typing import Tuple, Union, List, IO, Any, Dict, Callable
import numpy as np
import zarr
from zarr.storage import Store, MemoryStore
Expand Down Expand Up @@ -429,10 +429,13 @@ def _add_chunk_info_to_refs(
self,
key_parent: str,
key_names: List[str],
add_ref: callable,
add_ref_chunk: callable
add_ref: Callable,
add_ref_chunk: Callable
):
if self._h5f is None:
raise Exception("Store is closed")
h5_item = self._h5f.get('/' + key_parent, None)
assert isinstance(h5_item, h5py.Dataset)

# For the case of a scalar dataset, we need to check a few things
if h5_item.ndim == 0:
Expand All @@ -449,7 +452,7 @@ def _add_chunk_info_to_refs(
if inline_array.is_inline:
if len(key_names) != 1 or key_names[0] != inline_array.chunk_fname:
raise Exception(
f"Chunk name {key_name[0]} does not match dataset dimensions for inline array {key_parent}"
f"Chunk name {key_names[0]} does not match dataset dimensions for inline array {key_parent}"
)
inline_data = inline_array.chunk_bytes
add_ref(f"{key_parent}/{key_names[0]}", inline_data)
Expand All @@ -470,6 +473,7 @@ def _add_chunk_info_to_refs(
leave=True,
delay=2 # do not show progress bar until 2 seconds have passed
):
chunk_coords = None # so that chunk_coords is not unbound on exception
try:
# TODO remove this code through the assert after verifying order of key_names
# Get the chunk coords from the file name
Expand Down
1 change: 1 addition & 0 deletions lindi/LindiH5ZarrStore/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def _get_chunk_index(h5_dataset: h5py.Dataset, chunk_coords: tuple) -> int:
chunk_index += int(chunk_coords[i] * np.prod(chunk_coords_shape[i + 1:]))
return chunk_index


def _get_chunk_byte_range(h5_dataset: h5py.Dataset, chunk_coords: tuple) -> tuple:
"""Get the byte range in the file for a chunk of an h5py dataset.
Expand Down

0 comments on commit 5dbf83b

Please sign in to comment.