Skip to content

Commit 11170fc

Browse files
committed
Merge branch 'main' of https://github.com/pydata/xarray
2 parents 57d9d23 + 2da7f55 commit 11170fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1826
-1419
lines changed

ci/requirements/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dependencies:
5656
- types-pytz
5757
- types-PyYAML
5858
- types-setuptools
59+
- types-openpyxl
5960
- typing_extensions
6061
- zarr
6162
- pip:

conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def pytest_runtest_setup(item):
2222
pytest.skip(
2323
"set --run-network-tests to run test requiring an internet connection"
2424
)
25-
if "mypy" in item.keywords and not item.config.getoption("--run-mypy"):
25+
if any("mypy" in m.name for m in item.own_markers) and not item.config.getoption(
26+
"--run-mypy"
27+
):
2628
pytest.skip("set --run-mypy option to run mypy tests")
2729

2830

doc/api-hidden.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@
2828
core.coordinates.DatasetCoordinates.equals
2929
core.coordinates.DatasetCoordinates.identical
3030

31-
core.rolling.DatasetCoarsen.boundary
32-
core.rolling.DatasetCoarsen.coord_func
33-
core.rolling.DatasetCoarsen.obj
34-
core.rolling.DatasetCoarsen.side
35-
core.rolling.DatasetCoarsen.trim_excess
36-
core.rolling.DatasetCoarsen.windows
37-
38-
core.rolling.DatasetRolling.center
39-
core.rolling.DatasetRolling.dim
40-
core.rolling.DatasetRolling.min_periods
41-
core.rolling.DatasetRolling.obj
42-
core.rolling.DatasetRolling.rollings
43-
core.rolling.DatasetRolling.window
44-
45-
core.weighted.DatasetWeighted.obj
46-
core.weighted.DatasetWeighted.weights
31+
computation.rolling.DatasetCoarsen.boundary
32+
computation.rolling.DatasetCoarsen.coord_func
33+
computation.rolling.DatasetCoarsen.obj
34+
computation.rolling.DatasetCoarsen.side
35+
computation.rolling.DatasetCoarsen.trim_excess
36+
computation.rolling.DatasetCoarsen.windows
37+
38+
computation.rolling.DatasetRolling.center
39+
computation.rolling.DatasetRolling.dim
40+
computation.rolling.DatasetRolling.min_periods
41+
computation.rolling.DatasetRolling.obj
42+
computation.rolling.DatasetRolling.rollings
43+
computation.rolling.DatasetRolling.window
44+
45+
computation.weighted.DatasetWeighted.obj
46+
computation.weighted.DatasetWeighted.weights
4747

4848
Dataset.load_store
4949
Dataset.dump_to_store
@@ -70,22 +70,22 @@
7070
core.coordinates.DataArrayCoordinates.equals
7171
core.coordinates.DataArrayCoordinates.identical
7272

73-
core.rolling.DataArrayCoarsen.boundary
74-
core.rolling.DataArrayCoarsen.coord_func
75-
core.rolling.DataArrayCoarsen.obj
76-
core.rolling.DataArrayCoarsen.side
77-
core.rolling.DataArrayCoarsen.trim_excess
78-
core.rolling.DataArrayCoarsen.windows
79-
80-
core.rolling.DataArrayRolling.center
81-
core.rolling.DataArrayRolling.dim
82-
core.rolling.DataArrayRolling.min_periods
83-
core.rolling.DataArrayRolling.obj
84-
core.rolling.DataArrayRolling.window
85-
core.rolling.DataArrayRolling.window_labels
86-
87-
core.weighted.DataArrayWeighted.obj
88-
core.weighted.DataArrayWeighted.weights
73+
computation.rolling.DataArrayCoarsen.boundary
74+
computation.rolling.DataArrayCoarsen.coord_func
75+
computation.rolling.DataArrayCoarsen.obj
76+
computation.rolling.DataArrayCoarsen.side
77+
computation.rolling.DataArrayCoarsen.trim_excess
78+
computation.rolling.DataArrayCoarsen.windows
79+
80+
computation.rolling.DataArrayRolling.center
81+
computation.rolling.DataArrayRolling.dim
82+
computation.rolling.DataArrayRolling.min_periods
83+
computation.rolling.DataArrayRolling.obj
84+
computation.rolling.DataArrayRolling.window
85+
computation.rolling.DataArrayRolling.window_labels
86+
87+
computation.weighted.DataArrayWeighted.obj
88+
computation.weighted.DataArrayWeighted.weights
8989

