Skip to content

Commit d02d2fd

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feature/rolling-pad
* upstream/main: Save groupby codes after factorizing, pass to flox (pydata#7206) [skip-ci] Add compute to groupby benchmarks (pydata#7690) Delete built-in cfgrib backend (pydata#7670) Added a pronunciation guide to the word Xarray in the README.MD fil… (pydata#7677) boundarynorm fix (pydata#7553) Fix lazy negative slice rewriting. (pydata#7586) [pre-commit.ci] pre-commit autoupdate (pydata#7687) Adjust sidebar font colors (pydata#7674) Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.3 (pydata#7682) Raise PermissionError when insufficient permissions (pydata#7629)
2 parents b963b29 + 0ac5541 commit d02d2fd

38 files changed

+467
-531
lines changed

.github/workflows/pypi-release.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
7373
- name: Publish package to TestPyPI
7474
if: github.event_name == 'push'
75-
uses: pypa/[email protected].1
75+
uses: pypa/[email protected].3
7676
with:
7777
user: __token__
7878
password: ${{ secrets.TESTPYPI_TOKEN }}
@@ -90,7 +90,7 @@ jobs:
9090
name: releases
9191
path: dist
9292
- name: Publish package to PyPI
93-
uses: pypa/[email protected].1
93+
uses: pypa/[email protected].3
9494
with:
9595
user: __token__
9696
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/testpypi-release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
7979
- name: Publish package to TestPyPI
8080
if: github.event_name == 'push'
81-
uses: pypa/[email protected].1
81+
uses: pypa/[email protected].3
8282
with:
8383
user: __token__
8484
password: ${{ secrets.TESTPYPI_TOKEN }}

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
files: ^xarray/
1717
- repo: https://github.com/charliermarsh/ruff-pre-commit
1818
# Ruff version.
19-
rev: 'v0.0.257'
19+
rev: 'v0.0.259'
2020
hooks:
2121
- id: ruff
2222
args: ["--fix"]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[![Examples on binder](https://img.shields.io/badge/launch-binder-579ACA.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFkAAABZCAMAAABi1XidAAAB8lBMVEX///9XmsrmZYH1olJXmsr1olJXmsrmZYH1olJXmsr1olJXmsrmZYH1olL1olJXmsr1olJXmsrmZYH1olL1olJXmsrmZYH1olJXmsr1olL1olJXmsrmZYH1olL1olJXmsrmZYH1olL1olL0nFf1olJXmsrmZYH1olJXmsq8dZb1olJXmsrmZYH1olJXmspXmspXmsr1olL1olJXmsrmZYH1olJXmsr1olL1olJXmsrmZYH1olL1olLeaIVXmsrmZYH1olL1olL1olJXmsrmZYH1olLna31Xmsr1olJXmsr1olJXmsrmZYH1olLqoVr1olJXmsr1olJXmsrmZYH1olL1olKkfaPobXvviGabgadXmsqThKuofKHmZ4Dobnr1olJXmsr1olJXmspXmsr1olJXmsrfZ4TuhWn1olL1olJXmsqBi7X1olJXmspZmslbmMhbmsdemsVfl8ZgmsNim8Jpk8F0m7R4m7F5nLB6jbh7jbiDirOEibOGnKaMhq+PnaCVg6qWg6qegKaff6WhnpKofKGtnomxeZy3noG6dZi+n3vCcpPDcpPGn3bLb4/Mb47UbIrVa4rYoGjdaIbeaIXhoWHmZYHobXvpcHjqdHXreHLroVrsfG/uhGnuh2bwj2Hxk17yl1vzmljzm1j0nlX1olL3AJXWAAAAbXRSTlMAEBAQHx8gICAuLjAwMDw9PUBAQEpQUFBXV1hgYGBkcHBwcXl8gICAgoiIkJCQlJicnJ2goKCmqK+wsLC4usDAwMjP0NDQ1NbW3Nzg4ODi5+3v8PDw8/T09PX29vb39/f5+fr7+/z8/Pz9/v7+zczCxgAABC5JREFUeAHN1ul3k0UUBvCb1CTVpmpaitAGSLSpSuKCLWpbTKNJFGlcSMAFF63iUmRccNG6gLbuxkXU66JAUef/9LSpmXnyLr3T5AO/rzl5zj137p136BISy44fKJXu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/f/Grl/XnyF1Gw3VKCez0PN5IUfFLqvgUN4C0qNqYs5YhPL+aVZYDE4IpUk57oSFnJm4FyCqqOE0jhY2SMyLFoo56zyo6becOS5UVDdj7Vih0zp+tcMhwRpBeLyqtIjlJKAIZSbI8SGSF3k0pA3mR5tHuwPFoa7N7reoq2bqCsAk1HqCu5uvI1n6JuRXI+S1Mco54YmYTwcn6Aeic+kssXi8XpXC4V3t7/ADuTNKaQJdScAAAAAElFTkSuQmCC)](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/weather-data.ipynb)
1212
[![Twitter](https://img.shields.io/twitter/follow/xarray_dev?style=social)](https://twitter.com/xarray_dev)
1313

14-
**xarray** (formerly **xray**) is an open source project and Python
14+
**xarray** (pronounced "ex-array", formerly known as **xray**) is an open source project and Python
1515
package that makes working with labelled multi-dimensional arrays
1616
simple, efficient, and fun!
1717

asv_bench/benchmarks/groupby.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# import flox to avoid the cost of first import
2+
import flox.xarray # noqa
13
import numpy as np
24
import pandas as pd
35

@@ -27,24 +29,24 @@ def time_init(self, ndim):
2729
@parameterized(["method", "ndim"], [("sum", "mean"), (1, 2)])
2830
def time_agg_small_num_groups(self, method, ndim):
2931
ds = getattr(self, f"ds{ndim}d")
30-
getattr(ds.groupby("a"), method)()
32+
getattr(ds.groupby("a"), method)().compute()
3133

3234
@parameterized(["method", "ndim"], [("sum", "mean"), (1, 2)])
3335
def time_agg_large_num_groups(self, method, ndim):
3436
ds = getattr(self, f"ds{ndim}d")
35-
getattr(ds.groupby("b"), method)()
37+
getattr(ds.groupby("b"), method)().compute()
3638

3739
def time_binary_op_1d(self):
38-
self.ds1d.groupby("b") - self.ds1d_mean
40+
(self.ds1d.groupby("b") - self.ds1d_mean).compute()
3941

4042
def time_binary_op_2d(self):
41-
self.ds2d.groupby("b") - self.ds2d_mean
43+
(self.ds2d.groupby("b") - self.ds2d_mean).compute()
4244

4345
def peakmem_binary_op_1d(self):
44-
self.ds1d.groupby("b") - self.ds1d_mean
46+
(self.ds1d.groupby("b") - self.ds1d_mean).compute()
4547

4648
def peakmem_binary_op_2d(self):
47-
self.ds2d.groupby("b") - self.ds2d_mean
49+
(self.ds2d.groupby("b") - self.ds2d_mean).compute()
4850

4951

5052
class GroupByDask(GroupBy):
@@ -56,8 +58,8 @@ def setup(self, *args, **kwargs):
5658
self.ds1d["c"] = self.ds1d["c"].chunk({"dim_0": 50})
5759
self.ds2d = self.ds2d.sel(dim_0=slice(None, None, 2))
5860
self.ds2d["c"] = self.ds2d["c"].chunk({"dim_0": 50, "z": 5})
59-
self.ds1d_mean = self.ds1d.groupby("b").mean()
60-
self.ds2d_mean = self.ds2d.groupby("b").mean()
61+
self.ds1d_mean = self.ds1d.groupby("b").mean().compute()
62+
self.ds2d_mean = self.ds2d.groupby("b").mean().compute()
6163

6264

6365
class GroupByPandasDataFrame(GroupBy):
@@ -88,7 +90,7 @@ def setup(self, *args, **kwargs):
8890
requires_dask()
8991
super().setup(**kwargs)
9092
self.ds1d = self.ds1d.chunk({"dim_0": 50}).to_dataframe()
91-
self.ds1d_mean = self.ds1d.groupby("b").mean()
93+
self.ds1d_mean = self.ds1d.groupby("b").mean().compute()
9294

9395
def time_binary_op_2d(self):
9496
raise NotImplementedError
@@ -116,12 +118,12 @@ def time_init(self, ndim):
116118
@parameterized(["method", "ndim"], [("sum", "mean"), (1, 2)])
117119
def time_agg_small_num_groups(self, method, ndim):
118120
ds = getattr(self, f"ds{ndim}d")
119-
getattr(ds.resample(time="3M"), method)()
121+
getattr(ds.resample(time="3M"), method)().compute()
120122

121123
@parameterized(["method", "ndim"], [("sum", "mean"), (1, 2)])
122124
def time_agg_large_num_groups(self, method, ndim):
123125
ds = getattr(self, f"ds{ndim}d")
124-
getattr(ds.resample(time="48H"), method)()
126+
getattr(ds.resample(time="48H"), method)().compute()
125127

126128

127129
class ResampleDask(Resample):

ci/requirements/all-but-dask.yml

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dependencies:
1010
- bottleneck
1111
- cartopy
1212
- cdms2
13-
- cfgrib
1413
- cftime
1514
- coveralls
1615
- flox

ci/requirements/doc.yml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ dependencies:
77
- python=3.10
88
- bottleneck
99
- cartopy
10-
- cfgrib>=0.9
1110
- dask-core>=2022.1
1211
- h5netcdf>=0.13
1312
- ipykernel

ci/requirements/environment-py311.yml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dependencies:
88
- bottleneck
99
- cartopy
1010
# - cdms2
11-
- cfgrib
1211
- cftime
1312
- dask-core
1413
- distributed

ci/requirements/environment-windows-py311.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ dependencies:
66
- bottleneck
77
- cartopy
88
# - cdms2 # Not available on Windows
9-
# - cfgrib # Causes Python interpreter crash on Windows: https://github.com/pydata/xarray/pull/3340
109
- cftime
1110
- dask-core
1211
- distributed

ci/requirements/environment-windows.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ dependencies:
66
- bottleneck
77
- cartopy
88
# - cdms2 # Not available on Windows
9-
# - cfgrib # Causes Python interpreter crash on Windows: https://github.com/pydata/xarray/pull/3340
109
- cftime
1110
- dask-core
1211
- distributed

ci/requirements/environment.yml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dependencies:
88
- bottleneck
99
- cartopy
1010
- cdms2
11-
- cfgrib
1211
- cftime
1312
- dask-core
1413
- distributed

ci/requirements/min-all-deps.yml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ dependencies:
1212
- bottleneck=1.3
1313
- cartopy=0.20
1414
- cdms2=3.1
15-
- cfgrib=0.9
1615
- cftime=1.5
1716
- coveralls
1817
- dask-core=2022.1

doc/_static/style.css

-5
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,16 @@ https://github.com/bokeh/bokeh/blob/branch-2.4/sphinx/source/bokeh/static/custom
172172
display: block;
173173
padding: 0.25rem 1.5rem;
174174
font-size: 90%;
175-
color: rgba(0, 0, 0, 0.65);
176175
}
177176

178177
.bd-sidebar .nav > li > a:hover {
179-
color: rgba(0, 0, 0, 0.85);
180178
text-decoration: none;
181179
background-color: transparent;
182180
}
183181

184182
.bd-sidebar .nav > .active > a,
185183
.bd-sidebar .nav > .active:hover > a {
186184
font-weight: 400;
187-
color: #130654;
188185
/* adjusted from original
189186
color: rgba(0, 0, 0, 0.85);
190187
background-color: transparent; */
@@ -199,13 +196,11 @@ https://github.com/bokeh/bokeh/blob/branch-2.4/sphinx/source/bokeh/static/custom
199196
display: block;
200197
padding: 0.25rem 1.5rem;
201198
font-size: 90%;
202-
color: rgba(0, 0, 0, 0.65);
203199
}
204200

205201
.bd-sidebar .nav > li > ul > .active > a,
206202
.bd-sidebar .nav > li > ul > .active:hover > a {
207203
font-weight: 400;
208-
color: #542437;
209204
}
210205

211206
dt:target {

doc/getting-started-guide/installing.rst

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ For netCDF and IO
4545
other gridded raster datasets.
4646
- `iris <https://github.com/scitools/iris>`__: for conversion to and from iris'
4747
Cube objects
48-
- `cfgrib <https://github.com/ecmwf/cfgrib>`__: for reading GRIB files via the
49-
*ECMWF ecCodes* library.
5048

5149
For accelerating xarray
5250
~~~~~~~~~~~~~~~~~~~~~~~

doc/user-guide/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ GRIB format via cfgrib
12571257

12581258
Xarray supports reading GRIB files via ECMWF cfgrib_ python driver,
12591259
if it is installed. To open a GRIB file supply ``engine='cfgrib'``
1260-
to :py:func:`open_dataset`:
1260+
to :py:func:`open_dataset` after installing cfgrib_:
12611261

12621262
.. ipython::
12631263
:verbatim:

doc/whats-new.rst

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ Bug fixes
3939

4040
- Fix :py:meth:`xr.polyval` with non-system standard integer coeffs (:pull:`7619`).
4141
By `Shreyal Gupta <https://github.com/Ravenin7>`_ and `Michael Niklas <https://github.com/headtr1ck>`_.
42+
- Improve error message when trying to open a file which you do not have permission to read (:issue:`6523`, :pull:`7629`).
43+
By `Thomas Coleman <https://github.com/ColemanTom>`_.
44+
- Proper plotting when passing :py:class:`~matplotlib.colors.BoundaryNorm` type argument in :py:meth:`DataArray.plot`. (:issue:`4061`, :issue:`7014`,:pull:`7553`)
45+
By `Jelmer Veenstra <https://github.com/veenstrajelmer>`_.
4246

4347
Documentation
4448
~~~~~~~~~~~~~
@@ -49,6 +53,10 @@ Documentation
4953
Internal Changes
5054
~~~~~~~~~~~~~~~~
5155

56+
- Remove internal support for reading GRIB files through the ``cfgrib`` backend. ``cfgrib`` now uses the external
57+
backend interface, so no existing code should break.
58+
By `Deepak Cherian <https://github.com/dcherian>`_.
59+
5260
.. _whats-new.2023.03.0:
5361

5462
v2023.03.0 (March 22, 2023)

setup.cfg

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ io =
8989
fsspec
9090
cftime
9191
rasterio
92-
cfgrib
9392
pooch
9493
## Scitools packages & dependencies (e.g: cartopy, cf-units) can be hard to install
9594
# scitools-iris

xarray/backends/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
DataStores provide a uniform interface for saving and loading data in different
44
formats. They should not be used directly, but rather through Dataset objects.
55
"""
6-
from xarray.backends.cfgrib_ import CfGribDataStore
76
from xarray.backends.common import AbstractDataStore, BackendArray, BackendEntrypoint
87
from xarray.backends.file_manager import (
98
CachingFileManager,
@@ -30,7 +29,6 @@
3029
"BackendEntrypoint",
3130
"FileManager",
3231
"CachingFileManager",
33-
"CfGribDataStore",
3432
"DummyFileManager",
3533
"InMemoryDataStore",
3634
"NetCDF4DataStore",

xarray/backends/api.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
T_NetcdfEngine = Literal["netcdf4", "scipy", "h5netcdf"]
4444
T_Engine = Union[
4545
T_NetcdfEngine,
46-
Literal["pydap", "pynio", "pseudonetcdf", "cfgrib", "zarr"],
46+
Literal["pydap", "pynio", "pseudonetcdf", "zarr"],
4747
type[BackendEntrypoint],
4848
str, # no nice typing support for custom backends
4949
None,
@@ -64,7 +64,6 @@
6464
"h5netcdf": backends.H5NetCDFStore.open,
6565
"pynio": backends.NioDataStore,
6666
"pseudonetcdf": backends.PseudoNetCDFDataStore.open,
67-
"cfgrib": backends.CfGribDataStore,
6867
"zarr": backends.ZarrStore.open_group,
6968
}
7069

@@ -387,7 +386,7 @@ def open_dataset(
387386
ends with .gz, in which case the file is gunzipped and opened with
388387
scipy.io.netcdf (only netCDF3 supported). Byte-strings or file-like
389388
objects are opened by scipy.io.netcdf (netCDF3) or h5py (netCDF4/HDF).
390-
engine : {"netcdf4", "scipy", "pydap", "h5netcdf", "pynio", "cfgrib", \
389+
engine : {"netcdf4", "scipy", "pydap", "h5netcdf", "pynio", \
391390
"pseudonetcdf", "zarr", None}, installed backend \
392391
or subclass of xarray.backends.BackendEntrypoint, optional
393392
Engine to use when reading files. If not provided, the default engine
@@ -479,7 +478,7 @@ def open_dataset(
479478
relevant when using dask or another form of parallelism. By default,
480479
appropriate locks are chosen to safely read and write files with the
481480
currently active dask scheduler. Supported by "netcdf4", "h5netcdf",
482-
"scipy", "pynio", "pseudonetcdf", "cfgrib".
481+
"scipy", "pynio", "pseudonetcdf".
483482
484483
See engine open function for kwargs accepted by each specific engine.
485484
@@ -576,7 +575,7 @@ def open_dataarray(
576575
ends with .gz, in which case the file is gunzipped and opened with
577576
scipy.io.netcdf (only netCDF3 supported). Byte-strings or file-like
578577
objects are opened by scipy.io.netcdf (netCDF3) or h5py (netCDF4/HDF).
579-
engine : {"netcdf4", "scipy", "pydap", "h5netcdf", "pynio", "cfgrib", \
578+
engine : {"netcdf4", "scipy", "pydap", "h5netcdf", "pynio", \
580579
"pseudonetcdf", "zarr", None}, installed backend \
581580
or subclass of xarray.backends.BackendEntrypoint, optional
582581
Engine to use when reading files. If not provided, the default engine
@@ -666,7 +665,7 @@ def open_dataarray(
666665
relevant when using dask or another form of parallelism. By default,
667666
appropriate locks are chosen to safely read and write files with the
668667
currently active dask scheduler. Supported by "netcdf4", "h5netcdf",
669-
"scipy", "pynio", "pseudonetcdf", "cfgrib".
668+
"scipy", "pynio", "pseudonetcdf".
670669
671670
See engine open function for kwargs accepted by each specific engine.
672671
@@ -803,7 +802,7 @@ def open_mfdataset(
803802
If provided, call this function on each dataset prior to concatenation.
804803
You can find the file-name from which each dataset was loaded in
805804
``ds.encoding["source"]``.
806-
engine : {"netcdf4", "scipy", "pydap", "h5netcdf", "pynio", "cfgrib", \
805+
engine : {"netcdf4", "scipy", "pydap", "h5netcdf", "pynio", \
807806
"pseudonetcdf", "zarr", None}, installed backend \
808807
or subclass of xarray.backends.BackendEntrypoint, optional
809808
Engine to use when reading files. If not provided, the default engine

0 commit comments

Comments
 (0)