Skip to content

Commit 7c7a5f0

Browse files
committed
Merge branch 'main' into index-repr
2 parents b15aa07 + 491fb16 commit 7c7a5f0

27 files changed

+531
-140
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
hooks:
2020
- id: isort
2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v2.37.1
22+
rev: v2.37.2
2323
hooks:
2424
- id: pyupgrade
2525
args:
@@ -46,7 +46,7 @@ repos:
4646
# - id: velin
4747
# args: ["--write", "--compact"]
4848
- repo: https://github.com/pre-commit/mirrors-mypy
49-
rev: v0.961
49+
rev: v0.971
5050
hooks:
5151
- id: mypy
5252
# Copied from setup.cfg

doc/api.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ ndarray attributes
282282
DataArray.shape
283283
DataArray.size
284284
DataArray.dtype
285-
DataArray.nbytes
286285
DataArray.chunks
287286

288287

@@ -648,11 +647,23 @@ DataArray methods
648647
Coordinates objects
649648
===================
650649

650+
Dataset
651+
-------
652+
651653
.. autosummary::
652654
:toctree: generated/
653655

654-
core.coordinates.DataArrayCoordinates
655656
core.coordinates.DatasetCoordinates
657+
core.coordinates.DatasetCoordinates.dtypes
658+
659+
DataArray
660+
---------
661+
662+
.. autosummary::
663+
:toctree: generated/
664+
665+
core.coordinates.DataArrayCoordinates
666+
core.coordinates.DataArrayCoordinates.dtypes
656667

657668
Plotting
658669
========
@@ -736,6 +747,7 @@ Dataset
736747
DatasetGroupBy.all
737748
DatasetGroupBy.any
738749
DatasetGroupBy.count
750+
DatasetGroupBy.cumsum
739751
DatasetGroupBy.max
740752
DatasetGroupBy.mean
741753
DatasetGroupBy.median
@@ -765,6 +777,7 @@ DataArray
765777
DataArrayGroupBy.all
766778
DataArrayGroupBy.any
767779
DataArrayGroupBy.count
780+
DataArrayGroupBy.cumsum
768781
DataArrayGroupBy.max
769782
DataArrayGroupBy.mean
770783
DataArrayGroupBy.median
@@ -810,6 +823,7 @@ DataArray
810823
:toctree: generated/
811824

812825
DataArrayRolling
826+
DataArrayRolling.__iter__
813827
DataArrayRolling.construct
814828
DataArrayRolling.reduce
815829
DataArrayRolling.argmax

doc/user-guide/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ Chunk sizes may be specified in one of three ways when writing to a zarr store:
790790
The resulting chunks will be determined based on the order of the above list; dask
791791
chunks will be overridden by manually-specified chunks in the encoding argument,
792792
and the presence of either dask chunks or chunks in the ``encoding`` attribute will
793-
supercede the default chunking heuristics in zarr.
793+
supersede the default chunking heuristics in zarr.
794794

795795
Importantly, this logic applies to every array in the zarr store individually,
796796
including coordinate arrays. Therefore, if a dataset contains one or more dask

doc/user-guide/plotting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ Faceting here refers to splitting an array along one or two dimensions and
585585
plotting each group.
586586
Xarray's basic plotting is useful for plotting two dimensional arrays. What
587587
about three or four dimensional arrays? That's where facets become helpful.
588-
The general approach to plotting here is called “small multiples”, where the same kind of plot is repeated multiple times, and the specific use of small multiples to display the same relationship conditioned on one ore more other variables is often called a “trellis plot”.
588+
The general approach to plotting here is called “small multiples”, where the same kind of plot is repeated multiple times, and the specific use of small multiples to display the same relationship conditioned on one or more other variables is often called a “trellis plot”.
589589

590590
Consider the temperature data set. There are 4 observations per day for two
591591
years which makes for 2920 values along the time dimension.

doc/whats-new.rst

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,77 @@ What's New
1414
1515
np.random.seed(123456)
1616
17-
.. _whats-new.2022.06.0:
17+
.. _whats-new.2022.07.0:
1818

19-
v2022.06.0 (unreleased)
19+
v2022.07.0 (unreleased)
2020
-----------------------
2121

2222
New Features
2323
~~~~~~~~~~~~
2424