9090
core.coordinates.DataTreeCoordinates.get
9191
core.coordinates.DataTreeCoordinates.items

doc/api.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ Grouper Objects
13341334
Rolling objects
13351335
===============
13361336

1337-
.. currentmodule:: xarray.core.rolling
1337+
.. currentmodule:: xarray.computation.rolling
13381338

13391339
Dataset
13401340
-------
@@ -1427,7 +1427,7 @@ DataArray
14271427
Exponential rolling objects
14281428
===========================
14291429

1430-
.. currentmodule:: xarray.core.rolling_exp
1430+
.. currentmodule:: xarray.computation.rolling_exp
14311431

14321432
.. autosummary::
14331433
:toctree: generated/
@@ -1439,7 +1439,7 @@ Exponential rolling objects
14391439
Weighted objects
14401440
================
14411441

1442-
.. currentmodule:: xarray.core.weighted
1442+
.. currentmodule:: xarray.computation.weighted
14431443

14441444
Dataset
14451445
-------
@@ -1591,6 +1591,8 @@ Tutorial
15911591

15921592
tutorial.open_dataset
15931593
tutorial.load_dataset
1594+
tutorial.open_datatree
1595+
tutorial.load_datatree
15941596

15951597
Testing
15961598
=======

doc/user-guide/data-structures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ specifying the nodes' relationship to one another as you create each one.
558558
The :py:class:`~xarray.DataTree` constructor takes:
559559

560560
- ``dataset``: The data that will be stored in this node, represented by a single
561-
:py:class:`xarray.Dataset`, or a named :py:class:`xarray.DataArray`.
561+
:py:class:`xarray.Dataset`.
562562
- ``children``: The various child nodes (if there are any), given as a mapping
563563
from string keys to :py:class:`~xarray.DataTree` objects.
564564
- ``name``: A string to use as the name of this node.

doc/user-guide/reshaping.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Reshaping via coarsen
305305

306306
Whilst :py:class:`~xarray.DataArray.coarsen` is normally used for reducing your data's resolution by applying a reduction function
307307
(see the :ref:`page on computation<compute.coarsen>`),
308-
it can also be used to reorganise your data without applying a computation via :py:meth:`~xarray.core.rolling.DataArrayCoarsen.construct`.
308+
it can also be used to reorganise your data without applying a computation via :py:meth:`~xarray.computation.rolling.DataArrayCoarsen.construct`.
309309

310310
Taking our example tutorial air temperature dataset over the Northern US
311311

@@ -324,7 +324,7 @@ Taking our example tutorial air temperature dataset over the Northern US
324324
@savefig pre_coarsening.png
325325
air.isel(time=0).plot(x="lon", y="lat")
326326
327-
we can split this up into sub-regions of size ``(9, 18)`` points using :py:meth:`~xarray.core.rolling.DataArrayCoarsen.construct`:
327+
we can split this up into sub-regions of size ``(9, 18)`` points using :py:meth:`~xarray.computation.rolling.DataArrayCoarsen.construct`:
328328

329329
.. ipython:: python
330330

doc/whats-new.rst

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ v2025.02.0 (unreleased)
2121

2222
New Features
2323
~~~~~~~~~~~~
24+
- Added :py:meth:`tutorial.open_datatree` and :py:meth:`tutorial.load_datatree`
25+
By `Eni Awowale <https://github.com/eni-awowale>`_.
2426
- Added :py:meth:`DataTree.filter_like` to conveniently restructure a DataTree like another DataTree (:issue:`10096`, :pull:`10097`).
2527
By `Kobe Vandelanotte <https://github.com/kobebryant432>`_.
2628
- Added :py:meth:`Coordinates.from_xindex` as convenience for creating a new :py:class:`Coordinates` object
@@ -32,11 +34,25 @@ New Features
3234
By `Justus Magin <https://github.com/keewis>`_.
3335
- Added experimental support for coordinate transforms (not ready for public use yet!) (:pull:`9543`)
3436
By `Benoit Bovy <https://github.com/benbovy>`_.
37+
- Similar to our :py:class:`numpy.datetime64` encoding path, automatically
38+
modify the units when an integer dtype is specified during eager cftime
39+
encoding, but the specified units would not allow for an exact round trip
40+
(:pull:`9498`). By `Spencer Clark <https://github.com/spencerkclark>`_.
3541
- Support reading to `GPU memory with Zarr <https://zarr.readthedocs.io/en/stable/user-guide/gpu.html>`_ (:pull:`10078`).
3642
By `Deepak Cherian <https://github.com/dcherian>`_.
3743

