Skip to content

Commit

Permalink
Merge pull request #95 from NeurodataWithoutBorders/no-write-complex
Browse files Browse the repository at this point in the history
Do not allow writing of complex datasets
  • Loading branch information
magland authored Sep 17, 2024
2 parents 66c36d5 + a2e0af2 commit 6aa7cbb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lindi/conversion/create_zarr_dataset_from_h5_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def create_zarr_dataset_from_h5_data(
if zarr_compressor != 'default' and zarr_compressor is not None:
raise Exception('zarr_compressor is not supported for scalar datasets')

if np.issubdtype(h5_dtype, np.complexfloating):
raise Exception(f'Complex scalar datasets are not supported: dataset {label} with dtype {h5_dtype}')

if _is_numeric_dtype(h5_dtype) or h5_dtype in [bool, np.bool_]:
# Handle the simple numeric types
ds = zarr_parent_group.create_dataset(
Expand Down Expand Up @@ -110,6 +113,9 @@ def create_zarr_dataset_from_h5_data(
# If we have a list, then we need to convert it to an array
h5_data = np.array(h5_data)

if np.issubdtype(h5_dtype, np.complexfloating):
raise Exception(f'Complex datasets are not supported: dataset {label} with dtype {h5_dtype}')

if _is_numeric_dtype(h5_dtype) or h5_dtype in [bool, np.bool_]: # integer, unsigned integer, float, bool
# This is the normal case of a chunked dataset with a numeric (or boolean) dtype
if h5_chunks is None:
Expand Down

0 comments on commit 6aa7cbb

Please sign in to comment.