diff --git a/src/hdf5_vis.py b/src/hdf5_vis.py index 1fa6ab5..b5c8dc3 100644 --- a/src/hdf5_vis.py +++ b/src/hdf5_vis.py @@ -75,19 +75,13 @@ def make_dtype_yaml_compatible(value): print('Yaml-compatible data-type was not found. Value has been set to Nan.') value = np.nan elif isinstance(value, np.ndarray): - if np.issubdtype(value.dtype, np.string_): - value = value.astype(str).tolist() - elif np.issubdtype(value.dtype, np.integer): - value = value.astype(int).tolist() + if np.issubdtype(value.dtype, np.string_) or np.issubdtype(value.dtype, np.generic): + value = [str(item) for item in value] if len(value)>1 else str(value[0]) # value.astype(str).tolist() + elif np.issubdtype(value.dtype, np.integer) : + value = [int(item) for item in value] if len(value)>1 else int(value[0]) # value.astype(int).tolist() elif np.issubdtype(value.dtype, np.floating): - value = value.astype(float).tolist() - elif np.issubdtype(value.dtype, np.generic): - value = value.astype(str).tolist() - #elif isinstance(value,(int,float,str)): - - #print('Yaml-compatible data-type was not found. Value has been set to Nan.') - #value = np.nan - #print('leave value as is') + value = [float(item) for item in value] if len(value)>1 else float(value[0]) # value.astype(float).tolist() + except: print('Yaml-compatible data-type was not found. Value has been set to Nan.') value = np.nan