44+
Performance
45+
~~~~~~~~~~~
46+
- :py:meth:`DatasetGroupBy.first` and :py:meth:`DatasetGroupBy.last` can now use ``flox`` if available. (:issue:`9647`)
47+
By `Deepak Cherian <https://github.com/dcherian>`_.
48+
3849
Breaking changes
3950
~~~~~~~~~~~~~~~~
51+
- Rolled back code that would attempt to catch integer overflow when encoding
52+
times with small integer dtypes (:issue:`8542`), since it was inconsistent
53+
with xarray's handling of standard integers, and interfered with encoding
54+
times with small integer dtypes and missing values (:pull:`9498`). By
55+
`Spencer Clark <https://github.com/spencerkclark>`_.
4056
- Warn instead of raise if phony_dims are detected when using h5netcdf-backend and ``phony_dims=None`` (:issue:`10049`, :pull:`10058`)
4157
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
4258

@@ -62,6 +78,12 @@ Bug fixes
6278
- Fix DataArray().drop_attrs(deep=False) and add support for attrs to
6379
DataArray()._replace(). (:issue:`10027`, :pull:`10030`). By `Jan
6480
Haacker <https://github.com/j-haacker>`_.
81+
- Fix bug preventing encoding times with missing values with small integer
82+
dtype (:issue:`9134`, :pull:`9498`). By `Spencer Clark
83+
<https://github.com/spencerkclark>`_.
84+
- More robustly raise an error when lazily encoding times and an integer dtype
85+
is specified with units that do not allow for an exact round trip
86+
(:pull:`9498`). By `Spencer Clark <https://github.com/spencerkclark>`_.
6587
- Prevent false resolution change warnings from being emitted when decoding
6688
timedeltas encoded with floating point values, and make it clearer how to
6789
silence this warning message in the case that it is rightfully emitted
@@ -157,8 +179,6 @@ New Features
157179
:py:class:`pandas.DatetimeIndex` (:pull:`9965`). By `Spencer Clark
158180
<https://github.com/spencerkclark>`_ and `Kai Mühlbauer
159181
<https://github.com/kmuehlbauer>`_.
160-
- :py:meth:`DatasetGroupBy.first` and :py:meth:`DatasetGroupBy.last` can now use ``flox`` if available. (:issue:`9647`)
161-
By `Deepak Cherian <https://github.com/dcherian>`_.
162182

163183
Breaking changes
164184
~~~~~~~~~~~~~~~~
@@ -1473,7 +1493,7 @@ Bug fixes
14731493
special case ``NaT`` handling in :py:meth:`~core.accessor_dt.DatetimeAccessor.isocalendar`
14741494
(:issue:`7928`, :pull:`8084`).
14751495
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
1476-
- Fix :py:meth:`~core.rolling.DatasetRolling.construct` with stride on Datasets without indexes.
1496+
- Fix :py:meth:`~computation.rolling.DatasetRolling.construct` with stride on Datasets without indexes.
14771497
(:issue:`7021`, :pull:`7578`).
14781498
By `Amrest Chinkamol <https://github.com/p4perf4ce>`_ and `Michael Niklas <https://github.com/headtr1ck>`_.
14791499
- Calling plot with kwargs ``col``, ``row`` or ``hue`` no longer squeezes dimensions passed via these arguments
@@ -2488,8 +2508,8 @@ New Features
24882508

24892509
- The ``zarr`` backend is now able to read NCZarr.
24902510
By `Mattia Almansi <https://github.com/malmans2>`_.
2491-
- Add a weighted ``quantile`` method to :py:class:`~core.weighted.DatasetWeighted` and
2492-
:py:class:`~core.weighted.DataArrayWeighted` (:pull:`6059`).
2511+
- Add a weighted ``quantile`` method to :py:class:`.computation.weighted.DatasetWeighted` and
2512+
:py:class:`~computation.weighted.DataArrayWeighted` (:pull:`6059`).
24932513
By `Christian Jauvin <https://github.com/cjauvin>`_ and `David Huard <https://github.com/huard>`_.
24942514
- Add a ``create_index=True`` parameter to :py:meth:`Dataset.stack` and
24952515
:py:meth:`DataArray.stack` so that the creation of multi-indexes is optional
@@ -2871,7 +2891,7 @@ Thomas Nicholas, Tomas Chor, Tom Augspurger, Victor Negîrneac, Zachary Blackwoo
28712891

