From f231076548125ab4780412b9c58514b251b79fcb Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sat, 3 Jul 2021 13:12:50 +0200 Subject: dev-python/xarray: Backport pandas & dask compatibility fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- .../xarray/files/xarray-0.18.2-backports.patch | 116 +++++++++++++++++++++ dev-python/xarray/xarray-0.18.2-r1.ebuild | 46 ++++++++ dev-python/xarray/xarray-0.18.2.ebuild | 42 -------- 3 files changed, 162 insertions(+), 42 deletions(-) create mode 100644 dev-python/xarray/files/xarray-0.18.2-backports.patch create mode 100644 dev-python/xarray/xarray-0.18.2-r1.ebuild delete mode 100644 dev-python/xarray/xarray-0.18.2.ebuild (limited to 'dev-python/xarray') diff --git a/dev-python/xarray/files/xarray-0.18.2-backports.patch b/dev-python/xarray/files/xarray-0.18.2-backports.patch new file mode 100644 index 000000000000..be30702e67f4 --- /dev/null +++ b/dev-python/xarray/files/xarray-0.18.2-backports.patch @@ -0,0 +1,116 @@ +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 + diff --git a/dev-python/xarray/xarray-0.18.2-r1.ebuild b/dev-python/xarray/xarray-0.18.2-r1.ebuild new file mode 100644 index 000000000000..573e03b4e449 --- /dev/null +++ b/dev-python/xarray/xarray-0.18.2-r1.ebuild @@ -0,0 +1,46 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +# pkg_resources use in code +DISTUTILS_USE_SETUPTOOLS=rdepend +PYTHON_COMPAT=( python3_{7..9} ) + +inherit distutils-r1 + +DESCRIPTION="N-D labeled arrays and datasets in Python" +HOMEPAGE="https://xarray.pydata.org/" +SRC_URI="mirror://pypi/${P:0:1}/${PN}/${P}.tar.gz" + +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="amd64 ~arm ~arm64 ~x86 ~amd64-linux ~x86-linux" + +RDEPEND=" + >=dev-python/numpy-1.17[${PYTHON_USEDEP}] + >=dev-python/pandas-1.0[${PYTHON_USEDEP}]" +# note: most of test dependencies are optional +BDEPEND=" + test? ( + dev-python/bottleneck[${PYTHON_USEDEP}] + dev-python/hypothesis[${PYTHON_USEDEP}] + dev-python/matplotlib[${PYTHON_USEDEP}] + dev-python/toolz[${PYTHON_USEDEP}] + >=dev-python/scipy-1.4[${PYTHON_USEDEP}] + )" + +distutils_enable_tests pytest + +PATCHES=( + "${FILESDIR}"/${P}-backports.patch +) + +python_test() { + local deselect=( + # warning-targeted tests are fragile and not important to end users + xarray/tests/test_backends.py::test_no_warning_from_dask_effective_get + ) + + epytest ${deselect[@]/#/--deselect } +} diff --git a/dev-python/xarray/xarray-0.18.2.ebuild b/dev-python/xarray/xarray-0.18.2.ebuild deleted file mode 100644 index bedc8b3da110..000000000000 --- a/dev-python/xarray/xarray-0.18.2.ebuild +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -# pkg_resources use in code -DISTUTILS_USE_SETUPTOOLS=rdepend -PYTHON_COMPAT=( python3_{7..9} ) - -inherit distutils-r1 - -DESCRIPTION="N-D labeled arrays and datasets in Python" -HOMEPAGE="https://xarray.pydata.org/" -SRC_URI="mirror://pypi/${P:0:1}/${PN}/${P}.tar.gz" - -LICENSE="Apache-2.0" -SLOT="0" -KEYWORDS="amd64 ~arm ~arm64 ~x86 ~amd64-linux ~x86-linux" - -RDEPEND=" - >=dev-python/numpy-1.17[${PYTHON_USEDEP}] - >=dev-python/pandas-1.0[${PYTHON_USEDEP}]" -# note: most of test dependencies are optional -BDEPEND=" - test? ( - dev-python/bottleneck[${PYTHON_USEDEP}] - dev-python/hypothesis[${PYTHON_USEDEP}] - dev-python/matplotlib[${PYTHON_USEDEP}] - dev-python/toolz[${PYTHON_USEDEP}] - >=dev-python/scipy-1.4[${PYTHON_USEDEP}] - )" - -distutils_enable_tests pytest - -python_test() { - local deselect=( - # warning-targeted tests are fragile and not important to end users - xarray/tests/test_backends.py::test_no_warning_from_dask_effective_get - ) - - epytest ${deselect[@]/#/--deselect } -} -- cgit v1.2.3-65-gdbad