Skip to content

Commit 6a6ba1b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix/allow_lazy
* upstream/master: (27 commits) drop_vars; deprecate drop for variables (pydata#3475) uamiv test using only raw uamiv variables (pydata#3485) Optimize dask array equality checks. (pydata#3453) Propagate indexes in DataArray binary operations. (pydata#3481) python 3.8 tests (pydata#3477) __dask_tokenize__ (pydata#3446) Type check sentinel values (pydata#3472) Fix typo in docstring (pydata#3474) fix test suite warnings re `drop` (pydata#3460) Fix integrate docs (pydata#3469) Fix leap year condition in monthly means example (pydata#3464) Hypothesis tests for roundtrip to & from pandas (pydata#3285) unpin cftime (pydata#3463) Cleanup whatsnew (pydata#3462) enable xr.ALL_DIMS in xr.dot (pydata#3424) Merge stable into master (pydata#3457) upgrade black verison to 19.10b0 (pydata#3456) Remove outdated code related to compatibility with netcdftime (pydata#3450) Remove deprecated behavior from dataset.drop docstring (pydata#3451) jupyterlab dark theme (pydata#3443) ...
2 parents aadd922 + 0e8debf commit 6a6ba1b

Some content is hidden

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

65 files changed

+2608
-674
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ prune doc/generated
66
global-exclude .DS_Store
77
include versioneer.py
88
include xarray/_version.py
9+
recursive-include xarray/static *

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,7 @@ under a "3-clause BSD" license:
138138
xarray also bundles portions of CPython, which is available under the "Python
139139
Software Foundation License" in xarray/core/pycompat.py.
140140

141+
xarray uses icons from the icomoon package (free version), which is
142+
available under the "CC BY 4.0" license.
143+
141144
The full text of these licenses are included in the licenses directory.

azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
conda_env: py36
1919
py37:
2020
conda_env: py37
21+
py38:
22+
conda_env: py38
2123
py37-upstream-dev:
2224
conda_env: py37
2325
upstream_dev: true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- cartopy=0.17
1414
- cdms2=3.1
1515
- cfgrib=0.9
16-
- cftime=1.0.3 # FIXME need 1.0.5 (not released yet); 1.0.4 is broken
16+
- cftime=1.0
1717
- coveralls
1818
- dask=1.2
1919
- distributed=1.27

ci/requirements/py36.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
- cartopy
1010
- cdms2
1111
- cfgrib
12-
- cftime<1.0.4 # FIXME need 1.0.5 (not released yet); 1.0.4 is broken
12+
- cftime
1313
- coveralls
1414
- dask
1515
- distributed

ci/requirements/py37-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
- cartopy
1010
# - cdms2 # Not available on Windows
1111
# - cfgrib # Causes Python interpreter crash on Windows
12-
- cftime<1.0.4 # FIXME need 1.0.5 (not released yet); 1.0.4 is broken
12+
- cftime
1313
- coveralls
1414
- dask
1515
- distributed

ci/requirements/py37.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99
- cartopy
1010
- cdms2
1111
- cfgrib
12-
- cftime<1.0.4 # FIXME need 1.0.5 (not released yet); 1.0.4 is broken
12+
- cftime
1313
- coveralls
1414
- dask
1515
- distributed

ci/requirements/py38.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: xarray-tests
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python=3.8
6+
- pip
7+
- pip:
8+
- coveralls
9+
- dask
10+
- distributed
11+
- numpy
12+
- pandas
13+
- pytest
14+
- pytest-cov
15+
- pytest-env

doc/data-structures.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,14 @@ methods (like pandas) for transforming datasets into new objects.
393393

394394
For removing variables, you can select and drop an explicit list of
395395
variables by indexing with a list of names or using the
396-
:py:meth:`~xarray.Dataset.drop` methods to return a new ``Dataset``. These
396+
:py:meth:`~xarray.Dataset.drop_vars` methods to return a new ``Dataset``. These
397397
operations keep around coordinates:
398398

399399
.. ipython:: python
400400
401401
ds[['temperature']]
402402
ds[['temperature', 'temperature_double']]
403-
ds.drop('temperature')
403+
ds.drop_vars('temperature')
404404
405405
To remove a dimension, you can use :py:meth:`~xarray.Dataset.drop_dims` method.
406406
Any variables using that dimension are dropped:
@@ -411,7 +411,7 @@ Any variables using that dimension are dropped:
411411
412412
As an alternate to dictionary-like modifications, you can use
413413
:py:meth:`~xarray.Dataset.assign` and :py:meth:`~xarray.Dataset.assign_coords`.
414-
These methods return a new dataset with additional (or replaced) or values:
414+
These methods return a new dataset with additional (or replaced) values:
415415

416416
.. ipython:: python
417417
@@ -420,7 +420,7 @@ These methods return a new dataset with additional (or replaced) or values:
420420
There is also the :py:meth:`~xarray.Dataset.pipe` method that allows you to use
421421
a method call with an external function (e.g., ``ds.pipe(func)``) instead of
422422
simply calling it (e.g., ``func(ds)``). This allows you to write pipelines for
423-
transforming you data (using "method chaining") instead of writing hard to
423+
transforming your data (using "method chaining") instead of writing hard to
424424
follow nested function calls:
425425

426426
.. ipython:: python

doc/examples/monthly-means.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ the ``calendar.month_range`` function.
8383
8484
for i, (month, year) in enumerate(zip(time.month, time.year)):
8585
month_length[i] = cal_days[month]
86-
if leap_year(year, calendar=calendar):
86+
if leap_year(year, calendar=calendar) and month == 2:
8787
month_length[i] += 1
8888
return month_length
8989

doc/examples/multidimensional-coords.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function to specify the output coordinates of the group.
107107
lat_center = np.arange(1, 90, 2)
108108
# group according to those bins and take the mean
109109
Tair_lat_mean = (ds.Tair.groupby_bins('xc', lat_bins, labels=lat_center)
110-
.mean(xr.ALL_DIMS))
110+
.mean(...))
111111
# plot the result
112112
@savefig xarray_multidimensional_coords_14_1.png width=5in
113113
Tair_lat_mean.plot();

doc/groupby.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ dimensions *other than* the provided one:
116116

117117
.. ipython:: python
118118
119-
ds.groupby('x').std(xr.ALL_DIMS)
119+
ds.groupby('x').std(...)
120+
121+
.. note::
122+
123+
We use an ellipsis (`...`) here to indicate we want to reduce over all
124+
other dimensions
125+
120126

121127
First and last
122128
~~~~~~~~~~~~~~
@@ -127,7 +133,7 @@ values for group along the grouped dimension:
127133

128134
.. ipython:: python
129135
130-
ds.groupby('letters').first(xr.ALL_DIMS)
136+
ds.groupby('letters').first(...)
131137
132138
By default, they skip missing values (control this with ``skipna``).
133139

@@ -142,7 +148,7 @@ coordinates. For example:
142148

143149
.. ipython:: python
144150
145-
alt = arr.groupby('letters').mean(xr.ALL_DIMS)
151+
alt = arr.groupby('letters').mean(...)
146152
alt
147153
ds.groupby('letters') - alt
148154
@@ -195,7 +201,7 @@ __ http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html#_two_dimen
195201
'lat': (['ny','nx'], [[10,10],[20,20]] ),},
196202
dims=['ny','nx'])
197203
da
198-
da.groupby('lon').sum(xr.ALL_DIMS)
204+
da.groupby('lon').sum(...)
199205
da.groupby('lon').apply(lambda x: x - x.mean(), shortcut=False)
200206
201207
Because multidimensional groups have the ability to generate a very large
@@ -213,4 +219,4 @@ applying your function, and then unstacking the result:
213219
.. ipython:: python
214220
215221
stacked = da.stack(gridcell=['ny', 'nx'])
216-
stacked.groupby('gridcell').sum(xr.ALL_DIMS).unstack('gridcell')
222+
stacked.groupby('gridcell').sum(...).unstack('gridcell')

