Skip to content
Snippets Groups Projects

Improved the handling of numpy scalars in cfoods.h5.h5_attr_to_property

Merged Alexander Kreft requested to merge improving-h5-scalar-attribute-handling into dev
1 file
+ 6
6
Compare changes
  • Side-by-side
  • Inline
@@ -85,13 +85,13 @@ def h5_attr_to_property(val):
if isinstance(val, np.ndarray):
if val.ndim > 1:
return None, None
if val.ndim == 0:
raise NotImplementedError(
"Code assumes that scalar values "
"will not be given as np.ndarray objects")
val = list(val)
# The tolist method is on both numpy.ndarray and numpy.generic
# and properly converts scalars (including 0-dimensional
# numpy.ndarray) to Python scalars and 1D arrays to lists of
# Python scalars.
if val.ndim != 0:
dtype = db.LIST(dtype)
val = val.tolist()
# TODO this can eventually be removed
Loading