From 591263ed3c8d03b64ccbffb613f4c486ae54e7f2 Mon Sep 17 00:00:00 2001 From: spencerkclark Date: Fri, 21 May 2021 07:16:40 -0400 Subject: [PATCH 1/2] [test-upstream] Make kind argument in CFTimeIndex._maybe_cast_slice_bound optional --- doc/whats-new.rst | 3 +++ xarray/coding/cftimeindex.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 2dc271061e4..942cf1b4956 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -33,6 +33,9 @@ Deprecations Bug fixes ~~~~~~~~~ +- Fix a minor incompatibility between partial datetime string indexing with a +:py:class:`CFTimeIndex` and upcoming pandas version 1.3.0 (:issue:`5356`, +:pull:`5359`). By `Spencer Clark `_. Documentation diff --git a/xarray/coding/cftimeindex.py b/xarray/coding/cftimeindex.py index f0de55656fa..783fe8d04d9 100644 --- a/xarray/coding/cftimeindex.py +++ b/xarray/coding/cftimeindex.py @@ -465,9 +465,14 @@ def get_loc(self, key, method=None, tolerance=None): else: return pd.Index.get_loc(self, key, method=method, tolerance=tolerance) - def _maybe_cast_slice_bound(self, label, side, kind): + def _maybe_cast_slice_bound(self, label, side, kind=None): """Adapted from - pandas.tseries.index.DatetimeIndex._maybe_cast_slice_bound""" + pandas.tseries.index.DatetimeIndex._maybe_cast_slice_bound + + Note that we have never used the kind argument in CFTimeIndex and it is + deprecated as of pandas version 1.3.0. It exists only for compatibility + reasons. We can remove it when our minimum version of pandas is 1.3.0. + """ if not isinstance(label, str): return label From d2c1c0e0fef151737c15bf16f6647c2f8b59dfa2 Mon Sep 17 00:00:00 2001 From: Spencer Clark Date: Sat, 22 May 2021 19:57:58 -0400 Subject: [PATCH 2/2] Update doc/whats-new.rst Co-authored-by: keewis --- doc/whats-new.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 942cf1b4956..828e8da4b44 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -34,8 +34,9 @@ Deprecations Bug fixes ~~~~~~~~~ - Fix a minor incompatibility between partial datetime string indexing with a -:py:class:`CFTimeIndex` and upcoming pandas version 1.3.0 (:issue:`5356`, -:pull:`5359`). By `Spencer Clark `_. + :py:class:`CFTimeIndex` and upcoming pandas version 1.3.0 (:issue:`5356`, + :pull:`5359`). + By `Spencer Clark `_. Documentation