Skip to content

Commit 2c73e0b

Browse files
committed
Merge branch 'master' into open_mfzarr
2 parents 40c4d46 + 1155f56 commit 2c73e0b

19 files changed

+259
-81
lines changed

HOW_TO_RELEASE.md

+20-12
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,34 @@
33
Time required: about an hour.
44

55
These instructions assume that `upstream` refers to the main repository:
6-
```
6+
7+
```sh
78
$ git remote -v
89
{...}
910
upstream https://github.com/pydata/xarray (fetch)
1011
upstream https://github.com/pydata/xarray (push)
1112
```
1213

14+
<!-- markdownlint-disable MD031 -->
15+
1316
1. Ensure your master branch is synced to upstream:
1417
```sh
1518
git pull upstream master
1619
```
17-
2. Get a list of contributors with:
20+
2. Add a list of contributors with:
1821
```sh
1922
git log "$(git tag --sort="v:refname" | sed -n 'x;$p').." --format=%aN | sort -u | perl -pe 's/\n/$1, /'
2023
```
2124
or by substituting the _previous_ release in {0.X.Y-1}:
2225
```sh
2326
git log v{0.X.Y-1}.. --format=%aN | sort -u | perl -pe 's/\n/$1, /'
2427
```
25-
Add these into `whats-new.rst` somewhere :)
28+
This will return the number of contributors:
29+
```sh
30+
git log v{0.X.Y-1}.. --format=%aN | sort -u | wc -l
31+
```
2632
3. Write a release summary: ~50 words describing the high level features. This
27-
will be used in the release emails, tweets, GitHub release notes, etc.
33+
will be used in the release emails, tweets, GitHub release notes, etc.
2834
4. Look over whats-new.rst and the docs. Make sure "What's New" is complete
2935
(check the date!) and add the release summary at the top.
3036
Things to watch out for:
@@ -45,7 +51,7 @@ upstream https://github.com/pydata/xarray (push)
4551
```
4652
8. Check that the ReadTheDocs build is passing.
4753
9. On the master branch, commit the release in git:
48-
```s
54+
```sh
4955
git commit -am 'Release v{0.X.Y}'
5056
```
5157
10. Tag the release:
@@ -67,7 +73,7 @@ upstream https://github.com/pydata/xarray (push)
6773
twine upload dist/xarray-{0.X.Y}*
6874
```
6975
You will need to be listed as a package owner at
70-
https://pypi.python.org/pypi/xarray for this to work.
76+
<https://pypi.python.org/pypi/xarray> for this to work.
7177
14. Push your changes to master:
7278
```sh
7379
git push upstream master
@@ -80,11 +86,11 @@ upstream https://github.com/pydata/xarray (push)
8086
git push --force upstream stable
8187
git checkout master
8288
```
83-
It's OK to force push to 'stable' if necessary. (We also update the stable
84-
branch with `git cherry-pick` for documentation only fixes that apply the
89+
It's OK to force push to 'stable' if necessary. (We also update the stable
90+
branch with `git cherry-pick` for documentation only fixes that apply the
8591
current released version.)
8692
16. Add a section for the next release {0.X.Y+1} to doc/whats-new.rst:
87-
```
93+
```rst
8894
.. _whats-new.{0.X.Y+1}:
8995
9096
v{0.X.Y+1} (unreleased)
@@ -116,12 +122,12 @@ upstream https://github.com/pydata/xarray (push)
116122
```
117123
You're done pushing to master!
118124
18. Issue the release on GitHub. Click on "Draft a new release" at
119-
https://github.com/pydata/xarray/releases. Type in the version number
125+
<https://github.com/pydata/xarray/releases>. Type in the version number
120126
and paste the release summary in the notes.
121-
19. Update the docs. Login to https://readthedocs.org/projects/xray/versions/
127+
19. Update the docs. Login to <https://readthedocs.org/projects/xray/versions/>
122128
and switch your new release tag (at the bottom) from "Inactive" to "Active".
123129
It should now build automatically.
124-
20. Issue the release announcement to mailing lists & Twitter. For bug fix releases, I
130+
20. Issue the release announcement to mailing lists & Twitter. For bug fix releases, I
125131
usually only email [email protected]. For major/feature releases, I will email a broader
126132
list (no more than once every 3-6 months):
127133
@@ -133,6 +139,8 @@ upstream https://github.com/pydata/xarray (push)
133139
Google search will turn up examples of prior release announcements (look for
134140
"ANN xarray").
135141
142+
<!-- markdownlint-enable MD013 -->
143+
136144
## Note on version numbering
137145
138146
We follow a rough approximation of semantic version. Only major releases (0.X.0)

azure-pipelines.yml

+12
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ jobs:
7474
- bash: black --check .
7575
displayName: black formatting check
7676

77+
- job: Doctests
78+
variables:
79+
conda_env: py38
80+
pool:
81+
vmImage: 'ubuntu-16.04'
82+
steps:
83+
- template: ci/azure/install.yml
84+
- bash: |
85+
source activate xarray-tests
86+
python -m pytest --doctest-modules xarray --ignore xarray/tests
87+
displayName: Run doctests
88+
7789
- job: TypeChecking
7890
variables:
7991
conda_env: py38

ci/requirements/py36-min-nep18.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- distributed=2.9
1111
- numpy=1.17
1212
- pandas=0.25
13-
- pint=0.13
13+
- pint=0.15
1414
- pip
1515
- pytest
1616
- pytest-cov

doc/indexing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ MATLAB, or after using the :py:func:`numpy.ix_` helper:
339339
coords={"x": [0, 1, 2], "y": ["a", "b", "c", "d"]},
340340
)
341341
da
342-
da[[0, 1], [1, 1]]
342+
da[[0, 2, 2], [1, 3]]
343343
344344
For more flexibility, you can supply :py:meth:`~xarray.DataArray` objects
345345
as indexers.

doc/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The recommended way to store xarray data structures is `netCDF`__, which
2626
is a binary file format for self-described datasets that originated
2727
in the geosciences. xarray is based on the netCDF data model, so netCDF files
2828
on disk directly correspond to :py:class:`Dataset` objects (more accurately,
29-
a group in a netCDF file directly corresponds to a to :py:class:`Dataset` object.
29+
a group in a netCDF file directly corresponds to a :py:class:`Dataset` object.
3030
See :ref:`io.netcdf_groups` for more.)
3131

3232
NetCDF is supported on almost all platforms, and parsers exist

doc/quick-overview.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Here are the key properties for a ``DataArray``:
4646
Indexing
4747
--------
4848

49-
xarray supports four kind of indexing. Since we have assigned coordinate labels to the x dimension we can use label-based indexing along that dimension just like pandas. The four examples below all yield the same result (the value at `x=10`) but at varying levels of convenience and intuitiveness.
49+
xarray supports four kinds of indexing. Since we have assigned coordinate labels to the x dimension we can use label-based indexing along that dimension just like pandas. The four examples below all yield the same result (the value at `x=10`) but at varying levels of convenience and intuitiveness.
5050

5151
.. ipython:: python
5252

doc/whats-new.rst

+94-33
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,105 @@ What's New
1414
1515
np.random.seed(123456)
1616
17+
18+
.. _whats-new.0.16.2:
19+
20+
v0.16.2 (unreleased)
21+
--------------------
22+
23+
Breaking changes
24+
~~~~~~~~~~~~~~~~
25+
26+
27+
New Features
28+
~~~~~~~~~~~~
29+
30+
- :py:func:`open_dataset` and :py:func:`open_mfdataset`
31+
now works with ``engine="zarr"`` (:issue:`3668`, :pull:`4003`, :pull:`4187`).
32+
By `Miguel Jimenez <https://github.com/Mikejmnez>`_ and `Wei Ji Leong <https://github.com/weiji14>`_.
33+
34+
Bug fixes
35+
~~~~~~~~~
36+
37+
38+
Documentation
39+
~~~~~~~~~~~~~
40+
41+
42+
Internal Changes
43+
~~~~~~~~~~~~~~~~
44+
45+
1746
.. _whats-new.0.16.1:
1847

19-
v0.16.1 (unreleased)
48+
v0.16.1 (2020-09-20)
2049
---------------------
2150

51+
This patch release fixes an incompatibility with a recent pandas change, which
52+
was causing an issue indexing with a ``datetime64``. It also includes
53+
improvements to ``rolling``, ``to_dataframe``, ``cov`` & ``corr`` methods and
54+
bug fixes. Our documentation has a number of improvements, including fixing all
55+
doctests and confirming their accuracy on every commit.
56+
57+
Many thanks to the 36 contributors who contributed to this release:
58+
59+
Aaron Spring, Akio Taniguchi, Aleksandar Jelenak, Alexandre Poux,
60+
Caleb, Dan Nowacki, Deepak Cherian, Gerardo Rivera, Jacob Tomlinson, James A.
61+
Bednar, Joe Hamman, Julia Kent, Kai Mühlbauer, Keisuke Fujii, Mathias Hauser,
62+
Maximilian Roos, Nick R. Papior, Pascal Bourgault, Peter Hausamann, Romain
63+
Martinez, Russell Manser, Samnan Rahee, Sander, Spencer Clark, Stephan Hoyer,
64+
Thomas Zilio, Tobias Kölling, Tom Augspurger, alexamici, crusaderky, darikg,
65+
inakleinbottle, jenssss, johnomotani, keewis, and rpgoldman.
66+
2267
Breaking changes
2368
~~~~~~~~~~~~~~~~
69+
2470
- :py:meth:`DataArray.astype` and :py:meth:`Dataset.astype` now preserve attributes. Keep the
2571
old behavior by passing `keep_attrs=False` (:issue:`2049`, :pull:`4314`).
2672
By `Dan Nowacki <https://github.com/dnowacki-usgs>`_ and `Gabriel Joel Mitchell <https://github.com/gajomi>`_.
2773

2874
New Features
2975
~~~~~~~~~~~~
30-
- Support multiple outputs in :py:func:`xarray.apply_ufunc` when using ``dask='parallelized'``. (:issue:`1815`, :pull:`4060`)
31-
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
76+
3277
- :py:meth:`~xarray.DataArray.rolling` and :py:meth:`~xarray.Dataset.rolling`
3378
now accept more than 1 dimension. (:pull:`4219`)
3479
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
80+
- :py:meth:`~xarray.DataArray.to_dataframe` and :py:meth:`~xarray.Dataset.to_dataframe`
81+
now accept a ``dim_order`` parameter allowing to specify the resulting dataframe's
82+
dimensions order (:issue:`4331`, :pull:`4333`).
83+
By `Thomas Zilio <https://github.com/thomas-z>`_.
84+
- Support multiple outputs in :py:func:`xarray.apply_ufunc` when using
85+
``dask='parallelized'``. (:issue:`1815`, :pull:`4060`).
86+
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
3587
- ``min_count`` can be supplied to reductions such as ``.sum`` when specifying
36-
multiple dimension to reduce over. (:pull:`4356`)
88+
multiple dimension to reduce over; (:pull:`4356`).
3789
By `Maximilian Roos <https://github.com/max-sixty>`_.
38-
- :py:func:`xarray.cov` and :py:func:`xarray.corr` now handle missing values. (:pull:`4351`)
90+
- :py:func:`xarray.cov` and :py:func:`xarray.corr` now handle missing values; (:pull:`4351`).
3991
By `Maximilian Roos <https://github.com/max-sixty>`_.
92+
- Add support for parsing datetime strings formatted following the default
93+
string representation of cftime objects, i.e. YYYY-MM-DD hh:mm:ss, in
94+
partial datetime string indexing, as well as :py:meth:`~xarray.cftime_range`
95+
(:issue:`4337`). By `Spencer Clark <https://github.com/spencerkclark>`_.
4096
- Build ``CFTimeIndex.__repr__`` explicitly as :py:class:`pandas.Index`. Add ``calendar`` as a new
4197
property for :py:class:`CFTimeIndex` and show ``calendar`` and ``length`` in
4298
``CFTimeIndex.__repr__`` (:issue:`2416`, :pull:`4092`)
4399
By `Aaron Spring <https://github.com/aaronspring>`_.
44-
- Relaxed the :ref:`mindeps_policy` to support:
45-
46-
- all versions of setuptools released in the last 42 months (but no older than 38.4)
47-
- all versions of dask and dask.distributed released in the last 12 months (but no
48-
older than 2.9)
49-
- all versions of other packages released in the last 12 months
50-
51-
All are up from 6 months (:issue:`4295`)
52-
`Guido Imperiale <https://github.com/crusaderky>`_.
53100
- Use a wrapped array's ``_repr_inline_`` method to construct the collapsed ``repr``
54101
of :py:class:`DataArray` and :py:class:`Dataset` objects and
55102
document the new method in :doc:`internals`. (:pull:`4248`).
56103
By `Justus Magin <https://github.com/keewis>`_.
57-
- :py:func:`open_dataset` and :py:func:`open_mfdataset`
58-
now works with ``engine="zarr"`` (:issue:`3668`, :pull:`4003`, :pull:`4187`).
59-
By `Miguel Jimenez <https://github.com/Mikejmnez>`_ and `Wei Ji Leong <https://github.com/weiji14>`_.
60-
- Add support for parsing datetime strings formatted following the default
61-
string representation of cftime objects, i.e. YYYY-MM-DD hh:mm:ss, in
62-
partial datetime string indexing, as well as :py:meth:`~xarray.cftime_range`
63-
(:issue:`4337`). By `Spencer Clark <https://github.com/spencerkclark>`_.
64-
- :py:meth:`~xarray.DataArray.to_dataframe` and :py:meth:`~xarray.Dataset.to_dataframe`
65-
now accept a ``dim_order`` parameter allowing to specify the resulting dataframe's
66-
dimensions order (:issue:`4331`, :pull:`4333`).
67-
By `Thomas Zilio <https://github.com/thomas-z>`_.
104+
- Allow per-variable fill values in most functions. (:pull:`4237`).
105+
By `Justus Magin <https://github.com/keewis>`_.
68106
- Expose ``use_cftime`` option in :py:func:`~xarray.open_zarr` (:issue:`2886`, :pull:`3229`)
69107
By `Samnan Rahee <https://github.com/Geektrovert>`_ and `Anderson Banihirwe <https://github.com/andersy005>`_.
70108

