Skip to content

Commit

Permalink
bugfix 0d time data dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasprobst committed Nov 7, 2023
1 parent 4e90db8 commit 79a8a6d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions h5rdmtoolbox/wrapper/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .ds_decoder import dataset_value_decoder
from .h5attr import H5_DIM_ATTRS, pop_hdf_attributes, WrapperAttributeManager
from .h5utils import _is_not_valid_natural_name, get_rootparent
from .. import _repr, get_config, conventions, utils, consts, get_ureg, protected_attributes
from .. import _repr, get_config, conventions, utils, consts, protected_attributes
from .._repr import H5Repr, H5PY_SPECIAL_ATTRIBUTES
from .._version import __version__
from ..conventions.consts import DefaultValue
Expand Down Expand Up @@ -1673,13 +1673,18 @@ def __getitem__(self, args, new_dtype=None, nparray=False) -> Union[xr.DataArray
if dim_ds_data.dtype.kind == 'S':
# decode string array
if dim_ds_attrs.get('ISTIMEDS', False):
dim_ds_data = np.array([datetime.fromisoformat(t) for t in dim_ds_data.astype(str)]).astype(
datetime)
if dim_ds_data.ndim == 0:
dim_ds_data = np.array(datetime.fromisoformat(dim_ds_data.astype(str))).astype(datetime)
else:
dim_ds_data = np.array(
[datetime.fromisoformat(t) for t in dim_ds_data.astype(str)]).astype(
datetime)
if dim_ds_data.ndim == 0:
if isinstance(arg, int):
coords[coord_name] = xr.DataArray(name=coord_name,
dims=(
), data=dim_ds_data,
),
data=dim_ds_data,
attrs=dim_ds_attrs)
else:
coords[coord_name] = xr.DataArray(name=coord_name, dims=coord_name,
Expand Down

0 comments on commit 79a8a6d

Please sign in to comment.