25-
- Add :py:meth:`Dataset.dtypes`, :py:meth:`DatasetCoordinates.dtypes`,
26-
:py:meth:`DataArrayCoordinates.dtypes` properties: Mapping from variable names to dtypes.
25+
26+
Breaking changes
27+
~~~~~~~~~~~~~~~~
28+
29+
30+
Deprecations
31+
~~~~~~~~~~~~
32+
33+
34+
Bug fixes
35+
~~~~~~~~~
36+
37+
- :py:attr:`DataArray.nbytes` now uses the ``nbytes`` property of the underlying array if available.
38+
By `Max Jones <https://github.com/maxrjones>`_.
39+
40+
Documentation
41+
~~~~~~~~~~~~~
42+
43+
44+
Internal Changes
45+
~~~~~~~~~~~~~~~~
46+
47+
48+
.. _whats-new.2022.06.0:
49+
50+
v2022.06.0 (July 21, 2022)
51+
--------------------------
52+
53+
This release brings a number of bug fixes and improvements, most notably a major internal
54+
refactor of the indexing functionality, the use of `flox`_ in ``groupby`` operations,
55+
and experimental support for the new Python `Array API standard <https://data-apis.org/array-api/latest/>`_.
56+
It also stops testing support for the abandoned PyNIO.
57+
58+
Much effort has been made to preserve backwards compatibility as part of the indexing refactor.
59+
We are aware of one `unfixed issue <https://github.com/pydata/xarray/issues/6607>`_.
60+
61+
Please also see the `whats-new.2022.06.0rc0`_ for a full list of changes.
62+
63+
Many thanks to our 18 contributors:
64+
Bane Sullivan, Deepak Cherian, Dimitri Papadopoulos Orfanos, Emma Marshall, Hauke Schulz, Illviljan,
65+
Julia Signell, Justus Magin, Keewis, Mathias Hauser, Michael Delgado, Mick, Pierre Manchon, Ray Bell,
66+
Spencer Clark, Stefaan Lippens, Tom White, Travis A. O'Brien,
67+
68+
New Features
69+
~~~~~~~~~~~~
70+
71+
- Add :py:attr:`Dataset.dtypes`, :py:attr:`core.coordinates.DatasetCoordinates.dtypes`,
72+
:py:attr:`core.coordinates.DataArrayCoordinates.dtypes` properties: Mapping from variable names to dtypes.
2773
(:pull:`6706`)
2874
By `Michael Niklas <https://github.com/headtr1ck>`_.
2975
- Initial typing support for :py:meth:`groupby`, :py:meth:`rolling`, :py:meth:`rolling_exp`,
3076
:py:meth:`coarsen`, :py:meth:`weighted`, :py:meth:`resample`,
3177
(:pull:`6702`)
3278
By `Michael Niklas <https://github.com/headtr1ck>`_.
33-
34-
Deprecations
35-
~~~~~~~~~~~~
36-
79+
- Experimental support for wrapping any array type that conforms to the python
80+
`array api standard <https://data-apis.org/array-api/latest/>`_. (:pull:`6804`)
81+
By `Tom White <https://github.com/tomwhite>`_.
3782

3883
Bug fixes
3984
~~~~~~~~~
4085

41-
- :py:meth:`xarray.save_mfdataset` now passes ``**kwargs`` on to ``to_netcdf``,
42-
allowing the ``encoding`` and ``unlimited_dims`` options with ``save_mfdataset``.
86+
- :py:meth:`save_mfdataset` now passes ``**kwargs`` on to :py:meth:`Dataset.to_netcdf`,
87+
allowing the ``encoding`` and ``unlimited_dims`` options with :py:meth:`save_mfdataset`.
4388
(:issue:`6684`)
4489
By `Travis A. O'Brien <https://github.com/taobrienlbl>`_.
4590
- Fix backend support of pydap versions <3.3.0 (:issue:`6648`, :pull:`6656`).
@@ -58,16 +103,12 @@ Bug fixes
58103
(:issue:`6739`, :pull:`6744`)
59104
By `Michael Niklas <https://github.com/headtr1ck>`_.
60105

61-
Documentation
62-
~~~~~~~~~~~~~
63-
64-
65106
Internal Changes
66107
~~~~~~~~~~~~~~~~
67108

68-
- :py:meth:`xarray.core.groupby`, :py:meth:`xarray.core.rolling`,
69-
:py:meth:`xarray.core.rolling_exp`, :py:meth:`xarray.core.weighted`
70-
and :py:meth:`xarray.core.resample` modules are no longer imported by default.
109+
- ``xarray.core.groupby``, ``xarray.core.rolling``,
110+
``xarray.core.rolling_exp``, ``xarray.core.weighted``
111+
and ``xarray.core.resample`` modules are no longer imported by default.
71112
(:pull:`6702`)
72113

