Skip to content

Commit f34595f

Browse files
committed
Merge branch 'main' into single-matplotlib-import
2 parents 8a41948 + 07de257 commit f34595f

Some content is hidden

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

42 files changed

+501
-303
lines changed

.github/workflows/ci-additional.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
$PYTEST_EXTRA_FLAGS
103103
104104
- name: Upload code coverage to Codecov
105-
uses: codecov/codecov-action@v2.0.3
105+
uses: codecov/codecov-action@v2.1.0
106106
with:
107107
file: ./coverage.xml
108108
flags: unittests,${{ matrix.env }}

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
path: pytest.xml
101101

102102
- name: Upload code coverage to Codecov
103-
uses: codecov/codecov-action@v2.0.3
103+
uses: codecov/codecov-action@v2.1.0
104104
with:
105105
file: ./coverage.xml
106106
flags: unittests

.pre-commit-config.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
- id: isort
1414
# https://github.com/python/black#version-control-integration
1515
- repo: https://github.com/psf/black
16-
rev: 21.8b0
16+
rev: 21.9b0
1717
hooks:
1818
- id: black
1919
- repo: https://github.com/keewis/blackdoc
@@ -30,20 +30,21 @@ repos:
3030
# - id: velin
3131
# args: ["--write", "--compact"]
3232
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v0.910
33+
rev: v0.910-1
3434
hooks:
3535
- id: mypy
36-
# Copied from setup.cfg
37-
exclude: "properties|asv_bench"
36+
# `properies` & `asv_bench` are copied from setup.cfg.
37+
# `_typed_ops.py` is added since otherwise mypy will complain (but notably only in pre-commit)
38+
exclude: "properties|asv_bench|_typed_ops.py"
3839
additional_dependencies: [
3940
# Type stubs
4041
types-python-dateutil,
4142
types-pkg_resources,
4243
types-PyYAML,
4344
types-pytz,
45+
typing-extensions==3.10.0.0,
4446
# Dependencies that are typed
4547
numpy,
46-
typing-extensions==3.10.0.0,
4748
]
4849
# run this occasionally, ref discussion https://github.com/pydata/xarray/pull/3194
4950
# - repo: https://github.com/asottile/pyupgrade

asv_bench/benchmarks/groupby.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import numpy as np
2+
3+
import xarray as xr
4+
5+
from . import parameterized, requires_dask
6+
7+
8+
class GroupBy:
9+
def setup(self, *args, **kwargs):
10+
self.ds = xr.Dataset(
11+
{
12+
"a": xr.DataArray(np.r_[np.arange(500.0), np.arange(500.0)]),
13+
"b": xr.DataArray(np.arange(1000.0)),
14+
}
15+
)
16+
17+
@parameterized(["method"], [("sum", "mean")])
18+
def time_agg(self, method):
19+
return getattr(self.ds.groupby("a"), method)()
20+
21+
22+
class GroupByDask(GroupBy):
23+
def setup(self, *args, **kwargs):
24+
requires_dask()
25+
super().setup(**kwargs)
26+
self.ds = self.ds.chunk({"dim_0": 50})
27+
28+
29+
class GroupByDataFrame(GroupBy):
30+
def setup(self, *args, **kwargs):
31+
super().setup(**kwargs)
32+
self.ds = self.ds.to_dataframe()
33+
34+
35+
class GroupByDaskDataFrame(GroupBy):
36+
def setup(self, *args, **kwargs):
37+
requires_dask()
38+
super().setup(**kwargs)
39+
self.ds = self.ds.chunk({"dim_0": 50}).to_dataframe()

ci/requirements/doc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies:
2323
- pooch
2424
- pip
2525
- pydata-sphinx-theme>=0.4.3
26+
- pyproj
2627
- rasterio>=1.1
2728
- seaborn
2829
- setuptools

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@
260260
ogp_image = "https://xarray.pydata.org/en/stable/_static/dataset-diagram-logo.png"
261261
ogp_custom_meta_tags = [
262262
'<meta name="twitter:card" content="summary_large_image" />',
263-
'<meta property="twitter:site" content="@xarray_dev />',
264-
'<meta name="image" property="og:image" content="https://xarray.pydata.org/en/stable/_static/dataset-diagram-logo.png">',
263+
'<meta property="twitter:site" content="@xarray_dev" />',
264+
'<meta name="image" property="og:image" content="https://xarray.pydata.org/en/stable/_static/dataset-diagram-logo.png" />',
265265
]
266266

267267
# Redirects for pages that were moved to new locations

