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
This commit is part of merge request !18. Comments created here will be created in the context of that merge request.
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment