Skip to content

Commit 46a4b16

Browse files
committed
Merge branch 'main' into fix/dask_indexing
* main: (34 commits) Explicit indexes (pydata#5692) Remove test_rasterio_vrt_network (pydata#6371) Allow write_empty_chunks to be set in Zarr encoding (pydata#6348) Add new tutorial video (pydata#6353) Revert "explicitly install `ipython_genutils` (pydata#6350)" (pydata#6361) [pre-commit.ci] pre-commit autoupdate (pydata#6357) Run pyupgrade on core/groupby (pydata#6351) Generate reductions for DataArray, Dataset, GroupBy and Resample (pydata#5950) explicitly install `ipython_genutils` (pydata#6350) Bump actions/setup-python from 2 to 3 (pydata#6338) Bump actions/checkout from 2 to 3 (pydata#6337) In documentation on adding a new backend, add missing import and tweak headings (pydata#6330) Lengthen underline, correct spelling, and reword (pydata#6326) quantile: use skipna=None (pydata#6303) New whatsnew section v2022.03.0 release notes (pydata#6319) fix typos (using codespell) (pydata#6316) Add General issue template (pydata#6314) Disable CI runs on forks (pydata#6315) Enable running sphinx-build on Windows (pydata#6237) ...
2 parents b7c382b + 3ead17e commit 46a4b16

File tree

92 files changed

+8986
-3884
lines changed

Some content is hidden

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

92 files changed

+8986
-3884
lines changed

.github/ISSUE_TEMPLATE/bugreport.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ body:
3333
3434
Bug reports that follow these guidelines are easier to diagnose, and so are often handled much more quickly.
3535
This will be automatically formatted into code, so no need for markdown backticks.
36-
render: python
36+
render: Python
3737

3838
- type: textarea
3939
id: log-output
4040
attributes:
4141
label: Relevant log output
4242
description: Please copy and paste any relevant output. This will be automatically formatted into code, so no need for markdown backticks.
43-
render: python
43+
render: Python
4444

4545
- type: textarea
4646
id: extra

.github/ISSUE_TEMPLATE/misc.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Issue
2+
description: General Issue or discussion topic. For usage questions, please follow the "Usage question" link
3+
labels: ["needs triage"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Please describe your issue here.
9+
- type: textarea
10+
id: issue-description
11+
attributes:
12+
label: What is your issue?
13+
description: |
14+
Thank you for filing an issue! Please give us further information on how we can help you.
15+
placeholder: Please describe your issue.
16+
validations:
17+
required: true

.github/workflows/benchmarks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
# We need the full repo to avoid this issue
1818
# https://github.com/actions/checkout/issues/23
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
with:
2121
fetch-depth: 0
2222

.github/workflows/ci-additional.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
outputs:
2323
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v3
2626
with:
2727
fetch-depth: 2
2828
- uses: xarray-contrib/[email protected]
@@ -53,7 +53,7 @@ jobs:
5353
"py39-flaky",
5454
]
5555
steps:
56-
- uses: actions/checkout@v2
56+
- uses: actions/checkout@v3
5757
with:
5858
fetch-depth: 0 # Fetch all history for all branches and tags.
5959

@@ -119,12 +119,13 @@ jobs:
119119
doctest:
120120
name: Doctests
121121
runs-on: "ubuntu-latest"
122+
if: needs.detect-ci-trigger.outputs.triggered == 'false'
122123
defaults:
123124
run:
124125
shell: bash -l {0}
125126

126127
steps:
127-
- uses: actions/checkout@v2
128+
- uses: actions/checkout@v3
128129
with:
129130
fetch-depth: 0 # Fetch all history for all branches and tags.
130131
- uses: conda-incubator/setup-miniconda@v2
@@ -161,7 +162,7 @@ jobs:
161162
shell: bash -l {0}
162163

163164
steps:
164-
- uses: actions/checkout@v2
165+
- uses: actions/checkout@v3
165166
with:
166167
fetch-depth: 0 # Fetch all history for all branches and tags.
167168
- uses: conda-incubator/setup-miniconda@v2

.github/workflows/ci.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
outputs:
2323
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v3
2626
with:
2727
fetch-depth: 2
2828
- uses: xarray-contrib/[email protected]
@@ -44,7 +44,7 @@ jobs:
4444
# Bookend python versions
4545
python-version: ["3.8", "3.9", "3.10"]
4646
steps:
47-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v3
4848
with:
4949
fetch-depth: 0 # Fetch all history for all branches and tags.
5050
- name: Set environment variables
@@ -115,6 +115,7 @@ jobs:
115115
event_file:
116116
name: "Event File"
117117
runs-on: ubuntu-latest
118+
if: github.repository == 'pydata/xarray'
118119
steps:
119120
- name: Upload
120121
uses: actions/upload-artifact@v2

.github/workflows/pypi-release.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313
if: github.repository == 'pydata/xarray'
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
1616
with:
1717
fetch-depth: 0
18-
- uses: actions/setup-python@v2
18+
- uses: actions/setup-python@v3
1919
name: Install Python
2020
with:
2121
python-version: 3.8
@@ -50,7 +50,7 @@ jobs:
5050
needs: build-artifacts
5151
runs-on: ubuntu-latest
5252
steps:
53-
- uses: actions/setup-python@v2
53+
- uses: actions/setup-python@v3
5454
name: Install Python
5555
with:
5656
python-version: 3.8

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
outputs:
2525
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
2626
steps:
27-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v3
2828
with:
2929
fetch-depth: 2
3030
- uses: xarray-contrib/[email protected]
@@ -52,7 +52,7 @@ jobs:
5252
outputs:
5353
artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }}
5454
steps:
55-
- uses: actions/checkout@v2
55+
- uses: actions/checkout@v3
5656
with:
5757
fetch-depth: 0 # Fetch all history for all branches and tags.
5858
- uses: conda-incubator/setup-miniconda@v2
@@ -110,8 +110,8 @@ jobs:
110110
run:
111111
shell: bash
112112
steps:
113-
- uses: actions/checkout@v2
114-
- uses: actions/setup-python@v2
113+
- uses: actions/checkout@v3
114+
- uses: actions/setup-python@v3
115115
with:
116116
python-version: "3.x"
117117
- uses: actions/download-artifact@v2

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ __pycache__
55
.hypothesis/
66

77
# temp files from docs build
8+
doc/*.nc
89
doc/auto_gallery
9-
doc/example.nc
10+
doc/rasm.zarr
1011
doc/savefig
1112

1213
# C extensions
@@ -72,4 +73,3 @@ xarray/tests/data/*.grib.*.idx
7273
Icon*
7374

7475
.ipynb_checkpoints
75-
doc/rasm.zarr

.pre-commit-config.yaml

+2-2
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.31.0
22+
rev: v2.31.1
2323
hooks:
2424
- id: pyupgrade
2525
args:
@@ -45,7 +45,7 @@ repos:
4545
# - id: velin
4646
# args: ["--write", "--compact"]
4747
- repo: https://github.com/pre-commit/mirrors-mypy
48-
rev: v0.931
48+
rev: v0.940
4949
hooks:
5050
- id: mypy
5151
# Copied from setup.cfg

HOW_TO_RELEASE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ upstream https://github.com/pydata/xarray (push)
109109

110110
## Note on version numbering
111111

112-
As of 2022.02.0, we utilize the [CALVER](https://calver.org/) version system.
112+
As of 2022.03.0, we utilize the [CALVER](https://calver.org/) version system.
113113
Specifically, we have adopted the pattern `YYYY.MM.X`, where `YYYY` is a 4-digit
114114
year (e.g. `2022`), `MM` is a 2-digit zero-padded month (e.g. `01` for January), and `X` is the release number (starting at zero at the start of each month and incremented once for each additional release).

ci/requirements/environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies:
3737
- pytest
3838
- pytest-cov
3939
- pytest-env
40+
- pytest-github-actions-annotate-failures
4041
- pytest-xdist
4142
- rasterio
4243
- scipy

doc/api.rst

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Dataset contents
106106
Dataset.swap_dims
107107
Dataset.expand_dims
108108
Dataset.drop_vars
109+
Dataset.drop_duplicates
109110
Dataset.drop_dims
110111
Dataset.set_coords
111112
Dataset.reset_coords

doc/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
print("python exec:", sys.executable)
2929
print("sys.path:", sys.path)
3030

31-
if "conda" in sys.executable:
31+
if "CONDA_DEFAULT_ENV" in os.environ or "conda" in sys.executable:
3232
print("conda environment:")
33-
subprocess.run(["conda", "list"])
33+
subprocess.run([os.environ.get("CONDA_EXE", "conda"), "list"])
3434
else:
3535
print("pip environment:")
3636
subprocess.run([sys.executable, "-m", "pip", "list"])

doc/contributing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ Some other important things to know about the docs:
274274
.. ipython:: python
275275
276276
x = 2
277-
x ** 3
277+
x**3
278278
279279
will be rendered as::
280280

281281
In [1]: x = 2
282282

283-
In [2]: x ** 3
283+
In [2]: x**3
284284
Out[2]: 8
285285

286286
Almost all code examples in the docs are run (and the output saved) during the

doc/ecosystem.rst

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Geosciences
1717
- `climpred <https://climpred.readthedocs.io>`_: Analysis of ensemble forecast models for climate prediction.
1818
- `geocube <https://corteva.github.io/geocube>`_: Tool to convert geopandas vector data into rasterized xarray data.
1919
- `GeoWombat <https://github.com/jgrss/geowombat>`_: Utilities for analysis of remotely sensed and gridded raster data at scale (easily tame Landsat, Sentinel, Quickbird, and PlanetScope).
20+
- `gsw-xarray <https://github.com/DocOtak/gsw-xarray>`_: a wrapper around `gsw <https://teos-10.github.io/GSW-Python>`_ that adds CF compliant attributes when possible, units, name.
2021
- `infinite-diff <https://github.com/spencerahill/infinite-diff>`_: xarray-based finite-differencing, focused on gridded climate/meteorology data
2122
- `marc_analysis <https://github.com/darothen/marc_analysis>`_: Analysis package for CESM/MARC experiments and output.
2223
- `MetPy <https://unidata.github.io/MetPy/dev/index.html>`_: A collection of tools in Python for reading, visualizing, and performing calculations with weather data.

doc/examples/ROMS_ocean_model.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"ds = xr.tutorial.open_dataset(\"ROMS_example.nc\", chunks={\"ocean_time\": 1})\n",
7878
"\n",
7979
"# This is a way to turn on chunking and lazy evaluation. Opening with mfdataset, or\n",
80-
"# setting the chunking in the open_dataset would also achive this.\n",
80+
"# setting the chunking in the open_dataset would also achieve this.\n",
8181
"ds"
8282
]
8383
},

doc/gallery/plot_colorbar_center.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
ax4.set_title("Celsius: center=False")
3939
ax4.set_ylabel("")
4040

41-
# Mke it nice
41+
# Make it nice
4242
plt.tight_layout()
4343
plt.show()

doc/getting-started-guide/quick-overview.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,15 @@ You can directly read and write xarray objects to disk using :py:meth:`~xarray.D
215215
.. ipython:: python
216216
217217
ds.to_netcdf("example.nc")
218-
xr.open_dataset("example.nc")
218+
reopened = xr.open_dataset("example.nc")
219+
reopened
219220
220221
.. ipython:: python
221222
:suppress:
222223
223224
import os
224225
226+
reopened.close()
225227
os.remove("example.nc")
226228
227229

doc/internals/how-to-add-new-backend.rst

+16-8
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ Xarray :py:meth:`~xarray.open_dataset`, and returns a boolean.
172172

173173
Decoders
174174
^^^^^^^^
175+
175176
The decoders implement specific operations to transform data from on-disk
176177
representation to Xarray representation.
177178

@@ -199,6 +200,11 @@ performs the inverse transformation.
199200

200201
In the following an example on how to use the coders ``decode`` method:
201202

203+
.. ipython:: python
204+
:suppress:
205+
206+
import xarray as xr
207+
202208
.. ipython:: python
203209
204210
var = xr.Variable(
@@ -239,7 +245,7 @@ interface only the boolean keywords related to the supported decoders.
239245
.. _RST backend_registration:
240246

241247
How to register a backend
242-
+++++++++++++++++++++++++++
248+
+++++++++++++++++++++++++
243249

244250
Define a new entrypoint in your ``setup.py`` (or ``setup.cfg``) with:
245251

@@ -273,15 +279,16 @@ If you are using `Poetry <https://python-poetry.org/>`_ for your build system, y
273279

274280
.. code-block:: toml
275281
276-
[tool.poetry.plugins."xarray_backends"]
282+
[tool.poetry.plugins."xarray.backends"]
277283
"my_engine" = "my_package.my_module:MyBackendEntryClass"
278284
279285
See https://python-poetry.org/docs/pyproject/#plugins for more information on Poetry plugins.
280286

281287
.. _RST lazy_loading:
282288

283-
How to support Lazy Loading
289+
How to support lazy loading
284290
+++++++++++++++++++++++++++
291+
285292
If you want to make your backend effective with big datasets, then you should
286293
support lazy loading.
287294
Basically, you shall replace the :py:class:`numpy.ndarray` inside the
@@ -317,7 +324,7 @@ grouped in three types of indexes
317324
:py:class:`~xarray.core.indexing.OuterIndexer` and
318325
:py:class:`~xarray.core.indexing.VectorizedIndexer`.
319326
This implies that the implementation of the method ``__getitem__`` can be tricky.
320-
In oder to simplify this task, Xarray provides a helper function,
327+
In order to simplify this task, Xarray provides a helper function,
321328
:py:func:`~xarray.core.indexing.explicit_indexing_adapter`, that transforms
322329
all the input ``indexer`` types (`basic`, `outer`, `vectorized`) in a tuple
323330
which is interpreted correctly by your backend.
@@ -338,8 +345,8 @@ This is an example ``BackendArray`` subclass implementation:
338345
# other backend specific keyword arguments
339346
):
340347
self.shape = shape
341-
self.dtype = lock
342-
self.lock = dtype
348+
self.dtype = dtype
349+
self.lock = lock
343350
344351
def __getitem__(
345352
self, key: xarray.core.indexing.ExplicitIndexer
@@ -380,8 +387,9 @@ opening files, we therefore suggest to use the helper class provided by Xarray
380387

381388
.. _RST indexing:
382389

383-
Indexing Examples
390+
Indexing examples
384391
^^^^^^^^^^^^^^^^^
392+
385393
**BASIC**
386394

387395
In the ``BASIC`` indexing support, numbers and slices are supported.
@@ -426,7 +434,7 @@ The ``OUTER_1VECTOR`` indexing shall supports number, slices and at most one
426434
list. The behaviour with the list shall be the same of ``OUTER`` indexing.
427435

428436
If you support more complex indexing as `explicit indexing` or
429-
`numpy indexing`, you can have a look to the implemetation of Zarr backend and Scipy backend,
437+
`numpy indexing`, you can have a look to the implementation of Zarr backend and Scipy backend,
430438
currently available in :py:mod:`~xarray.backends` module.
431439

432440
.. _RST preferred_chunks:

doc/internals/zarr-encoding-spec.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ for the storage of the NetCDF data model in Zarr; see
1414
discussion.
1515

1616
First, Xarray can only read and write Zarr groups. There is currently no support
17-
for reading / writting individual Zarr arrays. Zarr groups are mapped to
17+
for reading / writing individual Zarr arrays. Zarr groups are mapped to
1818
Xarray ``Dataset`` objects.
1919

2020
Second, from Xarray's point of view, the key difference between
@@ -63,3 +63,10 @@ re-open it directly with Zarr:
6363
print(os.listdir("rasm.zarr"))
6464
print(zgroup.tree())
6565
dict(zgroup["Tair"].attrs)
66+
67+
.. ipython:: python
68+
:suppress:
69+
70+
import shutil
71+
72+
shutil.rmtree("rasm.zarr")

0 commit comments

Comments
 (0)