28722892
New Features
28732893
~~~~~~~~~~~~
2874-
- Add ``std``, ``var``, ``sum_of_squares`` to :py:class:`~core.weighted.DatasetWeighted` and :py:class:`~core.weighted.DataArrayWeighted`.
2894+
- Add ``std``, ``var``, ``sum_of_squares`` to :py:class:`~computation.weighted.DatasetWeighted` and :py:class:`~computation.weighted.DataArrayWeighted`.
28752895
By `Christian Jauvin <https://github.com/cjauvin>`_.
28762896
- Added a :py:func:`get_options` method to xarray's root namespace (:issue:`5698`, :pull:`5716`)
28772897
By `Pushkar Kopparla <https://github.com/pkopparla>`_.
@@ -3507,7 +3527,7 @@ New Features
35073527
By `Justus Magin <https://github.com/keewis>`_.
35083528
- Allow installing from git archives (:pull:`4897`).
35093529
By `Justus Magin <https://github.com/keewis>`_.
3510-
- :py:class:`~core.rolling.DataArrayCoarsen` and :py:class:`~core.rolling.DatasetCoarsen`
3530+
- :py:class:`~computation.rolling.DataArrayCoarsen` and :py:class:`~computation.rolling.DatasetCoarsen`
35113531
now implement a ``reduce`` method, enabling coarsening operations with custom
35123532
reduction functions (:issue:`3741`, :pull:`4939`).
35133533
By `Spencer Clark <https://github.com/spencerkclark>`_.
@@ -4352,8 +4372,8 @@ New Features
43524372
- :py:meth:`Dataset.quantile`, :py:meth:`DataArray.quantile` and ``GroupBy.quantile``
43534373
now work with dask Variables.
43544374
By `Deepak Cherian <https://github.com/dcherian>`_.
4355-
- Added the ``count`` reduction method to both :py:class:`~core.rolling.DatasetCoarsen`
4356-
and :py:class:`~core.rolling.DataArrayCoarsen` objects. (:pull:`3500`)
4375+
- Added the ``count`` reduction method to both :py:class:`~computation.rolling.DatasetCoarsen`
4376+
and :py:class:`~computation.rolling.DataArrayCoarsen` objects. (:pull:`3500`)
43574377
By `Deepak Cherian <https://github.com/dcherian>`_
43584378
- Add ``meta`` kwarg to :py:func:`~xarray.apply_ufunc`;
43594379
this is passed on to :py:func:`dask.array.blockwise`. (:pull:`3660`)
@@ -4705,7 +4725,7 @@ Bug fixes
47054725
- Fix error in concatenating unlabeled dimensions (:pull:`3362`).
47064726
By `Deepak Cherian <https://github.com/dcherian>`_.
47074727
- Warn if the ``dim`` kwarg is passed to rolling operations. This is redundant since a dimension is
4708-
specified when the :py:class:`~core.rolling.DatasetRolling` or :py:class:`~core.rolling.DataArrayRolling` object is created.
4728+
specified when the :py:class:`~computation.rolling.DatasetRolling` or :py:class:`~computation.rolling.DataArrayRolling` object is created.
47094729
(:pull:`3362`). By `Deepak Cherian <https://github.com/dcherian>`_.
47104730

47114731
Documentation
@@ -5936,7 +5956,7 @@ Enhancements
59365956
supplied list, returning a bool array. See :ref:`selecting values with isin`
59375957
for full details. Similar to the ``np.isin`` function.
59385958
By `Maximilian Roos <https://github.com/max-sixty>`_.
5939-
- Some speed improvement to construct :py:class:`~xarray.core.rolling.DataArrayRolling`
5959+
- Some speed improvement to construct :py:class:`~xarray.computation.rolling.DataArrayRolling`
59405960
object (:issue:`1993`)
59415961
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
59425962
- Handle variables with different values for ``missing_value`` and
@@ -6016,8 +6036,8 @@ Enhancements
60166036
NumPy. By `Stephan Hoyer <https://github.com/shoyer>`_.
60176037

