From 337923039421b54abe736939c9a8dfad26df4b67 Mon Sep 17 00:00:00 2001 From: Pete Bunting Date: Wed, 19 Jun 2024 18:31:18 +0100 Subject: [PATCH] Updated rsgislib.zonalstats hdf5 functions to check whether input h5_files are lists --- python/rsgislib/zonalstats/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/python/rsgislib/zonalstats/__init__.py b/python/rsgislib/zonalstats/__init__.py index 29e32705..fdd8dd43 100644 --- a/python/rsgislib/zonalstats/__init__.py +++ b/python/rsgislib/zonalstats/__init__.py @@ -1620,6 +1620,9 @@ def merge_extracted_hdf5_data( """ import h5py + if not isinstance(h5_files, list): + raise rsgislib.RSGISPyException("h5_files must be a list.") + if len(h5_files) == 0: raise rsgislib.RSGISPyException("The list of input files is empty.") @@ -1695,6 +1698,9 @@ def merge_extracted_hdf5_vars_data( """ import h5py + if not isinstance(h5_files, list): + raise rsgislib.RSGISPyException("h5_files must be a list.") + if len(h5_files) == 0: raise rsgislib.RSGISPyException("The list of input files is empty.") @@ -2126,6 +2132,9 @@ def merge_extracted_hdf5_chip_data( if datatype is None: datatype = rsgislib.TYPE_32FLOAT + if not isinstance(h5_files, list): + raise rsgislib.RSGISPyException("h5_files must be a list.") + first = True n_feats = 0 chip_size = 0 @@ -2605,6 +2614,9 @@ def merge_extracted_hdf5_chip_ref_data( if datatype is None: datatype = rsgislib.TYPE_32FLOAT + if not isinstance(h5_files, list): + raise rsgislib.RSGISPyException("h5_files must be a list.") + first = True n_feats = 0 chip_size = 0 @@ -2836,6 +2848,9 @@ def get_var_from_hdf5_data(h5_files: List[str], var_idx: int = 0) -> numpy.array """ import h5py + if not isinstance(h5_files, list): + raise rsgislib.RSGISPyException("h5_files must be a list.") + if var_idx < 0: raise rsgislib.RSGISPyException("The variable index must be greater than 0.") @@ -2878,6 +2893,9 @@ def get_hdf5_data(h5_files: List[str]) -> numpy.array: """ import h5py + if not isinstance(h5_files, list): + raise rsgislib.RSGISPyException("h5_files must be a list.") + num_vals = 0 n_vars = 0 first = True