73114
.. _whats-new.2022.06.0rc0:
@@ -120,13 +161,17 @@ New Features
120161
elements which trigger summarization rather than full repr in (numpy) array
121162
detailed views of the html repr (:pull:`6400`).
122163
By `Benoît Bovy <https://github.com/benbovy>`_.
123-
- Allow passing chunks in ``**kwargs`` form to :py:meth:`Dataset.chunk`, :py:meth:`DataArray.chunk`, and
164+
- Allow passing chunks in ``kwargs`` form to :py:meth:`Dataset.chunk`, :py:meth:`DataArray.chunk`, and
124165
:py:meth:`Variable.chunk`. (:pull:`6471`)
125166
By `Tom Nicholas <https://github.com/TomNicholas>`_.
167+
- Add :py:meth:`core.groupby.DatasetGroupBy.cumsum` and :py:meth:`core.groupby.DataArrayGroupBy.cumsum`.
168+
By `Vladislav Skripniuk <https://github.com/VladSkripniuk>`_ and `Deepak Cherian <https://github.com/dcherian>`_. (:pull:`3147`, :pull:`6525`, :issue:`3141`)
169+
- Expose `inline_array` kwarg from `dask.array.from_array` in :py:func:`open_dataset`, :py:meth:`Dataset.chunk`,
170+
:py:meth:`DataArray.chunk`, and :py:meth:`Variable.chunk`. (:pull:`6471`)
126171
- Expose the ``inline_array`` kwarg from :py:func:`dask.array.from_array` in :py:func:`open_dataset`,
127172
:py:meth:`Dataset.chunk`, :py:meth:`DataArray.chunk`, and :py:meth:`Variable.chunk`. (:pull:`6471`)
128173
By `Tom Nicholas <https://github.com/TomNicholas>`_.
129-
- :py:meth:`xr.polyval` now supports :py:class:`Dataset` and :py:class:`DataArray` args of any shape,
174+
- :py:func:`polyval` now supports :py:class:`Dataset` and :py:class:`DataArray` args of any shape,
130175
is faster and requires less memory. (:pull:`6548`)
131176
By `Michael Niklas <https://github.com/headtr1ck>`_.
132177
- Improved overall typing.
@@ -159,7 +204,7 @@ Breaking changes
159204
zarr 2.5 2.8
160205
=============== ===== ====
161206

162-
- The Dataset and DataArray ``rename*`` methods do not implicitly add or drop
207+
- The Dataset and DataArray ``rename```` methods do not implicitly add or drop
163208
indexes. (:pull:`5692`).
164209
By `Benoît Bovy <https://github.com/benbovy>`_.
165210
- Many arguments like ``keep_attrs``, ``axis``, and ``skipna`` are now keyword
@@ -172,11 +217,6 @@ Breaking changes
172217
(:pull:`6548`)
173218
By `Michael Niklas <https://github.com/headtr1ck>`_.
174219

175-
176-
Deprecations
177-
~~~~~~~~~~~~
178-
179-
180220
Bug fixes
181221
~~~~~~~~~
182222

@@ -204,16 +244,16 @@ Bug fixes
204244
By `Stan West <https://github.com/stanwest>`_.
205245
- Fix bug in :py:func:`where` when passing non-xarray objects with ``keep_attrs=True``. (:issue:`6444`, :pull:`6461`)
206246
By `Sam Levang <https://github.com/slevang>`_.
207-
- Allow passing both ``other`` and ``drop=True`` arguments to ``xr.DataArray.where``
208-
and ``xr.Dataset.where`` (:pull:`6466`, :pull:`6467`).
247+
- Allow passing both ``other`` and ``drop=True`` arguments to :py:meth:`DataArray.where`
248+
and :py:meth:`Dataset.where` (:pull:`6466`, :pull:`6467`).
209249
By `Michael Delgado <https://github.com/delgadom>`_.
210250
- Ensure dtype encoding attributes are not added or modified on variables that contain datetime-like
211251
values prior to being passed to :py:func:`xarray.conventions.decode_cf_variable` (:issue:`6453`,
212252
:pull:`6489`).
213253
By `Spencer Clark <https://github.com/spencerkclark>`_.
214254
- Dark themes are now properly detected in Furo-themed Sphinx documents (:issue:`6500`, :pull:`6501`).
215255
By `Kevin Paul <https://github.com/kmpaul>`_.
216-
- :py:meth:`isel` with `drop=True` works as intended with scalar :py:class:`DataArray` indexers.
256+
- :py:meth:`Dataset.isel`, :py:meth:`DataArray.isel` with `drop=True` works as intended with scalar :py:class:`DataArray` indexers.
217257
(:issue:`6554`, :pull:`6579`)
218258
By `Michael Niklas <https://github.com/headtr1ck>`_.
219259
- Fixed silent overflow issue when decoding times encoded with 32-bit and below
@@ -229,15 +269,17 @@ Documentation
229269
sizes. In particular, correct the syntax and replace lists with tuples in the
230270
examples. (:issue:`6333`, :pull:`6334`)
231271
By `Stan West <https://github.com/stanwest>`_.
232-
272+
- Mention that :py:meth:`DataArray.rename` can rename coordinates.
273+
(:issue:`5458`, :pull:`6665`)
274+
By `Michael Niklas <https://github.com/headtr1ck>`_.
233275
- Added examples to :py:meth:`Dataset.thin` and :py:meth:`DataArray.thin`
234276
By `Emma Marshall <https://github.com/e-marshall>`_.
235277

236278
Performance
237279
~~~~~~~~~~~
238280

239281
- GroupBy binary operations are now vectorized.
240-
Previously this involved looping over all groups. (:issue:`5804`,:pull:`6160`)
282+
Previously this involved looping over all groups. (:issue:`5804`, :pull:`6160`)
241283
By `Deepak Cherian <https://github.com/dcherian>`_.
242284
- Substantially improved GroupBy operations using `flox <https://flox.readthedocs.io/en/latest/>`_.
243285
This is auto-enabled when ``flox`` is installed. Use ``xr.set_options(use_flox=False)`` to use

xarray/backends/api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,22 @@ def open_mfdataset(
895895
combine_nested
896896
open_dataset
897897
898+
Examples
899+
--------
900+
A user might want to pass additional arguments into ``preprocess`` when
901+
applying some operation to many individual files that are being opened. One route
902+
to do this is through the use of ``functools.partial``.
903+
904+
>>> from functools import partial
905+
>>> def _preprocess(x, lon_bnds, lat_bnds):
906+
... return x.sel(lon=slice(*lon_bnds), lat=slice(*lat_bnds))
907+
...
908+
>>> lon_bnds, lat_bnds = (-110, -105), (40, 45)
909+
>>> partial_func = partial(_preprocess, lon_bnds=lon_bnds, lat_bnds=lat_bnds)
910+
>>> ds = xr.open_mfdataset(
911+
... "file_*.nc", concat_dim="time", preprocess=_preprocess
912+
... ) # doctest: +SKIP
913+
898914
References
899915
----------
900916

xarray/coding/calendar_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def convert_calendar(
9898
Notes
9999
-----
100100
Passing a value to `missing` is only usable if the source's time coordinate as an
101-
inferrable frequencies (see :py:func:`~xarray.infer_freq`) and is only appropriate
101+
inferable frequencies (see :py:func:`~xarray.infer_freq`) and is only appropriate
102102
if the target coordinate, generated from this frequency, has dates equivalent to the
103103
source. It is usually **not** appropriate to use this mode with:
104104

xarray/coding/cftime_offsets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ def date_range_like(source, calendar, use_cftime=None):
12001200
freq = infer_freq(source)
12011201
if freq is None:
12021202
raise ValueError(
1203-
"`date_range_like` was unable to generate a range as the source frequency was not inferrable."
1203+
"`date_range_like` was unable to generate a range as the source frequency was not inferable."
12041204
)
12051205

12061206
use_cftime = _should_cftime_be_used(source, calendar, use_cftime)

xarray/core/alignment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def find_matching_unindexed_dims(self) -> None:
285285
self.unindexed_dim_sizes = unindexed_dim_sizes
286286

287287
def assert_no_index_conflict(self) -> None:
288-
"""Check for uniqueness of both coordinate and dimension names accross all sets
288+
"""Check for uniqueness of both coordinate and dimension names across all sets
289289
of matching indexes.
290290
291291
We need to make sure that all indexes used for re-indexing or alignment

0 commit comments

Comments
 (0)