Skip to content

Commit 4f481af

Browse files
committed
Re-introduce fix removed in pydata#4684
1 parent 38203da commit 4f481af

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

xarray/coding/times.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ def _decode_datetime_with_pandas(flat_num_dates, units, calendar):
181181
# strings, in which case we fall back to using cftime
182182
raise OutOfBoundsDatetime
183183

184+
with warnings.catch_warnings():
185+
warnings.filterwarnings("ignore", "invalid value encountered", RuntimeWarning)
186+
pd.to_timedelta(flat_num_dates.min(), delta) + ref_date
187+
pd.to_timedelta(flat_num_dates.max(), delta) + ref_date
188+
184189
# To avoid integer overflow when converting to nanosecond units for integer
185190
# dtypes smaller than np.int64 cast all integer-dtype arrays to np.int64
186191
# (GH 2002).

0 commit comments

Comments
 (0)