From dcb3dafff051519a2c6eaecd2c705b8aedd0ef32 Mon Sep 17 00:00:00 2001 From: Jeremy Magland Date: Wed, 11 Sep 2024 09:36:06 -0400 Subject: [PATCH] Do not allow writing of complex datasets --- lindi/conversion/create_zarr_dataset_from_h5_data.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lindi/conversion/create_zarr_dataset_from_h5_data.py b/lindi/conversion/create_zarr_dataset_from_h5_data.py index 851897a..0d0b500 100644 --- a/lindi/conversion/create_zarr_dataset_from_h5_data.py +++ b/lindi/conversion/create_zarr_dataset_from_h5_data.py @@ -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( @@ -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: