Corrected parsing problem from hdf5 to yaml attribute. Single element arrays are now represented as a scalar as opposed to a list with a single element.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user