doc/ecosystem.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Geosciences
5050
Machine Learning
5151
~~~~~~~~~~~~~~~~
5252
- `ArviZ <https://arviz-devs.github.io/arviz/>`_: Exploratory analysis of Bayesian models, built on top of xarray.
53+
- `Darts <https://github.com/unit8co/darts/>`_: User-friendly modern machine learning for time series in Python.
5354
- `Elm <https://ensemble-learning-models.readthedocs.io>`_: Parallel machine learning on xarray data structures
5455
- `sklearn-xarray (1) <https://phausamann.github.io/sklearn-xarray>`_: Combines scikit-learn and xarray (1).
5556
- `sklearn-xarray (2) <https://sklearn-xarray.readthedocs.io/en/latest/>`_: Combines scikit-learn and xarray (2).

doc/examples/visualization_gallery.ipynb

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@
191191
},
192192
{
193193
"cell_type": "markdown",
194-
"metadata": {},
194+
"metadata": {
195+
"jp-MarkdownHeadingCollapsed": true,
196+
"tags": []
197+
},
195198
"source": [
196199
"## `imshow()` and rasterio map projections\n",
197200
"\n",
@@ -213,7 +216,7 @@
213216
"\n",
214217
"# The data is in UTM projection. We have to set it manually until\n",
215218
"# https://github.com/SciTools/cartopy/issues/813 is implemented\n",
216-
"crs = ccrs.UTM('18N')\n",
219+
"crs = ccrs.UTM('18')\n",
217220
"\n",
218221
"# Plot on a map\n",
219222
"ax = plt.subplot(projection=crs)\n",
@@ -242,20 +245,14 @@
242245
"metadata": {},
243246
"outputs": [],
244247
"source": [
245-
"from rasterio.warp import transform\n",
248+
"from pyproj import Transformer\n",
246249
"import numpy as np\n",
247250
"\n",
248251
"da = xr.tutorial.open_rasterio(\"RGB.byte\")\n",
249252
"\n",
250-
"# Compute the lon/lat coordinates with rasterio.warp.transform\n",
251-
"ny, nx = len(da['y']), len(da['x'])\n",
252253
"x, y = np.meshgrid(da['x'], da['y'])\n",
253-
"\n",
254-
"# Rasterio works with 1D arrays\n",
255-
"lon, lat = transform(da.crs, {'init': 'EPSG:4326'},\n",
256-
" x.flatten(), y.flatten())\n",
257-
"lon = np.asarray(lon).reshape((ny, nx))\n",
258-
"lat = np.asarray(lat).reshape((ny, nx))\n",
254+
"transformer = Transformer.from_crs(da.crs, \"EPSG:4326\", always_xy=True)\n",
255+
"lon, lat = transformer.transform(x, y)\n",
259256
"da.coords['lon'] = (('y', 'x'), lon)\n",
260257
"da.coords['lat'] = (('y', 'x'), lat)\n",
261258
"\n",
@@ -265,14 +262,14 @@
265262
"# Plot on a map\n",
266263
"ax = plt.subplot(projection=ccrs.PlateCarree())\n",
267264
"greyscale.plot(ax=ax, x='lon', y='lat', transform=ccrs.PlateCarree(),\n",
268-
" cmap='Greys_r', add_colorbar=False)\n",
265+
" cmap='Greys_r', shading=\"auto\",add_colorbar=False)\n",
269266
"ax.coastlines('10m', color='r')"
270267
]
271268
}
272269
],
273270
"metadata": {
274271
"kernelspec": {
275-
"display_name": "Python 3",
272+
"display_name": "Python 3 (ipykernel)",
276273
"language": "python",
277274
"name": "python3"
278275
},
@@ -286,7 +283,7 @@
286283
"name": "python",
287284
"nbconvert_exporter": "python",
288285
"pygments_lexer": "ipython3",
289-
"version": "3.7.3"
286+
"version": "3.9.7"
290287
}
291288
},
292289
"nbformat": 4,

doc/gallery/plot_rasterio.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,17 @@
1818
import cartopy.crs as ccrs
1919
import matplotlib.pyplot as plt
2020
import numpy as np
21-
from rasterio.warp import transform
21+
from pyproj import Transformer
2222

2323
import xarray as xr
2424

2525
# Read the data
2626
url = "https://github.com/mapbox/rasterio/raw/master/tests/data/RGB.byte.tif"
2727
da = xr.open_rasterio(url)
2828