60186038
- Improve :py:func:`~xarray.DataArray.rolling` logic.
6019-
:py:func:`~xarray.core.rolling.DataArrayRolling` object now supports
6020-
:py:func:`~xarray.core.rolling.DataArrayRolling.construct` method that returns a view
6039+
:py:func:`~xarray.computation.rolling.DataArrayRolling` object now supports
6040+
:py:func:`~xarray.computation.rolling.DataArrayRolling.construct` method that returns a view
60216041
of the DataArray / Dataset object with the rolling-window dimension added
60226042
to the last axis. This enables more flexible operation, such as strided
60236043
rolling, windowed rolling, ND-rolling, short-time FFT and convolution.
@@ -6791,7 +6811,7 @@ Enhancements
67916811
By `Stephan Hoyer <https://github.com/shoyer>`_ and
67926812
`Phillip J. Wolfram <https://github.com/pwolfram>`_.
67936813

6794-
- New aggregation on rolling objects :py:meth:`~core.rolling.DataArrayRolling.count`
6814+
- New aggregation on rolling objects :py:meth:`~computation.rolling.DataArrayRolling.count`
67956815
which providing a rolling count of valid values (:issue:`1138`).
67966816

67976817
Bug fixes

pyproject.toml

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,6 @@ dependencies = ["numpy>=1.24", "packaging>=23.2", "pandas>=2.1"]
3030
[project.optional-dependencies]
3131
accel = ["scipy", "bottleneck", "numbagg", "numba>=0.54", "flox", "opt_einsum"]
3232
complete = ["xarray[accel,etc,io,parallel,viz]"]
33-
dev = [
34-
"hypothesis",
35-
"jinja2",
36-
"mypy",
37-
"pre-commit",
38-
"pytest",
39-
"pytest-cov",
40-
"pytest-env",
41-
"pytest-mypy-plugins",
42-
"pytest-timeout",
43-
"pytest-xdist",
44-
"ruff>=0.8.0",
45-
"sphinx",
46-
"sphinx_autosummary_accessors",
47-
"xarray[complete,types]",
48-
]
4933
io = [
5034
"netCDF4",
5135
"h5netcdf",
@@ -71,11 +55,30 @@ types = [
7155
"types-pexpect",
7256
"types-psutil",
7357
"types-pycurl",
58+
"types-openpyxl",
7459
"types-python-dateutil",
7560
"types-pytz",
7661
"types-setuptools",
7762
]
7863

64+
[dependency-groups]
65+
dev = [
66+
"hypothesis",
67+
"jinja2",
68+
"mypy",
69+
"pre-commit",
70+
"pytest",
71+
"pytest-cov",
72+
"pytest-env",
73+
"pytest-mypy-plugins",
74+
"pytest-timeout",
75+
"pytest-xdist",
76+
"ruff>=0.8.0",
77+
"sphinx",
78+
"sphinx_autosummary_accessors",
79+
"xarray[complete,types]",
80+
]
81+
7982
[project.urls]
8083
Documentation = "https://docs.xarray.dev"
8184
SciPy2015-talk = "https://www.youtube.com/watch?v=X0pAhJgySxk"
@@ -99,10 +102,10 @@ fallback_version = "9999"
99102
[tool.coverage.run]
100103
omit = [
101104
"*/xarray/tests/*",
102-
"*/xarray/core/dask_array_compat.py",
103-
"*/xarray/core/npcompat.py",
104-
"*/xarray/core/pdcompat.py",
105-
"*/xarray/core/pycompat.py",
105+
"*/xarray/compat/dask_array_compat.py",
106+
"*/xarray/compat/npcompat.py",
107+
"*/xarray/compat/pdcompat.py",
108+
"*/xarray/namedarray/pycompat.py",
106109
"*/xarray/core/types.py",
107110
]
108111
source = ["xarray"]
@@ -166,9 +169,8 @@ check_untyped_defs = true
166169
module = [
167170
"xarray.core.accessor_dt",
168171
"xarray.core.accessor_str",
169-
"xarray.core.alignment",
170-
"xarray.core.computation",
171-
"xarray.core.rolling_exp",
172+
"xarray.structure.alignment",
173+
"xarray.computation.*",
172174
"xarray.indexes.*",
173175
"xarray.tests.*",
174176
]
@@ -359,7 +361,7 @@ markers = [
359361
"slow_hypothesis: slow hypothesis tests",
360362
]
361363
minversion = "7"
362-
python_files = "test_*.py"
364+
python_files = ["test_*.py"]
363365
testpaths = ["xarray/tests", "properties"]
364366

365367
[tool.aliases]

0 commit comments

Comments
 (0)