Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f10e4da66 | ||
|
|
751e38064f | ||
|
|
196ebc08ba | ||
|
|
f7571ba9d3 | ||
|
|
b402b2518a | ||
|
|
185ae2fc83 | ||
|
|
6f9b465990 | ||
|
|
8df0d82123 | ||
|
|
d121e78a08 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -29,3 +29,7 @@
|
||||
/xarray-2024.7.0.tar.gz
|
||||
/xarray-2024.10.0.tar.gz
|
||||
/xarray-2025.1.1.tar.gz
|
||||
/xarray-2025.4.0.tar.gz
|
||||
/xarray-2025.9.0.tar.gz
|
||||
/xarray-2025.11.0.tar.gz
|
||||
/xarray-2025.12.0.tar.gz
|
||||
|
||||
42
0001-Drop-pydap-from-dependencies.patch
Normal file
42
0001-Drop-pydap-from-dependencies.patch
Normal file
@@ -0,0 +1,42 @@
|
||||
From 260fec7f2a203093cb6626d464e30fab3ec70de7 Mon Sep 17 00:00:00 2001
|
||||
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
||||
Date: Mon, 15 Sep 2025 05:49:16 -0400
|
||||
Subject: [PATCH 1/2] Drop pydap from dependencies
|
||||
|
||||
We didn't have it since it wasn't available in Python 3.10+, and it's
|
||||
not yet pcakaged.
|
||||
|
||||
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
||||
---
|
||||
pyproject.toml | 1 -
|
||||
xarray/tests/test_backends.py | 2 +-
|
||||
2 files changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/pyproject.toml b/pyproject.toml
|
||||
index 52897064..23d0b8ee 100644
|
||||
--- a/pyproject.toml
|
||||
+++ b/pyproject.toml
|
||||
@@ -38,7 +38,6 @@ complete = ["xarray[accel,etc,io,parallel,viz]"]
|
||||
io = [
|
||||
"netCDF4>=1.6.0",
|
||||
"h5netcdf",
|
||||
- "pydap",
|
||||
"scipy>=1.13",
|
||||
"zarr>=2.18",
|
||||
"fsspec",
|
||||
diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py
|
||||
index 5aab1531..89461b0a 100644
|
||||
--- a/xarray/tests/test_backends.py
|
||||
+++ b/xarray/tests/test_backends.py
|
||||
@@ -7457,7 +7457,7 @@ def test_remote_url_backend_auto_detection() -> None:
|
||||
"https://disc2.gesdisc.eosdis.nasa.gov/dods/TRMM_3B42", # GrADS /dods/
|
||||
]
|
||||
|
||||
- for url in dap_urls:
|
||||
+ for url in dap_urls[:0]:
|
||||
engine = guess_engine(url)
|
||||
assert engine == expected_dap_backend, (
|
||||
f"URL {url!r} should select {expected_dap_backend!r} but got {engine!r}"
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
From f41100ae4202dce5891854143ba3a31f4e2d5a6d Mon Sep 17 00:00:00 2001
|
||||
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
||||
Date: Tue, 14 Jan 2025 02:46:39 -0500
|
||||
Subject: [PATCH 1/2] Fix test_doc_example on big-endian systems
|
||||
|
||||
... by using a fixed-endian input.
|
||||
|
||||
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
||||
---
|
||||
xarray/tests/test_datatree.py | 8 ++++++--
|
||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/xarray/tests/test_datatree.py b/xarray/tests/test_datatree.py
|
||||
index 7b295128..21870050 100644
|
||||
--- a/xarray/tests/test_datatree.py
|
||||
+++ b/xarray/tests/test_datatree.py
|
||||
@@ -1240,8 +1240,12 @@ class TestRepr:
|
||||
)
|
||||
def test_doc_example(self) -> None:
|
||||
# regression test for https://github.com/pydata/xarray/issues/9499
|
||||
- time = xr.DataArray(data=["2022-01", "2023-01"], dims="time")
|
||||
- stations = xr.DataArray(data=list("abcdef"), dims="station")
|
||||
+ time = xr.DataArray(
|
||||
+ data=np.array(["2022-01", "2023-01"], dtype="<U7"), dims="time"
|
||||
+ )
|
||||
+ stations = xr.DataArray(
|
||||
+ data=np.array(list("abcdef"), dtype="<U1"), dims="station"
|
||||
+ )
|
||||
lon = [-100, -80, -60]
|
||||
lat = [10, 20, 30]
|
||||
# Set up fake data
|
||||
--
|
||||
2.47.0
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
From e84321150e52a19e617efd7f8798d6859bd3c5e7 Mon Sep 17 00:00:00 2001
|
||||
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
||||
Date: Sun, 19 Jan 2025 04:47:23 -0500
|
||||
Subject: [PATCH 2/2] Avoid unsafe casts from float to unsigned int
|
||||
|
||||
Fixes #9815
|
||||
|
||||
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
||||
---
|
||||
xarray/coding/variables.py | 5 ++++-
|
||||
xarray/core/duck_array_ops.py | 10 ++++++++++
|
||||
2 files changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/xarray/coding/variables.py b/xarray/coding/variables.py
|
||||
index 8154f044..355f3b0b 100644
|
||||
--- a/xarray/coding/variables.py
|
||||
+++ b/xarray/coding/variables.py
|
||||
@@ -426,7 +426,10 @@ class CFMaskCoder(VariableCoder):
|
||||
if fill_value is not None and has_unsigned:
|
||||
pop_to(encoding, attrs, "_Unsigned")
|
||||
# XXX: Is this actually needed? Doesn't the backend handle this?
|
||||
- data = duck_array_ops.astype(duck_array_ops.around(data), dtype)
|
||||
+ signed_dtype = np.dtype(f"i{dtype.itemsize}")
|
||||
+ data = duck_array_ops.view(
|
||||
+ duck_array_ops.astype(duck_array_ops.around(data), signed_dtype), dtype
|
||||
+ )
|
||||
attrs["_FillValue"] = fill_value
|
||||
|
||||
return Variable(dims, data, attrs, encoding, fastpath=True)
|
||||
diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py
|
||||
index 7e7333fd..be842b66 100644
|
||||
--- a/xarray/core/duck_array_ops.py
|
||||
+++ b/xarray/core/duck_array_ops.py
|
||||
@@ -236,6 +236,16 @@ def astype(data, dtype, **kwargs):
|
||||
return data.astype(dtype, **kwargs)
|
||||
|
||||
|
||||
+def view(data, *args, **kwargs):
|
||||
+ if hasattr(data, "__array_namespace__"):
|
||||
+ xp = get_array_namespace(data)
|
||||
+ if xp == np:
|
||||
+ # numpy currently doesn't have a view:
|
||||
+ return data.view(*args, **kwargs)
|
||||
+ return xp.view(data, *args, **kwargs)
|
||||
+ return data.view(*args, **kwargs)
|
||||
+
|
||||
+
|
||||
def asarray(data, xp=np, dtype=None):
|
||||
converted = data if is_duck_array(data) else xp.asarray(data)
|
||||
|
||||
--
|
||||
2.47.0
|
||||
|
||||
117
0002-Ensure-netcdf4-is-locked-while-closing.patch
Normal file
117
0002-Ensure-netcdf4-is-locked-while-closing.patch
Normal file
@@ -0,0 +1,117 @@
|
||||
From 5e5ef99ce6cae2179a2cc89b551b187fb97f35fe Mon Sep 17 00:00:00 2001
|
||||
From: David Bold <davidsch@fedoraproject.org>
|
||||
Date: Tue, 25 Nov 2025 19:58:05 -0500
|
||||
Subject: [PATCH 2/2] Ensure netcdf4 is locked while closing
|
||||
|
||||
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
||||
---
|
||||
xarray/backends/file_manager.py | 20 +++++++++++++++-----
|
||||
xarray/backends/locks.py | 3 +++
|
||||
xarray/backends/netCDF4_.py | 8 +++-----
|
||||
3 files changed, 21 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/xarray/backends/file_manager.py b/xarray/backends/file_manager.py
|
||||
index f7cd4675..cf85eaf3 100644
|
||||
--- a/xarray/backends/file_manager.py
|
||||
+++ b/xarray/backends/file_manager.py
|
||||
@@ -8,7 +8,7 @@ from collections.abc import Callable, Hashable, Iterator, Mapping, MutableMappin
|
||||
from contextlib import AbstractContextManager, contextmanager
|
||||
from typing import Any, Generic, Literal, TypeVar, cast
|
||||
|
||||
-from xarray.backends.locks import acquire
|
||||
+from xarray.backends.locks import NETCDF4_PYTHON_LOCK, acquire
|
||||
from xarray.backends.lru_cache import LRUCache
|
||||
from xarray.core import utils
|
||||
from xarray.core.options import OPTIONS
|
||||
@@ -89,7 +89,7 @@ class CachingFileManager(FileManager[T_File]):
|
||||
*args: Any,
|
||||
mode: Any = _OMIT_MODE,
|
||||
kwargs: Mapping[str, Any] | None = None,
|
||||
- lock: Lock | None | Literal[False] = None,
|
||||
+ lock: Lock | Literal[False] | None = None,
|
||||
cache: MutableMapping[Any, T_File] | None = None,
|
||||
manager_id: Hashable | None = None,
|
||||
ref_counts: dict[Any, int] | None = None,
|
||||
@@ -448,9 +448,16 @@ def _remove_del_methods():
|
||||
class DummyFileManager(FileManager[T_File]):
|
||||
"""FileManager that simply wraps an open file in the FileManager interface."""
|
||||
|
||||
- def __init__(self, value: T_File, *, close: Callable[[], None] | None = None):
|
||||
+ def __init__(
|
||||
+ self,
|
||||
+ value: T_File,
|
||||
+ *,
|
||||
+ close: Callable[[], None] | None = None,
|
||||
+ lock: Lock | Literal[False] | None = None,
|
||||
+ ):
|
||||
if close is None:
|
||||
close = value.close
|
||||
+ self._lock = lock
|
||||
self._value = value
|
||||
self._close = close
|
||||
|
||||
@@ -464,5 +471,8 @@ class DummyFileManager(FileManager[T_File]):
|
||||
yield self._value
|
||||
|
||||
def close(self, needs_lock: bool = True) -> None:
|
||||
- del needs_lock # unused
|
||||
- self._close()
|
||||
+ if needs_lock and self._lock:
|
||||
+ with self._lock:
|
||||
+ self._close()
|
||||
+ else:
|
||||
+ self._close()
|
||||
diff --git a/xarray/backends/locks.py b/xarray/backends/locks.py
|
||||
index 78444354..e2db5e93 100644
|
||||
--- a/xarray/backends/locks.py
|
||||
+++ b/xarray/backends/locks.py
|
||||
@@ -281,3 +281,6 @@ def ensure_lock(lock: Lock | None | Literal[False]) -> Lock:
|
||||
if lock is None or lock is False:
|
||||
return DummyLock()
|
||||
return lock
|
||||
+
|
||||
+
|
||||
+NETCDF4_PYTHON_LOCK = combine_locks([NETCDFC_LOCK, HDF5_LOCK])
|
||||
diff --git a/xarray/backends/netCDF4_.py b/xarray/backends/netCDF4_.py
|
||||
index bb511f9b..5d5d4e74 100644
|
||||
--- a/xarray/backends/netCDF4_.py
|
||||
+++ b/xarray/backends/netCDF4_.py
|
||||
@@ -30,7 +30,7 @@ from xarray.backends.file_manager import (
|
||||
PickleableFileManager,
|
||||
)
|
||||
from xarray.backends.locks import (
|
||||
- HDF5_LOCK,
|
||||
+ NETCDF4_PYTHON_LOCK,
|
||||
NETCDFC_LOCK,
|
||||
combine_locks,
|
||||
ensure_lock,
|
||||
@@ -67,8 +67,6 @@ if TYPE_CHECKING:
|
||||
# string used by netCDF4.
|
||||
_endian_lookup = {"=": "native", ">": "big", "<": "little", "|": "native"}
|
||||
|
||||
-NETCDF4_PYTHON_LOCK = combine_locks([NETCDFC_LOCK, HDF5_LOCK])
|
||||
-
|
||||
|
||||
class BaseNetCDF4Array(BackendArray):
|
||||
__slots__ = ("datastore", "dtype", "shape", "variable_name")
|
||||
@@ -421,7 +419,7 @@ class NetCDF4DataStore(WritableCFDataStore):
|
||||
"argument is provided"
|
||||
)
|
||||
root = manager
|
||||
- manager = DummyFileManager(root)
|
||||
+ manager = DummyFileManager(root, lock=NETCDF4_PYTHON_LOCK)
|
||||
|
||||
self._manager = manager
|
||||
self._group = group
|
||||
@@ -520,7 +518,7 @@ class NetCDF4DataStore(WritableCFDataStore):
|
||||
)
|
||||
else:
|
||||
manager = CachingFileManager(
|
||||
- netCDF4.Dataset, filename, mode=mode, kwargs=kwargs
|
||||
+ netCDF4.Dataset, filename, lock=lock, mode=mode, kwargs=kwargs
|
||||
)
|
||||
return cls(manager, group=group, mode=mode, lock=lock, autoclose=autoclose)
|
||||
|
||||
--
|
||||
2.52.0
|
||||
|
||||
102
9945.patch
102
9945.patch
@@ -1,102 +0,0 @@
|
||||
From da4aa1f2f116089c75adee5954bcc9ab755bcb89 Mon Sep 17 00:00:00 2001
|
||||
From: Deepak Cherian <deepak@cherian.net>
|
||||
Date: Mon, 13 Jan 2025 08:00:50 -0600
|
||||
Subject: [PATCH 1/2] Remove outdated quantile test.
|
||||
|
||||
dask now auto-rechunks for quantile.
|
||||
|
||||
Closes #9860
|
||||
---
|
||||
xarray/tests/test_groupby.py | 18 ++++++++++--------
|
||||
1 file changed, 10 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py
|
||||
index e4383dd58a9..2349ff0adfd 100644
|
||||
--- a/xarray/tests/test_groupby.py
|
||||
+++ b/xarray/tests/test_groupby.py
|
||||
@@ -284,7 +284,6 @@ def test_da_groupby_empty() -> None:
|
||||
|
||||
@requires_dask
|
||||
def test_dask_da_groupby_quantile() -> None:
|
||||
- # Only works when the grouped reduction can run blockwise
|
||||
# Scalar quantile
|
||||
expected = xr.DataArray(
|
||||
data=[2, 5], coords={"x": [1, 2], "quantile": 0.5}, dims="x"
|
||||
@@ -292,8 +291,6 @@ def test_dask_da_groupby_quantile() -> None:
|
||||
array = xr.DataArray(
|
||||
data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
|
||||
)
|
||||
- with pytest.raises(ValueError):
|
||||
- array.chunk(x=1).groupby("x").quantile(0.5)
|
||||
|
||||
# will work blockwise with flox
|
||||
actual = array.chunk(x=3).groupby("x").quantile(0.5)
|
||||
@@ -327,7 +324,8 @@ def test_dask_da_groupby_median() -> None:
|
||||
assert_identical(expected, actual)
|
||||
|
||||
|
||||
-def test_da_groupby_quantile() -> None:
|
||||
+@pytest.mark.parametrize("use_flox", [True, False])
|
||||
+def test_da_groupby_quantile(use_flox) -> None:
|
||||
array = xr.DataArray(
|
||||
data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
|
||||
)
|
||||
@@ -336,8 +334,10 @@ def test_da_groupby_quantile() -> None:
|
||||
expected = xr.DataArray(
|
||||
data=[2, 5], coords={"x": [1, 2], "quantile": 0.5}, dims="x"
|
||||
)
|
||||
- actual = array.groupby("x").quantile(0.5)
|
||||
- assert_identical(expected, actual)
|
||||
+
|
||||
+ with xr.set_options(use_flox=use_flox):
|
||||
+ actual = array.groupby("x").quantile(0.5)
|
||||
+ assert_identical(expected, actual)
|
||||
|
||||
# Vector quantile
|
||||
expected = xr.DataArray(
|
||||
@@ -345,7 +345,8 @@ def test_da_groupby_quantile() -> None:
|
||||
coords={"x": [1, 2], "quantile": [0, 1]},
|
||||
dims=("x", "quantile"),
|
||||
)
|
||||
- actual = array.groupby("x").quantile([0, 1])
|
||||
+ with xr.set_options(use_flox=use_flox):
|
||||
+ actual = array.groupby("x").quantile([0, 1])
|
||||
assert_identical(expected, actual)
|
||||
|
||||
array = xr.DataArray(
|
||||
@@ -356,7 +357,8 @@ def test_da_groupby_quantile() -> None:
|
||||
e = [np.nan, 5] if skipna is False else [2.5, 5]
|
||||
|
||||
expected = xr.DataArray(data=e, coords={"x": [1, 2], "quantile": 0.5}, dims="x")
|
||||
- actual = array.groupby("x").quantile(0.5, skipna=skipna)
|
||||
+ with xr.set_options(use_flox=use_flox):
|
||||
+ actual = array.groupby("x").quantile(0.5, skipna=skipna)
|
||||
assert_identical(expected, actual)
|
||||
|
||||
# Multiple dimensions
|
||||
|
||||
From 3d6e76a29a328489b0867a89fce1c157605c5f5d Mon Sep 17 00:00:00 2001
|
||||
From: Deepak Cherian <dcherian@users.noreply.github.com>
|
||||
Date: Mon, 13 Jan 2025 10:28:29 -0600
|
||||
Subject: [PATCH 2/2] Apply suggestions from code review
|
||||
|
||||
Co-authored-by: Michael Niklas <mick.niklas@gmail.com>
|
||||
---
|
||||
xarray/tests/test_groupby.py | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py
|
||||
index 2349ff0adfd..7dd6cdb622d 100644
|
||||
--- a/xarray/tests/test_groupby.py
|
||||
+++ b/xarray/tests/test_groupby.py
|
||||
@@ -324,8 +324,8 @@ def test_dask_da_groupby_median() -> None:
|
||||
assert_identical(expected, actual)
|
||||
|
||||
|
||||
-@pytest.mark.parametrize("use_flox", [True, False])
|
||||
-def test_da_groupby_quantile(use_flox) -> None:
|
||||
+@pytest.mark.parametrize("use_flox", [pytest.param(True, marks=requires_flox), False])
|
||||
+def test_da_groupby_quantile(use_flox: bool) -> None:
|
||||
array = xr.DataArray(
|
||||
data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
|
||||
)
|
||||
3
README.packit
Normal file
3
README.packit
Normal file
@@ -0,0 +1,3 @@
|
||||
This repository is maintained by packit.
|
||||
https://packit.dev/
|
||||
The file was generated using packit 1.12.0.post1.dev20+g7d30dac21.
|
||||
@@ -1,33 +1,32 @@
|
||||
%global srcname xarray
|
||||
|
||||
Name: python-%{srcname}
|
||||
Version: 2025.1.1
|
||||
Version: 2025.12.0
|
||||
Release: %autorelease
|
||||
Summary: N-D labeled arrays and datasets in Python
|
||||
|
||||
License: Apache-2.0
|
||||
URL: https://github.com/pydata/xarray
|
||||
Source: %pypi_source %{srcname}
|
||||
|
||||
# Fix test_dask_da_groupby_quantile.
|
||||
Patch: https://github.com/pydata/xarray/pull/9945.patch
|
||||
|
||||
# https://github.com/pydata/xarray/pull/9949
|
||||
Patch: 0001-Fix-test_doc_example-on-big-endian-systems.patch
|
||||
# https://github.com/pydata/xarray/pull/9964
|
||||
Patch: 0002-Avoid-unsafe-casts-from-float-to-unsigned-int.patch
|
||||
# Fedora specific.
|
||||
Patch: 0001-Drop-pydap-from-dependencies.patch
|
||||
# RHBZ#2395128
|
||||
# https://github.com/pydata/xarray/pull/10788
|
||||
Patch: 0002-Ensure-netcdf4-is-locked-while-closing.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3dist(bottleneck)
|
||||
BuildRequires: python3dist(dask[array]) >= 2023.9
|
||||
BuildRequires: python3dist(dask[dataframe]) >= 2023.9
|
||||
BuildRequires: python3dist(pint) >= 0.16
|
||||
BuildRequires: python3dist(dask[array]) >= 2023.11
|
||||
BuildRequires: python3dist(dask[dataframe]) >= 2023.11
|
||||
BuildRequires: python3dist(pint) >= 0.22
|
||||
BuildRequires: python3dist(pytest) >= 2.7.1
|
||||
BuildRequires: python3dist(pytest-asyncio)
|
||||
BuildRequires: python3dist(pytest-xdist)
|
||||
BuildRequires: python3dist(rasterio) >= 1.1
|
||||
BuildRequires: python3dist(seaborn) >= 0.11
|
||||
BuildRequires: python3dist(pytest-timeout)
|
||||
BuildRequires: python3dist(rasterio) >= 1.3
|
||||
BuildRequires: python3dist(seaborn) >= 0.13
|
||||
|
||||
%global _description %{expand: \
|
||||
Xarray (formerly xray) is an open source project and Python package that
|
||||
@@ -69,6 +68,8 @@ Summary: %{summary}
|
||||
%check
|
||||
rm -rf xarray
|
||||
|
||||
echo >> pytest.ini # Ignore any command-line arguments from upstream.
|
||||
|
||||
pytest_args=(
|
||||
-n auto
|
||||
-m "not network"
|
||||
@@ -76,7 +77,7 @@ pytest_args=(
|
||||
-k 'not test_save_mfdataset_compute_false_roundtrip'
|
||||
)
|
||||
|
||||
%{pytest} -ra "${pytest_args[@]}" --pyargs xarray
|
||||
%{pytest} -ra "${pytest_args[@]}" --pyargs xarray --timeout 300 --full-trace
|
||||
|
||||
%files -n python3-%{srcname} -f %{pyproject_files}
|
||||
%license licenses/*
|
||||
|
||||
2
sources
2
sources
@@ -1 +1 @@
|
||||
SHA512 (xarray-2025.1.1.tar.gz) = a0cde2c8e38887878bcde25fd3ea6ee436b522ca73f52359d2c8ac1993447472d7cd5e5d4b11016ec48d1b86dba08e9207caf00b2b43ab896c777395e51f7943
|
||||
SHA512 (xarray-2025.12.0.tar.gz) = 7bbdf756d24a91c4a11c5d38d10dfe520e2cb80ba2beecdbf534fae76c6c6148232f2f072d068daab60146d46c89e12800276ebc1bc4d5228b16dde8f80d9793
|
||||
|
||||
Reference in New Issue
Block a user