doc/indexing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,14 @@ Using indexing to *assign* values to a subset of dataset (e.g.,
232232
Dropping labels and dimensions
233233
------------------------------
234234

235-
The :py:meth:`~xarray.Dataset.drop` method returns a new object with the listed
235+
The :py:meth:`~xarray.Dataset.drop_sel` method returns a new object with the listed
236236
index labels along a dimension dropped:
237237

238238
.. ipython:: python
239239
240-
ds.drop(space=['IN', 'IL'])
240+
ds.drop_sel(space=['IN', 'IL'])
241241
242-
``drop`` is both a ``Dataset`` and ``DataArray`` method.
242+
``drop_sel`` is both a ``Dataset`` and ``DataArray`` method.
243243

244244
Use :py:meth:`~xarray.Dataset.drop_dims` to drop a full dimension from a Dataset.
245245
Any variables with these dimensions are also dropped:

doc/reshaping.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ Reordering dimensions
1818
---------------------
1919

2020
To reorder dimensions on a :py:class:`~xarray.DataArray` or across all variables
21-
on a :py:class:`~xarray.Dataset`, use :py:meth:`~xarray.DataArray.transpose`:
21+
on a :py:class:`~xarray.Dataset`, use :py:meth:`~xarray.DataArray.transpose`. An
22+
ellipsis (`...`) can be use to represent all other dimensions:
2223

2324
.. ipython:: python
2425
2526
ds = xr.Dataset({'foo': (('x', 'y', 'z'), [[[42]]]), 'bar': (('y', 'z'), [[24]])})
2627
ds.transpose('y', 'z', 'x')
28+
ds.transpose(..., 'x') # equivalent
2729
ds.transpose() # reverses all dimensions
2830
2931
Expand and squeeze dimensions

doc/terminology.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Terminology
1515

1616
----
1717

18-
**Variable:** A `NetCDF-like variable <https://www.unidata.ucar.edu/software/netcdf/netcdf/Variables.html>`_ consisting of dimensions, data, and attributes which describe a single array. The main functional difference between variables and numpy arrays is that numerical operations on variables implement array broadcasting by dimension name. Each ``DataArray`` has an underlying variable that can be accessed via ``arr.variable``. However, a variable is not fully described outside of either a ``Dataset`` or a ``DataArray``.
18+
**Variable:** A `NetCDF-like variable <https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_data_set_components.html#variables>`_ consisting of dimensions, data, and attributes which describe a single array. The main functional difference between variables and numpy arrays is that numerical operations on variables implement array broadcasting by dimension name. Each ``DataArray`` has an underlying variable that can be accessed via ``arr.variable``. However, a variable is not fully described outside of either a ``Dataset`` or a ``DataArray``.
1919

2020
.. note::
2121

@@ -39,4 +39,4 @@ Terminology
3939

4040
----
4141

42-
**Index:** An *index* is a data structure optimized for efficient selecting and slicing of an associated array. Xarray creates indexes for dimension coordinates so that operations along dimensions are fast, while non-dimension coordinates are not indexed. Under the hood, indexes are implemented as :py:class:`pandas.Index` objects. The index associated with dimension name ``x`` can be retrieved by ``arr.indexes[x]``. By construction, ``len(arr.dims) == len(arr.indexes)``
42+
**Index:** An *index* is a data structure optimized for efficient selecting and slicing of an associated array. Xarray creates indexes for dimension coordinates so that operations along dimensions are fast, while non-dimension coordinates are not indexed. Under the hood, indexes are implemented as :py:class:`pandas.Index` objects. The index associated with dimension name ``x`` can be retrieved by ``arr.indexes[x]``. By construction, ``len(arr.dims) == len(arr.indexes)``

doc/whats-new.rst

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,110 @@ v0.14.1 (unreleased)
2121
Breaking changes
2222
~~~~~~~~~~~~~~~~
2323

24-
- Minimum cftime version is now 1.0.3. By `Deepak Cherian <https://github.com/dcherian>`_.
25-
26-
New Features
27-
~~~~~~~~~~~~
28-
- Added integration tests against `pint <https://pint.readthedocs.io/>`_.
29-
(:pull:`3238`) by `Justus Magin <https://github.com/keewis>`_.
24+
- Broken compatibility with cftime < 1.0.3.
25+
By `Deepak Cherian <https://github.com/dcherian>`_.
3026

3127
.. note::
3228

33-
At the moment of writing, these tests *as well as the ability to use pint in general*
34-
require `a highly experimental version of pint
35-
<https://github.com/andrewgsavage/pint/pull/6>`_ (install with
36-
``pip install git+https://github.com/andrewgsavage/pint.git@refs/pull/6/head)``.
37-
Even with it, interaction with non-numpy array libraries, e.g. dask or sparse, is broken.
29+
cftime version 1.0.4 is broken
30+
(`cftime/126 <https://github.com/Unidata/cftime/issues/126>`_);
31+
please use version 1.0.4.2 instead.
32+
33+
- All leftover support for dates from non-standard calendars through netcdftime, the
34+
module included in versions of netCDF4 prior to 1.4 that eventually became the
35+
cftime package, has been removed in favor of relying solely on the standalone
36+
cftime package (:pull:`3450`).
37+
By `Spencer Clark <https://github.com/spencerkclark>`_.
38+
39+
New Features
40+
~~~~~~~~~~~~
41+
- :py:meth:`Dataset.drop_sel` & :py:meth:`DataArray.drop_sel` have been added for dropping labels.
42+
:py:meth:`Dataset.drop_vars` & :py:meth:`DataArray.drop_vars` have been added for
43+
dropping variables (including coordinates). The existing ``drop`` methods remain as a backward compatible
44+
option for dropping either lables or variables, but using the more specific methods is encouraged.
45+
(:pull:`3475`)
46+
By `Maximilian Roos <https://github.com/max-sixty>`_
47+
- :py:meth:`Dataset.transpose` and :py:meth:`DataArray.transpose` now support an ellipsis (`...`)
48+
to represent all 'other' dimensions. For example, to move one dimension to the front,
49+
use `.transpose('x', ...)`. (:pull:`3421`)
50+
By `Maximilian Roos <https://github.com/max-sixty>`_
51+
- Changed `xr.ALL_DIMS` to equal python's `Ellipsis` (`...`), and changed internal usages to use
52+
`...` directly. As before, you can use this to instruct a `groupby` operation
53+
to reduce over all dimensions. While we have no plans to remove `xr.ALL_DIMS`, we suggest
54+
using `...`. (:pull:`3418`)
55+
By `Maximilian Roos <https://github.com/max-sixty>`_
56+
- :py:func:`~xarray.dot`, and :py:func:`~xarray.DataArray.dot` now support the
57+
`dims=...` option to sum over the union of dimensions of all input arrays
58+
(:issue:`3423`) by `Mathias Hauser <https://github.com/mathause>`_.
59+
- Added new :py:meth:`Dataset._repr_html_` and :py:meth:`DataArray._repr_html_` to improve
60+
representation of objects in jupyter. By default this feature is turned off
61+
for now. Enable it with :py:meth:`xarray.set_options(display_style="html")`.
62+
(:pull:`3425`) by `Benoit Bovy <https://github.com/benbovy>`_ and
63+
`Julia Signell <https://github.com/jsignell>`_.
64+
- Implement `dask deterministic hashing
65+
<https://docs.dask.org/en/latest/custom-collections.html#deterministic-hashing>`_
66+
for xarray objects. Note that xarray objects with a dask.array backend already used
67+
deterministic hashing in previous releases; this change implements it when whole
68+
xarray objects are embedded in a dask graph, e.g. when :meth:`DataArray.map` is
69+
invoked. (:issue:`3378`, :pull:`3446`)
70+
By `Deepak Cherian <https://github.com/dcherian>`_ and
71+
`Guido Imperiale <https://github.com/crusaderky>`_.
3872

3973
Bug fixes
4074
~~~~~~~~~
4175
- Fix regression introduced in v0.14.0 that would cause a crash if dask is installed
4276
but cloudpickle isn't (:issue:`3401`) by `Rhys Doyle <https://github.com/rdoyle45>`_
43-
44-
- Sync with cftime by removing `dayofwk=-1` for cftime>=1.0.4.
77+
- Fix grouping over variables with NaNs. (:issue:`2383`, :pull:`3406`).
78+
By `Deepak Cherian <https://github.com/dcherian>`_.
79+
- Use dask names to compare dask objects prior to comparing values after computation.
80+
(:issue:`3068`, :issue:`3311`, :issue:`3454`, :pull:`3453`).
81+
By `Deepak Cherian <https://github.com/dcherian>`_.
82+
- Sync with cftime by removing `dayofwk=-1` for cftime>=1.0.4.
4583
By `Anderson Banihirwe <https://github.com/andersy005>`_.
4684

4785
- Rolling reduction operations now longer compute dask arrays by default. (:issue:`3161`).
4886
In addition, the ``allow_lazy`` kwarg to ``reduce`` is deprecated.
4987
By `Deepak Cherian <https://github.com/dcherian>`_.
88+
- Fix :py:meth:`xarray.core.groupby.DataArrayGroupBy.reduce` and
89+
:py:meth:`xarray.core.groupby.DatasetGroupBy.reduce` when reducing over multiple dimensions.
90+
(:issue:`3402`). By `Deepak Cherian <https://github.com/dcherian/>`_
5091

5192
Documentation
5293
~~~~~~~~~~~~~
53-
94+
- Fix leap year condition in example (http://xarray.pydata.org/en/stable/examples/monthly-means.html)
95+
by `Mickaël Lalande <https://github.com/mickaellalande>`_.
5496
- Fix the documentation of :py:meth:`DataArray.resample` and
5597
:py:meth:`Dataset.resample` and explicitly state that a
5698
datetime-like dimension is required. (:pull:`3400`)
5799
By `Justus Magin <https://github.com/keewis>`_.
58100
- Update the terminology page to address multidimensional coordinates. (:pull:`3410`)
59101
By `Jon Thielen <https://github.com/jthielen>`_.
102+
- Fix the documentation of :py:meth:`Dataset.integrate` and
103+
:py:meth:`DataArray.integrate` and add an example to
104+
:py:meth:`Dataset.integrate`. (:pull:`3469`)
105+
By `Justus Magin <https://github.com/keewis>`_.
60106

61107
Internal Changes
62108
~~~~~~~~~~~~~~~~
63109

64-
- Use Python 3.6 idioms throughout the codebase. (:pull:3419)
110+
- Added integration tests against `pint <https://pint.readthedocs.io/>`_.
111+
(:pull:`3238`) by `Justus Magin <https://github.com/keewis>`_.
112+
113+
.. note::
114+
115+
At the moment of writing, these tests *as well as the ability to use pint in general*
116+
require `a highly experimental version of pint
117+
<https://github.com/andrewgsavage/pint/pull/6>`_ (install with
118+
``pip install git+https://github.com/andrewgsavage/pint.git@refs/pull/6/head)``.
119+
Even with it, interaction with non-numpy array libraries, e.g. dask or sparse, is broken.
120+
121+
- Use Python 3.6 idioms throughout the codebase. (:pull:`3419`)
122+
By `Maximilian Roos <https://github.com/max-sixty>`_
123+
124+
- Run basic CI tests on Python 3.8. (:pull:`3477`)
65125
By `Maximilian Roos <https://github.com/max-sixty>`_
66126

127+
67128
.. _whats-new.0.14.0:
68129

69130
v0.14.0 (14 Oct 2019)
@@ -3701,6 +3762,7 @@ Enhancements
37013762
explicitly listed variables or index labels:
37023763

37033764
.. ipython:: python
3765+
:okwarning:
37043766
37053767
# drop variables
37063768
ds = xray.Dataset({'x': 0, 'y': 1})

0 commit comments

Comments
 (0)