From 096343512e262e45a8bef3b0e974d37123e7d4c0 Mon Sep 17 00:00:00 2001 From: Bryan Harter <41062454+bryan-harter@users.noreply.github.com> Date: Thu, 22 Feb 2024 00:25:06 +0000 Subject: [PATCH] Checking for 0 dimension input rather than 0 size input in xarray_to_cdf --- cdflib/xarray/xarray_to_cdf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdflib/xarray/xarray_to_cdf.py b/cdflib/xarray/xarray_to_cdf.py index c7ade42..f4d8265 100644 --- a/cdflib/xarray/xarray_to_cdf.py +++ b/cdflib/xarray/xarray_to_cdf.py @@ -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)