diff --git a/utils/exclude_path_keywords.yaml b/utils/exclude_path_keywords.yaml index 58f72ec..8ce57b0 100644 --- a/utils/exclude_path_keywords.yaml +++ b/utils/exclude_path_keywords.yaml @@ -3,4 +3,5 @@ exclude_paths: - .ipynb_checkpoints - .renku - .git -# - params \ No newline at end of file + # - params + - .Trash \ No newline at end of file diff --git a/utils/g5505_utils.py b/utils/g5505_utils.py index 32b849b..7eaf45b 100644 --- a/utils/g5505_utils.py +++ b/utils/g5505_utils.py @@ -237,21 +237,27 @@ def convert_attrdict_to_np_structured_array(attr_value: dict): Returns ------- - new_attr_value : ndarray or str - Numpy structured array with UTF-8 encoded fields. Returns 'missing' if + new_attr_value : ndarray + Numpy structured array with UTF-8 encoded fields. Returns np.array(['missing'], dtype=[str]) if the input dictionary is empty. """ + if not isinstance(attr_value,dict): + raise ValueError(f'Input paremeter {attr_value} must be a dictionary of scalar values.') + dtype = [] values_list = [] max_length = max(len(str(attr_value[key])) for key in attr_value.keys()) - for key in attr_value.keys(): - if key != 'rename_as': + for key, val in attr_value.items(): + # Verify if 'rename_as' is still used in metadata revision + if key != 'rename_as' and isinstance(val, (int, float, str)): dtype.append((key, f'S{max_length}')) values_list.append(attr_value[key]) + else: + print(f"Skipping unsupported type for key {key}: {type(val)}") if values_list: new_attr_value = np.array([tuple(values_list)], dtype=dtype) else: - new_attr_value = 'missing' + new_attr_value = np.array(['missing'], dtype=[str]) return new_attr_value