Skip to content

Commit

Permalink
Checking for 0 dimension input rather than 0 size input in xarray_to_cdf
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-harter committed Feb 22, 2024
1 parent 289ddd4 commit 0963435
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cdflib/xarray/xarray_to_cdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ def _unixtime_to_tt2000(unixtime_data) -> npt.NDArray: # type: ignore[no-untype
if not hasattr(unixtime_data, "__len__"):
unixtime_data = [unixtime_data]
elif isinstance(unixtime_data, np.ndarray):
if unixtime_data.size <= 1:
# Sometimes a np array has a length, but a dimension of 0
if unixtime_data.ndim == 0:
unixtime_data = [unixtime_data]

tt2000_data = np.zeros(len(unixtime_data), dtype=np.int64)
Expand Down

0 comments on commit 0963435

Please sign in to comment.