71109

72110
Bug fixes
73111
~~~~~~~~~
112+
113+
- Fix indexing with datetime64 scalars with pandas 1.1 (:issue:`4283`).
114+
By `Stephan Hoyer <https://github.com/shoyer>`_ and
115+
`Justus Magin <https://github.com/keewis>`_.
74116
- Variables which are chunked using dask only along some dimensions can be chunked while storing with zarr along previously
75117
unchunked dimensions (:pull:`4312`) By `Tobias Kölling <https://github.com/d70-t>`_.
76118
- Fixed a bug in backend caused by basic installation of Dask (:issue:`4164`, :pull:`4318`)
@@ -80,7 +122,7 @@ Bug fixes
80122
and :py:meth:`DataArray.str.wrap` (:issue:`4334`). By `Mathias Hauser <https://github.com/mathause>`_.
81123
- Fixed overflow issue causing incorrect results in computing means of :py:class:`cftime.datetime`
82124
arrays (:issue:`4341`). By `Spencer Clark <https://github.com/spencerkclark>`_.
83-
- Fixed :py:meth:`Dataset.coarsen`, :py:meth:`DataArray.coarsen` dropping attributes on original object (:issue:`4120`, :pull:`4360`). by `Julia Kent <https://github.com/jukent>`_.
125+
- Fixed :py:meth:`Dataset.coarsen`, :py:meth:`DataArray.coarsen` dropping attributes on original object (:issue:`4120`, :pull:`4360`). By `Julia Kent <https://github.com/jukent>`_.
84126
- fix the signature of the plot methods. (:pull:`4359`) By `Justus Magin <https://github.com/keewis>`_.
85127
- Fix :py:func:`xarray.apply_ufunc` with ``vectorize=True`` and ``exclude_dims`` (:issue:`3890`).
86128
By `Mathias Hauser <https://github.com/mathause>`_.
@@ -89,9 +131,15 @@ Bug fixes
89131
By `Jens Svensmark <https://github.com/jenssss>`_
90132
- Fix incorrect legend labels for :py:meth:`Dataset.plot.scatter` (:issue:`4126`).
91133
By `Peter Hausamann <https://github.com/phausamann>`_.
92-
- Fix indexing with datetime64 scalars with pandas 1.1 (:issue:`4283`).
93-
By `Stephan Hoyer <https://github.com/shoyer>`_ and
94-
`Justus Magin <https://github.com/keewis>`_.
134+
- Fix ``dask.optimize`` on ``DataArray`` producing an invalid Dask task graph (:issue:`3698`)
135+
By `Tom Augspurger <https://github.com/TomAugspurger>`_
136+
- Fix ``pip install .`` when no ``.git`` directory exists; namely when the xarray source
137+
directory has been rsync'ed by PyCharm Professional for a remote deployment over SSH.
138+
By `Guido Imperiale <https://github.com/crusaderky>`_
139+
- Preserve dimension and coordinate order during :py:func:`xarray.concat` (:issue:`2811`, :issue:`4072`, :pull:`4419`).
140+
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
141+
- Avoid relying on :py:class:`set` objects for the ordering of the coordinates (:pull:`4409`)
142+
By `Justus Magin <https://github.com/keewis>`_.
95143

