Skip to content
Snippets Groups Projects
Commit 94ae2395 authored by Freja Nordsiek's avatar Freja Nordsiek
Browse files

Improved the handling of numpy scalars (whether bare or 0-dimensional...

Improved the handling of numpy scalars (whether bare or 0-dimensional ndarrays) in cfoods.h5.h5_attr_to_property.
parent 336275fd
No related branches found
No related tags found
2 merge requests!22Release 0.3,!18Improved the handling of numpy scalars in cfoods.h5.h5_attr_to_property
...@@ -85,13 +85,13 @@ def h5_attr_to_property(val): ...@@ -85,13 +85,13 @@ def h5_attr_to_property(val):
if isinstance(val, np.ndarray): if isinstance(val, np.ndarray):
if val.ndim > 1: if val.ndim > 1:
return None, None return None, None
# The tolist method is on both numpy.ndarray and numpy.generic
if val.ndim == 0: # and properly converts scalars (including 0-dimensional
raise NotImplementedError( # numpy.ndarray) to Python scalars and 1D arrays to lists of
"Code assumes that scalar values " # Python scalars.
"will not be given as np.ndarray objects") if val.ndim != 0:
val = list(val)
dtype = db.LIST(dtype) dtype = db.LIST(dtype)
val = val.tolist()
# TODO this can eventually be removed # TODO this can eventually be removed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment