Skip to content

Commit 780ecb7

Browse files
authored
Merge branch 'main' into 0.20-whats-new
2 parents cd5e344 + 971b1f5 commit 780ecb7

Some content is hidden

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

53 files changed

+952
-422
lines changed

.github/workflows/upstream-dev-ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
shopt -s globstar
123123
python .github/workflows/parse_logs.py logs/**/*-log
124124
- name: Report failures
125-
uses: actions/github-script@v4.1
125+
uses: actions/github-script@v5
126126
with:
127127
github-token: ${{ secrets.GITHUB_TOKEN }}
128128
script: |
@@ -158,15 +158,15 @@ jobs:
158158
// If no issue is open, create a new issue,
159159
// else update the body of the existing issue.
160160
if (result.repository.issues.edges.length === 0) {
161-
github.issues.create({
161+
github.rest.issues.create({
162162
owner: variables.owner,
163163
repo: variables.name,
164164
body: issue_body,
165165
title: title,
166166
labels: [variables.label]
167167
})
168168
} else {
169-
github.issues.update({
169+
github.rest.issues.update({
170170
owner: variables.owner,
171171
repo: variables.name,
172172
issue_number: result.repository.issues.edges[0].node.number,

ci/min_deps_check.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,16 @@
2020
"isort",
2121
"mypy",
2222
"pip",
23+
"setuptools",
2324
"pytest",
2425
"pytest-cov",
2526
"pytest-env",
2627
"pytest-xdist",
2728
}
2829

29-
POLICY_MONTHS = {"python": 24, "numpy": 18, "setuptools": 42}
30+
POLICY_MONTHS = {"python": 24, "numpy": 18}
3031
POLICY_MONTHS_DEFAULT = 12
31-
POLICY_OVERRIDE = {
32-
# setuptools-scm doesn't work with setuptools < 36.7 (Nov 2017).
33-
# The conda metadata is malformed for setuptools < 38.4 (Jan 2018)
34-
# (it's missing a timestamp which prevents this tool from working).
35-
# setuptools < 40.4 (Sep 2018) from conda-forge cannot be installed into a py37
36-
# environment
37-
# TODO remove this special case and the matching note in installing.rst
38-
# after March 2022.
39-
"setuptools": (40, 4),
40-
}
32+
POLICY_OVERRIDE: Dict[str, Tuple[int, int]] = {}
4133
has_errors = False
4234

4335

ci/requirements/environment-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies:
3939
- setuptools
4040
- sparse
4141
- toolz
42+
- typing_extensions
4243
- zarr
4344
- pip:
4445
- numbagg

ci/requirements/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dependencies:
4343
- setuptools
4444
- sparse
4545
- toolz
46+
- typing_extensions
4647
- zarr
4748
- pip:
4849
- numbagg

ci/requirements/py37-bare-minimum.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ dependencies:
1010
- pytest-cov
1111
- pytest-env
1212
- pytest-xdist
13-
- numpy=1.17
14-
- pandas=1.0
15-
- setuptools=40.4
13+
- numpy=1.18
14+
- pandas=1.1
15+
- typing_extensions=3.7

ci/requirements/py37-min-all-deps.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,31 @@ dependencies:
1010
- python=3.7
1111
- boto3=1.13
1212
- bottleneck=1.3
13+
# cartopy 0.18 conflicts with pynio
1314
- cartopy=0.17
1415
- cdms2=3.1
1516
- cfgrib=0.9
16-
- cftime=1.1
17+
- cftime=1.2
1718
- coveralls
18-
- dask=2.24
19-
- distributed=2.24
19+
- dask=2.30
20+
- distributed=2.30
2021
- h5netcdf=0.8
2122
- h5py=2.10
23+
# hdf5 1.12 conflicts with h5py=2.10
2224
- hdf5=1.10
2325
- hypothesis
2426
- iris=2.4
25-
- lxml=4.5 # Optional dep of pydap
26-
- matplotlib-base=3.2
27+
- lxml=4.6 # Optional dep of pydap
28+
- matplotlib-base=3.3
2729
- nc-time-axis=1.2
2830
# netcdf follows a 1.major.minor[.patch] convention
2931
# (see https://github.com/Unidata/netcdf4-python/issues/1090)
3032
# bumping the netCDF4 version is currently blocked by #4491
3133
- netcdf4=1.5.3
32-
- numba=0.49
33-
- numpy=1.17
34-
- pandas=1.0
35-
- pint=0.15
34+
- numba=0.51
35+
- numpy=1.18
36+
- pandas=1.1
37+
- pint=0.16
3638
- pip
3739
- pseudonetcdf=3.1
3840
- pydap=3.2
@@ -42,11 +44,11 @@ dependencies:
4244
- pytest-env
4345
- pytest-xdist
4446
- rasterio=1.1
45-
- scipy=1.4
46-
- seaborn=0.10
47-
- setuptools=40.4
48-
- sparse=0.8
49-
- toolz=0.10
50-
- zarr=2.4
47+
- scipy=1.5
48+
- seaborn=0.11
49+
- sparse=0.11
50+
- toolz=0.11
51+
- typing_extensions=3.7
52+
- zarr=2.5
5153
- pip:
5254
- numbagg==0.1

ci/requirements/py38-all-but-dask.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies:
3939
- setuptools
4040
- sparse
4141
- toolz
42+
- typing_extensions
4243
- zarr
4344
- pip:
4445
- numbagg

doc/api.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Attributes
6565
Dataset.indexes
6666
Dataset.get_index
6767
Dataset.chunks
68+
Dataset.chunksizes
6869
Dataset.nbytes
6970

7071
Dictionary interface
@@ -271,6 +272,7 @@ Attributes
271272
DataArray.encoding
272273
DataArray.indexes
273274
DataArray.get_index
275+
DataArray.chunksizes
274276

275277
**ndarray attributes**:
276278
:py:attr:`~DataArray.ndim`
@@ -779,12 +781,18 @@ Weighted objects
779781

780782
core.weighted.DataArrayWeighted
781783
core.weighted.DataArrayWeighted.mean
784+
core.weighted.DataArrayWeighted.std
782785
core.weighted.DataArrayWeighted.sum
786+
core.weighted.DataArrayWeighted.sum_of_squares
783787
core.weighted.DataArrayWeighted.sum_of_weights
788+
core.weighted.DataArrayWeighted.var
784789
core.weighted.DatasetWeighted
785790
core.weighted.DatasetWeighted.mean
791+
core.weighted.DatasetWeighted.std
786792
core.weighted.DatasetWeighted.sum
793+
core.weighted.DatasetWeighted.sum_of_squares
787794
core.weighted.DatasetWeighted.sum_of_weights
795+
core.weighted.DatasetWeighted.var
788796

789797

790798
Coarsen objects

doc/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,18 @@
147147
"matplotlib colormap name": ":doc:`matplotlib colormap name <matplotlib:gallery/color/colormap_reference>`",
148148
"matplotlib axes object": ":py:class:`matplotlib axes object <matplotlib.axes.Axes>`",
149149
"colormap": ":py:class:`colormap <matplotlib.colors.Colormap>`",
150-
# objects without namespace
150+
# objects without namespace: xarray
151151
"DataArray": "~xarray.DataArray",
152152
"Dataset": "~xarray.Dataset",
153153
"Variable": "~xarray.Variable",
154+
"DatasetGroupBy": "~xarray.core.groupby.DatasetGroupBy",
155+
"DataArrayGroupBy": "~xarray.core.groupby.DataArrayGroupBy",
156+
# objects without namespace: numpy
154157
"ndarray": "~numpy.ndarray",
155158
"MaskedArray": "~numpy.ma.MaskedArray",
156159
"dtype": "~numpy.dtype",
157160
"ComplexWarning": "~numpy.ComplexWarning",
161+
# objects without namespace: pandas
158162
"Index": "~pandas.Index",
159163
"MultiIndex": "~pandas.MultiIndex",
160164
"CategoricalIndex": "~pandas.CategoricalIndex",

doc/ecosystem.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Geosciences
3737
- `Spyfit <https://spyfit.readthedocs.io/en/master/>`_: FTIR spectroscopy of the atmosphere
3838
- `windspharm <https://ajdawson.github.io/windspharm/index.html>`_: Spherical
3939
harmonic wind analysis in Python.
40+
- `wradlib <https://wradlib.org/>`_: An Open Source Library for Weather Radar Data Processing.
4041
- `wrf-python <https://wrf-python.readthedocs.io/>`_: A collection of diagnostic and interpolation routines for use with output of the Weather Research and Forecasting (WRF-ARW) Model.
4142
- `xarray-simlab <https://xarray-simlab.readthedocs.io>`_: xarray extension for computer model simulations.
4243
- `xarray-spatial <https://makepath.github.io/xarray-spatial>`_: Numba-accelerated raster-based spatial processing tools (NDVI, curvature, zonal-statistics, proximity, hillshading, viewshed, etc.)

doc/getting-started-guide/installing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Required dependencies
77
---------------------
88

99
- Python (3.7 or later)
10-
- setuptools (40.4 or later)
10+
- `importlib_metadata <https://importlib_metadata.readthedocs.io/>`__ (1.4 or later, Python 3.7 only)
11+
- ``typing_extensions`` (3.7 or later, Python 3.7 only)
1112
- `numpy <http://www.numpy.org/>`__ (1.17 or later)
1213
- `pandas <http://pandas.pydata.org/>`__ (1.0 or later)
1314

@@ -92,7 +93,6 @@ dependencies:
9293

9394
- **Python:** 24 months
9495
(`NEP-29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_)
95-
- **setuptools:** 42 months (but no older than 40.4)
9696
- **numpy:** 18 months
9797
(`NEP-29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_)
9898
- **all other libraries:** 12 months

doc/user-guide/computation.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Weighted array reductions
263263

264264
:py:class:`DataArray` and :py:class:`Dataset` objects include :py:meth:`DataArray.weighted`
265265
and :py:meth:`Dataset.weighted` array reduction methods. They currently
266-
support weighted ``sum`` and weighted ``mean``.
266+
support weighted ``sum``, ``mean``, ``std`` and ``var``.
267267

268268
.. ipython:: python
269269
@@ -298,13 +298,27 @@ The weighted sum corresponds to:
298298
weighted_sum = (prec * weights).sum()
299299
weighted_sum
300300
301-
and the weighted mean to:
301+
the weighted mean to:
302302

303303
.. ipython:: python
304304
305305
weighted_mean = weighted_sum / weights.sum()
306306
weighted_mean
307307
308+
the weighted variance to:
309+
310+
.. ipython:: python
311+
312+
weighted_var = weighted_prec.sum_of_squares() / weights.sum()
313+
weighted_var
314+
315+
and the weighted standard deviation to:
316+
317+
.. ipython:: python
318+
319+
weighted_std = np.sqrt(weighted_var)
320+
weighted_std
321+
308322
However, the functions also take missing values in the data into account:
309323

310324
.. ipython:: python
@@ -327,7 +341,7 @@ If the weights add up to to 0, ``sum`` returns 0:
327341
328342
data.weighted(weights).sum()
329343
330-
and ``mean`` returns ``NaN``:
344+
and ``mean``, ``std`` and ``var`` return ``NaN``:
331345

332346
.. ipython:: python
333347

doc/whats-new.rst

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,35 @@ New Features
3838
`Nathan Lis <https://github.com/wxman22>`_.
3939
- Histogram plots are set with a title displaying the scalar coords if any, similarly to the other plots (:issue:`5791`, :pull:`5792`).
4040
By `Maxime Liquet <https://github.com/maximlt>`_.
41+
- Slice plots display the coords units in the same way as x/y/colorbar labels (:pull:`5847`).
42+
By `Victor Negîrneac <https://github.com/caenrigen>`_.
43+
- Added a new :py:attr:`Dataset.chunksizes`, :py:attr:`DataArray.chunksizes`, and :py:attr:`Variable.chunksizes`
44+
property, which will always return a mapping from dimension names to chunking pattern along that dimension,
45+
regardless of whether the object is a Dataset, DataArray, or Variable. (:issue:`5846`, :pull:`5900`)
46+
By `Tom Nicholas <https://github.com/TomNicholas>`_.
4147

4248
Breaking changes
4349
~~~~~~~~~~~~~~~~
4450
- The minimum versions of some dependencies were changed:
4551

46-
============ ====== ====
47-
Package Old New
48-
============ ====== ====
49-
dask 2.15 2.24
50-
distributed 2.15 2.24
51-
============ ====== ====
52+
=============== ====== ====
53+
Package Old New
54+
=============== ====== ====
55+
cftime 1.1 1.2
56+
dask 2.15 2.30
57+
distributed 2.15 2.30
58+
lxml 4.5 4.6
59+
matplotlib-base 3.2 3.3
60+
numba 0.49 0.51
61+
numpy 1.17 1.18
62+
pandas 1.0 1.1
63+
pint 0.15 0.16
64+
scipy 1.4 1.5
65+
seaborn 0.10 0.11
66+
sparse 0.8 0.11
67+
toolz 0.10 0.11
68+
zarr 2.4 2.5
69+
=============== ====== ====
5270

5371
- The ``__repr__`` of a :py:class:`xarray.Dataset`'s ``coords`` and ``data_vars``
5472
ignore ``xarray.set_option(display_max_rows=...)`` and show the full output
@@ -76,17 +94,23 @@ Bug fixes
7694
- Fixed performance bug where ``cftime`` import attempted within various core operations if ``cftime`` not
7795
installed (:pull:`5640`).
7896
By `Luke Sewell <https://github.com/lusewell>`_
97+
- Fixed bug when combining named DataArrays using :py:func:`combine_by_coords`. (:pull:`5834`).
98+
By `Tom Nicholas <https://github.com/TomNicholas>`_.
7999
- When a custom engine was used in :py:func:`~xarray.open_dataset` the engine
80100
wasn't initialized properly, causing missing argument errors or inconsistent
81101
method signatures. (:pull:`5684`)
82102
By `Jimmy Westling <https://github.com/illviljan>`_.
83103
- Numbers are properly formatted in a plot's title (:issue:`5788`, :pull:`5789`).
84104
By `Maxime Liquet <https://github.com/maximlt>`_.
105+
- Faceted plots will no longer raise a `pint.UnitStrippedWarning` when a `pint.Quantity` array is plotted,
106+
and will correctly display the units of the data in the colorbar (if there is one) (:pull:`5886`).
107+
By `Tom Nicholas <https://github.com/TomNicholas>`_.
85108
- With backends, check for path-like objects rather than ``pathlib.Path``
86109
type, use ``os.fspath`` (:pull:`5879`).
87110
By `Mike Taves <https://github.com/mwtoews>`_.
88111
- ``open_mfdataset()`` now accepts a single ``pathlib.Path`` object (:issue: `5881`).
89112
By `Panos Mavrogiorgos <https://github.com/pmav99>`_.
113+
- Improved performance of :py:meth:`Dataset.unstack` (:pull:`5906`). By `Tom Augspurger <https://github.com/TomAugspurger>`_.
90114

91115
Documentation
92116
~~~~~~~~~~~~~
@@ -122,6 +146,10 @@ Internal Changes
122146
By `Tom Nicholas <https://github.com/TomNicholas>`_.
123147
- Add an ASV benchmark CI and improve performance of the benchmarks (:pull:`5796`)
124148
By `Jimmy Westling <https://github.com/illviljan>`_.
149+
- Use ``importlib`` to replace functionality of ``pkg_resources`` such
150+
as version setting and loading of resources. (:pull:`5845`).
151+
By `Martin K. Scherer <https://github.com/marscher>`_.
152+
125153

126154
.. _whats-new.0.19.0:
127155

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
numpy >= 1.17
66
pandas >= 1.0
77
setuptools >= 40.4
8-
typing-extensions >= 3.10
8+
typing-extensions >= 3.7

setup.cfg

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ zip_safe = False # https://mypy.readthedocs.io/en/latest/installed_packages.htm
7676
include_package_data = True
7777
python_requires = >=3.7
7878
install_requires =
79-
numpy >= 1.17
80-
pandas >= 1.0
81-
setuptools >= 40.4 # For pkg_resources
79+
numpy >= 1.18
80+
pandas >= 1.1
81+
importlib-metadata; python_version < '3.8'
82+
typing_extensions >= 3.7; python_version < '3.8'
8283

8384
[options.extras_require]
8485
io =

xarray/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pkg_resources
2-
31
from . import testing, tutorial, ufuncs
42
from .backends.api import (
53
load_dataarray,
@@ -30,7 +28,13 @@
3028
from .util.print_versions import show_versions
3129

3230
try:
33-
__version__ = pkg_resources.get_distribution("xarray").version
31+
from importlib.metadata import version as _version
32+
except ImportError:
33+
# if the fallback library is missing, we are doomed.
34+
from importlib_metadata import version as _version # type: ignore[no-redef]
35+
36+
try:
37+
__version__ = _version("xarray")
3438
except Exception:
3539
# Local copy or not installed with setuptools.
3640
# Disable minimum version checks on downstream libraries.

0 commit comments

Comments
 (0)