From ca72d56c213a1c47e54b12ee559f412e60fbf9b1 Mon Sep 17 00:00:00 2001 From: Spencer Clark Date: Sat, 22 May 2021 20:13:19 -0400 Subject: [PATCH] Make `kind` argument in `CFTimeIndex._maybe_cast_slice_bound` optional (#5359) * [test-upstream] Make kind argument in CFTimeIndex._maybe_cast_slice_bound optional * Update doc/whats-new.rst Co-authored-by: keewis Co-authored-by: keewis --- doc/whats-new.rst | 4 ++++ xarray/coding/cftimeindex.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/xarray/coding/cftimeindex.py b/xarray/coding/cftimeindex.py index f0de5565..783fe8d0 100644 --- a/xarray/coding/cftimeindex.py +++ b/xarray/coding/cftimeindex.py @@ -465,9 +465,14 @@ class CFTimeIndex(pd.Index): 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 -- 2.32.0 From 34dc57717c82a86455a9e5abb0a47df782266c7e Mon Sep 17 00:00:00 2001 From: Mathias Hauser Date: Mon, 7 Jun 2021 23:05:24 +0200 Subject: [PATCH] fix dask meta and output_dtypes error (#5449) --- xarray/tests/test_computation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py index b7ae1ca9..09bed724 100644 --- a/xarray/tests/test_computation.py +++ b/xarray/tests/test_computation.py @@ -1306,7 +1306,10 @@ def test_vectorize_dask_dtype_without_output_dtypes(data_array): assert expected.dtype == actual.dtype -@pytest.mark.xfail(LooseVersion(dask.__version__) < "2.3", reason="dask GH5274") +@pytest.mark.skipif( + LooseVersion(dask.__version__) > "2021.06", + reason="dask/dask#7669: can no longer pass output_dtypes and meta", +) @requires_dask def test_vectorize_dask_dtype_meta(): # meta dtype takes precedence -- 2.32.0 From 5a14d7d398be7e0efc6d5c8920dc8886212c3b2a Mon Sep 17 00:00:00 2001 From: Spencer Clark Date: Sat, 12 Jun 2021 08:58:42 -0400 Subject: [PATCH] Explicitly state datetime units in array constructors in `test_datetime_mean` (#5463) --- xarray/tests/test_duck_array_ops.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xarray/tests/test_duck_array_ops.py b/xarray/tests/test_duck_array_ops.py index 0eb00725..6d49e209 100644 --- a/xarray/tests/test_duck_array_ops.py +++ b/xarray/tests/test_duck_array_ops.py @@ -285,15 +285,15 @@ def assert_dask_array(da, dask): def test_datetime_mean(dask): # Note: only testing numpy, as dask is broken upstream da = DataArray( - np.array(["2010-01-01", "NaT", "2010-01-03", "NaT", "NaT"], dtype="M8"), + np.array(["2010-01-01", "NaT", "2010-01-03", "NaT", "NaT"], dtype="M8[ns]"), dims=["time"], ) if dask: # Trigger use case where a chunk is full of NaT da = da.chunk({"time": 3}) - expect = DataArray(np.array("2010-01-02", dtype="M8")) - expect_nat = DataArray(np.array("NaT", dtype="M8")) + expect = DataArray(np.array("2010-01-02", dtype="M8[ns]")) + expect_nat = DataArray(np.array("NaT", dtype="M8[ns]")) actual = da.mean() if dask: @@ -889,8 +889,6 @@ def test_push_dask(): # some chunks of size-1 with NaN with raise_if_dask_computes(): actual = push( - dask.array.from_array(array, chunks=(1, 2, 3, 2, 2, 1, 1)), - axis=0, - n=None, + dask.array.from_array(array, chunks=(1, 2, 3, 2, 2, 1, 1)), axis=0, n=None ) np.testing.assert_equal(actual, expected) -- 2.32.0