29-
# Compute the lon/lat coordinates with rasterio.warp.transform
30-
ny, nx = len(da["y"]), len(da["x"])
31-
x, y = np.meshgrid(da["x"], da["y"])
32-
33-
# Rasterio works with 1D arrays
34-
lon, lat = transform(da.crs, {"init": "EPSG:4326"}, x.flatten(), y.flatten())
35-
lon = np.asarray(lon).reshape((ny, nx))
36-
lat = np.asarray(lat).reshape((ny, nx))
29+
# Compute the lon/lat coordinates with pyproj
30+
transformer = Transformer.from_crs(da.crs, "EPSG:4326", always_xy=True)
31+
lon, lat = transformer.transform(*np.meshgrid(da["x"], da["y"]))
3732
da.coords["lon"] = (("y", "x"), lon)
3833
da.coords["lat"] = (("y", "x"), lat)
3934

doc/howdoi.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ How do I ...
4343
- :py:attr:`DataArray.data`
4444
* - convert to and extract the underlying NumPy array
4545
- :py:attr:`DataArray.values`
46+
* - convert to a pandas DataFrame
47+
- :py:attr:`Dataset.to_dataframe`
48+
* - sort values
49+
- :py:attr:`Dataset.sortby`
4650
* - find out if my xarray object is wrapping a Dask Array
4751
- :py:func:`dask.is_dask_collection`
4852
* - know how much memory my object requires

doc/team.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ The current core developers team comprises:
8282
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8383
:link-badge:`https://github.com/andersy005,"Anderson Banihirwe",cls=btn badge-light`
8484

85+
---
86+
.. image:: https://avatars.githubusercontent.com/u/14371165?v=4
87+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
88+
:link-badge:`https://github.com/Illviljan,"Jimmy Westling",cls=btn badge-light`
8589

8690

8791
The full list of contributors is on our `GitHub Contributors Page <https://github.com/pydata/xarray/graphs/contributors>`__.

doc/user-guide/dask.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependency in a future version of xarray.
1313

1414
For a full example of how to use xarray's Dask integration, read the
1515
`blog post introducing xarray and Dask`_. More up-to-date examples
16-
may be found at the `Pangeo project's use-cases <http://pangeo.io/use_cases/index.html>`_
16+
may be found at the `Pangeo project's gallery <http://gallery.pangeo.io/>`_
1717
and at the `Dask examples website <https://examples.dask.org/xarray.html>`_.
1818

1919
.. _blog post introducing xarray and Dask: http://stephanhoyer.com/2015/06/11/xray-dask-out-of-core-labeled-arrays/

doc/user-guide/io.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,12 @@ GeoTIFFs and other gridded raster datasets can be opened using `rasterio`_, if
742742
rasterio is installed. Here is an example of how to use
743743
:py:func:`open_rasterio` to read one of rasterio's `test files`_:
744744

745+
.. deprecated:: 0.19.1
746+
747+
Deprecated in favor of rioxarray.
748+
For information about transitioning, see:
749+
https://corteva.github.io/rioxarray/stable/getting_started/getting_started.html
750+
745751
.. ipython::
746752
:verbatim:
747753

@@ -769,12 +775,6 @@ coordinates defined in the file's projection provided by the ``crs`` attribute.
769775
See :ref:`/examples/visualization_gallery.ipynb#Parsing-rasterio-geocoordinates`
770776
for an example of how to convert these to longitudes and latitudes.
771777

772-
.. warning::
773-
774-
This feature has been added in xarray v0.9.6 and should still be
775-
considered experimental. Please report any bugs you may find
776-
on xarray's github repository.
777-
778778

779779
Additionally, you can use `rioxarray`_ for reading in GeoTiff, netCDF or other
780780
GDAL readable raster data using `rasterio`_ as well as for exporting to a geoTIFF.

doc/user-guide/reshaping.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,10 @@ One may sort a DataArray/Dataset via :py:meth:`~xarray.DataArray.sortby` and
275275
.. ipython:: python
276276
277277
ds = xr.Dataset(
278-
{"A": (("x", "y"), [[1, 2], [3, 4]]), "B": (("x", "y"), [[5, 6], [7, 8]])},
278+
{
279+
"A": (("x", "y"), [[1, 2], [3, 4]]),
280+
"B": (("x", "y"), [[5, 6], [7, 8]]),
281+
},
279282
coords={"x": ["b", "a"], "y": [1, 0]},
280283
)
281284
dax = xr.DataArray([100, 99], [("x", [0, 1])])

doc/whats-new.rst

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,23 @@ What's New
1919

