From 15f5c83eebc5595f75f4cedf1831992ef7abe41d6f85dca819b0d7500dafbda6 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Thu, 27 May 2021 06:19:25 +0000 Subject: [PATCH] Accepting request 895529 from home:mcepl:branches:devel:languages:python:numeric - Add local_dataset.patch allowing the use of the cached datasets (gh#pydata/xarray#5377). - Add scipy-interpolate.patch adding a missing import scipy.interpolate to test_interp.py (gh#pydata/xarray#5375). - Add test_resample_loffset.patch to fix test_resample_loffset test (gh#pydata/xarray#5364). OBS-URL: https://build.opensuse.org/request/show/895529 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-xarray?expand=0&rev=53 --- local_dataset.patch | 18 ++++++++++++++++++ python-xarray.changes | 10 ++++++++++ python-xarray.spec | 11 +++++++++++ scipy-interpolate.patch | 14 ++++++++++++++ test_resample_loffset.patch | 15 +++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 local_dataset.patch create mode 100644 scipy-interpolate.patch create mode 100644 test_resample_loffset.patch diff --git a/local_dataset.patch b/local_dataset.patch new file mode 100644 index 0000000..0ee942b --- /dev/null +++ b/local_dataset.patch @@ -0,0 +1,18 @@ +--- + xarray/tutorial.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/xarray/tutorial.py ++++ b/xarray/tutorial.py +@@ -139,7 +139,10 @@ def open_dataset( + url = f"{base_url}/raw/{version}/{path.name}" + + # retrieve the file +- filepath = pooch.retrieve(url=url, known_hash=None, path=cache_dir) ++ fname = pathlib.Path(cache_dir, path).expanduser() ++ if not fname.exists(): ++ fname = None ++ filepath = pooch.retrieve(url=url, fname=fname, known_hash=None, path=cache_dir) + ds = _open_dataset(filepath, engine=engine, **kws) + if not cache: + ds = ds.load() diff --git a/python-xarray.changes b/python-xarray.changes index 62f62f7..a433f73 100644 --- a/python-xarray.changes +++ b/python-xarray.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Tue May 25 17:25:46 UTC 2021 - Matej Cepl + +- Add local_dataset.patch allowing the use of the cached datasets + (gh#pydata/xarray#5377). +- Add scipy-interpolate.patch adding a missing import + scipy.interpolate to test_interp.py (gh#pydata/xarray#5375). +- Add test_resample_loffset.patch to fix test_resample_loffset + test (gh#pydata/xarray#5364). + ------------------------------------------------------------------- Thu May 20 11:58:50 UTC 2021 - Sebastian Wagner diff --git a/python-xarray.spec b/python-xarray.spec index 2dda74d..e2851a2 100644 --- a/python-xarray.spec +++ b/python-xarray.spec @@ -27,6 +27,15 @@ Summary: N-D labeled arrays and datasets in Python License: Apache-2.0 URL: https://github.com/pydata/xarray Source: https://files.pythonhosted.org/packages/source/x/xarray/xarray-%{version}.tar.gz +# PATCH-FEATURE-UPSTREAM local_dataset.patch gh#pydata/xarray#5377 mcepl@suse.com +# fix xr.tutorial.open_dataset to work with the preloaded cache. +Patch0: local_dataset.patch +# PATCH-FIX-UPSTREAM scipy-interpolate.patch gh#pydata/xarray#5375 mcepl@suse.com +# Add missing import scipy.interpolate +Patch1: scipy-interpolate.patch +# PATCH-FIX-UPSTREAM test_resample_loffset.patch gh#pydata/xarray#5364 mcepl@suse.com +# use assert_allclose in test_resample_loffset test +Patch2: test_resample_loffset.patch BuildRequires: %{python_module numpy >= 1.15} BuildRequires: %{python_module numpy-devel >= 1.14} BuildRequires: %{python_module pandas >= 0.25} @@ -63,6 +72,7 @@ Suggests: python-cfgrib #/SECTION # SECTION tests BuildRequires: %{python_module dask-dataframe} +BuildRequires: %{python_module pooch} BuildRequires: %{python_module pytest-xdist} BuildRequires: %{python_module pytest} BuildRequires: %{python_module scipy} @@ -80,6 +90,7 @@ The dataset is an in-memory representation of a netCDF file. %prep %autosetup -p1 -n xarray-%{version} + chmod -x xarray/util/print_versions.py %build diff --git a/scipy-interpolate.patch b/scipy-interpolate.patch new file mode 100644 index 0000000..f5db581 --- /dev/null +++ b/scipy-interpolate.patch @@ -0,0 +1,14 @@ +--- + xarray/tests/test_interp.py | 1 + + 1 file changed, 1 insertion(+) + +--- a/xarray/tests/test_interp.py ++++ b/xarray/tests/test_interp.py +@@ -20,6 +20,7 @@ from .test_dataset import create_test_da + + try: + import scipy ++ import scipy.interpolate + except ImportError: + pass + diff --git a/test_resample_loffset.patch b/test_resample_loffset.patch new file mode 100644 index 0000000..a3d1577 --- /dev/null +++ b/test_resample_loffset.patch @@ -0,0 +1,15 @@ +--- + xarray/tests/test_dataset.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/xarray/tests/test_dataset.py ++++ b/xarray/tests/test_dataset.py +@@ -3988,7 +3988,7 @@ class TestDataset: + expected_ = ds.bar.to_series().resample("24H").mean() + expected_.index += to_offset("-12H") + expected = DataArray.from_series(expected_) +- assert_identical(actual, expected) ++ assert_allclose(actual, expected) + + def test_resample_by_mean_discarding_attrs(self): + times = pd.date_range("2000-01-01", freq="6H", periods=10)