Skip to content

Commit

Permalink
Merge pull request #18 from NeurodataWithoutBorders/boolean-type
Browse files Browse the repository at this point in the history
handle boolean type for arrays
  • Loading branch information
magland authored Mar 18, 2024
2 parents 77f4fc6 + edd7b92 commit 8a6ef32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lindi/LindiH5Store/_zarr_info_for_h5_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def _zarr_info_for_h5_dataset(h5_dataset: h5py.Dataset) -> ZarrInfoForH5Dataset:
raise Exception(f'Cannot handle scalar dataset {h5_dataset.name} with dtype {dtype}')
else:
# not a scalar dataset
if dtype.kind in ['i', 'u', 'f']: # integer, unsigned integer, float
# This is the normal case of a chunked dataset with a numeric dtype
if dtype.kind in ['i', 'u', 'f', 'b']: # integer, unsigned integer, float, boolean
# This is the normal case of a chunked dataset with a numeric (or boolean) dtype
filters = _h5_filters_to_codecs(h5_dataset)
chunks = h5_dataset.chunks
if chunks is None:
Expand Down
7 changes: 4 additions & 3 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ def test_scalar_datasets():


def test_numpy_arrays():
X1 = ("1", np.arange(60).reshape(3, 20), (3, 7))
X2 = ("2", np.arange(60).reshape(3, 20), None)
for label, array, chunks in [X1, X2]:
array_1 = ("1", np.arange(60).reshape(3, 20), (3, 7))
array_2 = ("2", np.arange(60).reshape(3, 20), None)
array_boolean = ("3", np.array([[True, False, True], [False, True, False]]), None)
for label, array, chunks in [array_1, array_2, array_boolean]:
print(f"Testing numpy array {label}")
with tempfile.TemporaryDirectory() as tmpdir:
filename = f"{tmpdir}/test.h5"
Expand Down

0 comments on commit 8a6ef32

Please sign in to comment.