2020
v0.19.1 (unreleased)
2121
---------------------
22+
.. TODO(by keewis): update deprecations if we decide to skip 0.19.1
2223
2324
New Features
2425
~~~~~~~~~~~~
2526
- Added a :py:func:`get_options` method to xarray's root namespace (:issue:`5698`, :pull:`5716`)
2627
By `Pushkar Kopparla <https://github.com/pkopparla>`_.
2728
- Xarray now does a better job rendering variable names that are long LaTeX sequences when plotting (:issue:`5681`, :pull:`5682`).
2829
By `Tomas Chor <https://github.com/tomchor>`_.
29-
- Add a option to disable the use of ``bottleneck`` (:pull:`5560`)
30+
- Add an option to disable the use of ``bottleneck`` (:pull:`5560`)
3031
By `Justus Magin <https://github.com/keewis>`_.
3132
- Added ``**kwargs`` argument to :py:meth:`open_rasterio` to access overviews (:issue:`3269`).
3233
By `Pushkar Kopparla <https://github.com/pkopparla>`_.
3334
- Added ``storage_options`` argument to :py:meth:`to_zarr` (:issue:`5601`).
3435
By `Ray Bell <https://github.com/raybellwaves>`_, `Zachary Blackwood <https://github.com/blackary>`_ and
3536
`Nathan Lis <https://github.com/wxman22>`_.
36-
37+
- Histogram plots are set with a title displaying the scalar coords if any, similarly to the other plots (:issue:`5791`, :pull:`5792`).
38+
By `Maxime Liquet <https://github.com/maximlt>`_.
3739

3840
Breaking changes
3941
~~~~~~~~~~~~~~~~
@@ -55,14 +57,35 @@ Breaking changes
5557
Deprecations
5658
~~~~~~~~~~~~
5759

60+
- Deprecate :py:func:`open_rasterio` (:issue:`4697`, :pull:`5808`).
61+
By `Alan Snow <https://github.com/snowman2>`_.
62+
- Set the default argument for `roll_coords` to `False` for :py:meth:`DataArray.roll`
63+
and :py:meth:`Dataset.roll`. (:pull:`5653`)
64+
By `Tom Nicholas <https://github.com/TomNicholas>`_.
65+
- :py:meth:`xarray.open_mfdataset` will now error instead of warn when a value for ``concat_dim`` is
66+
passed alongside ``combine='by_coords'``.
67+
By `Tom Nicholas <https://github.com/TomNicholas>`_.
5868

5969
Bug fixes
6070
~~~~~~~~~
6171

72+
- Fix ZeroDivisionError from saving dask array with empty dimension (:issue: `5741`).
73+
By `Joseph K Aicher <https://github.com/jaicher>`_.
74+
- Fixed performance bug where ``cftime`` import attempted within various core operations if ``cftime`` not
75+
installed (:pull:`5640`).
76+
By `Luke Sewell <https://github.com/lusewell>`_
77+
- When a custom engine was used in :py:func:`~xarray.open_dataset` the engine
78+
wasn't initialized properly, causing missing argument errors or inconsistent
79+
method signatures. (:pull:`5684`)
80+
By `Jimmy Westling <https://github.com/illviljan>`_.
81+
- Numbers are properly formatted in a plot's title (:issue:`5788`, :pull:`5789`).
82+
By `Maxime Liquet <https://github.com/maximlt>`_.
6283

6384
Documentation
6485
~~~~~~~~~~~~~
6586

87+
- Users are instructed to try ``use_cftime=True`` if a ``TypeError`` occurs when combining datasets and one of the types involved is a subclass of ``cftime.datetime`` (:pull:`5776`).
88+
By `Zeb Nicholls <https://github.com/znicholls>`_.
6689

6790
Internal Changes
6891
~~~~~~~~~~~~~~~~
@@ -80,6 +103,10 @@ Internal Changes
80103
By `Jimmy Westling <https://github.com/illviljan>`_.
81104
- Use isort's `float_to_top` config. (:pull:`5695`).
82105
By `Maximilian Roos <https://github.com/max-sixty>`_.
106+
- Refactor `xarray.core.duck_array_ops` to no longer special-case dispatching to
107+
dask versions of functions when acting on dask arrays, instead relying numpy
108+
and dask's adherence to NEP-18 to dispatch automatically. (:pull:`5571`)
109+
By `Tom Nicholas <https://github.com/TomNicholas>`_.
83110

84111
.. _whats-new.0.19.0:
85112

0 commit comments

Comments
 (0)