Skip to content

Commit c0588d6

Browse files
committed
Handle 0-dim arrays being passed to ordinal converter
1 parent 222a6e5 commit c0588d6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

climada/hazard/xarray.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ def _date_to_ordinal_accessor(array: xr.DataArray, strict: bool = True) -> np.nd
9494
return _strict_positive_int_accessor(array)
9595

9696
# Try transforming to ordinals
97-
return np.array(u_dt.datetime64_to_ordinal(array.to_numpy()))
97+
arr = array.to_numpy()
98+
if arr.ndim == 0:
99+
arr = np.array([arr])
100+
return np.array(u_dt.datetime64_to_ordinal(arr))
98101

99102
# Handle access errors
100103
except (ValueError, TypeError, AttributeError) as err:

0 commit comments

Comments
 (0)