96144
Documentation
97145
~~~~~~~~~~~~~
@@ -101,15 +149,28 @@ Documentation
101149
- Removed skipna argument from :py:meth:`DataArray.count`, :py:meth:`DataArray.any`, :py:meth:`DataArray.all`. (:issue:`755`)
102150
By `Sander van Rijn <https://github.com/sjvrijn>`_
103151
- Update the contributing guide to use merges instead of rebasing and state
104-
that we squash-merge. (:pull:`4355`) By `Justus Magin <https://github.com/keewis>`_.
152+
that we squash-merge. (:pull:`4355`). By `Justus Magin <https://github.com/keewis>`_.
153+
- Make sure the examples from the docstrings actually work (:pull:`4408`).
154+
By `Justus Magin <https://github.com/keewis>`_.
155+
- Updated Vectorized Indexing to a clearer example.
156+
By `Maximilian Roos <https://github.com/max-sixty>`_
105157

106158
Internal Changes
107159
~~~~~~~~~~~~~~~~
160+
161+
- Fixed all doctests and enabled their running in CI.
162+
By `Justus Magin <https://github.com/keewis>`_.
163+
- Relaxed the :ref:`mindeps_policy` to support:
164+
165+
- all versions of setuptools released in the last 42 months (but no older than 38.4)
166+
- all versions of dask and dask.distributed released in the last 12 months (but no
167+
older than 2.9)
168+
- all versions of other packages released in the last 12 months
169+
170+
All are up from 6 months (:issue:`4295`)
171+
`Guido Imperiale <https://github.com/crusaderky>`_.
108172
- Use :py:func:`dask.array.apply_gufunc` instead of :py:func:`dask.array.blockwise` in
109173
:py:func:`xarray.apply_ufunc` when using ``dask='parallelized'``. (:pull:`4060`, :pull:`4391`, :pull:`4392`)
110-
- Fix ``pip install .`` when no ``.git`` directory exists; namely when the xarray source
111-
directory has been rsync'ed by PyCharm Professional for a remote deployment over SSH.
112-
By `Guido Imperiale <https://github.com/crusaderky>`_
113174
- Align ``mypy`` versions to ``0.782`` across ``requirements`` and
114175
``.pre-commit-config.yml`` files. (:pull:`4390`)
115176
By `Maximilian Roos <https://github.com/max-sixty>`_

xarray/core/combine.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ def combine_by_coords(
711711
<xarray.Dataset>
712712
Dimensions: (x: 3, y: 4)
713713
Coordinates:
714-
* x (x) int64 10 20 30
715714
* y (y) int64 0 1 2 3
715+
* x (x) int64 10 20 30
716716
Data variables:
717717
temperature (y, x) float64 10.98 14.3 12.06 10.9 ... 1.743 0.4044 16.65
718718
precipitation (y, x) float64 0.4376 0.8918 0.9637 ... 0.7992 0.4615 0.7805

xarray/core/concat.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ def _parse_datasets(
349349
all_coord_names.update(ds.coords)
350350
data_vars.update(ds.data_vars)
351351

352-
for dim in set(ds.dims) - dims:
352+
# preserves ordering of dimensions
353+
for dim in ds.dims:
354+
if dim in dims:
355+
continue
356+
353357
if dim not in dim_coords:
354358
dim_coords[dim] = ds.coords[dim].variable
355359
dims = dims | set(ds.dims)
@@ -459,6 +463,9 @@ def ensure_common_dims(vars):
459463
combined = concat_vars(vars, dim, positions)
460464
assert isinstance(combined, Variable)
461465
result_vars[k] = combined
466+
elif k in result_vars:
467+
# preserves original variable order
468+
result_vars[k] = result_vars.pop(k)
462469

463470
result = Dataset(result_vars, attrs=result_attrs)
464471
absent_coord_names = coord_names - set(result.variables)

xarray/core/coordinates.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ def __getitem__(self, key: Hashable) -> "DataArray":
215215

216216
def to_dataset(self) -> "Dataset":
217217
"""Convert these coordinates into a new Dataset"""
218-
return self._data._copy_listed(self._names)
218+
219+
names = [name for name in self._data._variables if name in self._names]
220+
return self._data._copy_listed(names)
219221

220222
def _update_coords(
221223
self, coords: Dict[Hashable, Variable], indexes: Mapping[Hashable, pd.Index]

0 commit comments

Comments
 (0)