Skip to content

Commit 54591a7

Browse files
committed
Merge branch 'master' of github.com:pydata/xarray into ufunc-vectorize-meta
* 'master' of github.com:pydata/xarray: Feature/align in dot (pydata#3699) ENH: enable `H5NetCDFStore` to work with already open h5netcdf.File a… (pydata#3618) One-off isort run (pydata#3705) hardcoded xarray.__all__ (pydata#3703) Bump mypy to v0.761 (pydata#3704) remove DataArray and Dataset constructor deprecations for 0.15 (pydata#3560) Tests for variables with units (pydata#3654)
2 parents 9e8316b + aa0f963 commit 54591a7

24 files changed

+1194
-90
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
hooks:
1212
- id: flake8
1313
- repo: https://github.com/pre-commit/mirrors-mypy
14-
rev: v0.730 # Must match ci/requirements/*.yml
14+
rev: v0.761 # Must match ci/requirements/*.yml
1515
hooks:
1616
- id: mypy
1717
# run these occasionally, ref discussion https://github.com/pydata/xarray/pull/3194

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies:
2525
- iris=2.2
2626
- lxml=4.4 # Optional dep of pydap
2727
- matplotlib=3.1
28-
- mypy=0.730 # Must match .pre-commit-config.yaml
28+
- mypy=0.761 # Must match .pre-commit-config.yaml
2929
- nc-time-axis=1.2
3030
- netcdf4=1.4
3131
- numba=0.44

ci/requirements/py36.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dependencies:
2121
- iris
2222
- lxml # optional dep of pydap
2323
- matplotlib
24-
- mypy=0.730 # Must match .pre-commit-config.yaml
24+
- mypy=0.761 # Must match .pre-commit-config.yaml
2525
- nc-time-axis
2626
- netcdf4
2727
- numba

ci/requirements/py37-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dependencies:
2121
- iris
2222
- lxml # Optional dep of pydap
2323
- matplotlib
24-
- mypy=0.730 # Must match .pre-commit-config.yaml
24+
- mypy=0.761 # Must match .pre-commit-config.yaml
2525
- nc-time-axis
2626
- netcdf4
2727
- numba

ci/requirements/py37.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dependencies:
2121
- iris
2222
- lxml # Optional dep of pydap
2323
- matplotlib
24-
- mypy=0.730 # Must match .pre-commit-config.yaml
24+
- mypy=0.761 # Must match .pre-commit-config.yaml
2525
- nc-time-axis
2626
- netcdf4
2727
- numba

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
os.environ["PYTHONPATH"] = str(root)
2626
sys.path.insert(0, str(root))
2727

28-
import xarray
28+
import xarray # isort:skip
2929

3030
allowed_failures = set()
3131

doc/whats-new.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,23 @@ v0.15.0 (unreleased)
2222
Breaking changes
2323
~~~~~~~~~~~~~~~~
2424
- Bumped minimum ``dask`` version to 2.2.
25+
- Remove ``compat`` and ``encoding`` kwargs from ``DataArray``, which
26+
have been deprecated since 0.12. (:pull:`3650`).
27+
Instead, specify the encoding when writing to disk or set
28+
the ``encoding`` attribute directly.
29+
By `Maximilian Roos <https://github.com/max-sixty>`_
30+
- :py:func:`xarray.dot`, :py:meth:`DataArray.dot`, and the ``@`` operator now
31+
use ``align="inner"`` (except when ``xarray.set_options(arithmetic_join="exact")``;
32+
:issue:`3694`) by `Mathias Hauser <https://github.com/mathause>`_.
33+
2534

2635
New Features
2736
~~~~~~~~~~~~
37+
- Support using an existing, opened h5netcdf ``File`` with
38+
:py:class:`~xarray.backends.H5NetCDFStore`. This permits creating an
39+
:py:class:`~xarray.Dataset` from a h5netcdf ``File`` that has been opened
40+
using other means (:issue:`3618`).
41+
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
2842
- Implement :py:func:`median` and :py:func:`nanmedian` for dask arrays. This works by rechunking
2943
to a single chunk along all reduction axes. (:issue:`2999`).
3044
By `Deepak Cherian <https://github.com/dcherian>`_.
@@ -86,6 +100,8 @@ Bug fixes
86100
- Fix a regression in :py:meth:`Dataset.drop`: allow passing any
87101
iterable when dropping variables (:issue:`3552`, :pull:`3693`)
88102
By `Justus Magin <https://github.com/keewis>`_.
103+
- Fixed errors emitted by ``mypy --strict`` in modules that import xarray.
104+
(:issue:`3695`) by `Guido Imperiale <https://github.com/crusaderky>`_.
89105

90106
Documentation
91107
~~~~~~~~~~~~~

properties/test_pandas_roundtrip.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
"""
22
Property-based tests for roundtripping between xarray and pandas objects.
33
"""
4-
import pytest
5-
6-
pytest.importorskip("hypothesis")
7-
84
from functools import partial
9-
import hypothesis.extra.numpy as npst
10-
import hypothesis.extra.pandas as pdst
11-
import hypothesis.strategies as st
12-
from hypothesis import given
135

146
import numpy as np
157
import pandas as pd
8+
import pytest
9+
1610
import xarray as xr
1711

12+
pytest.importorskip("hypothesis")
13+
import hypothesis.extra.numpy as npst # isort:skip
14+
import hypothesis.extra.pandas as pdst # isort:skip
15+
import hypothesis.strategies as st # isort:skip
16+
from hypothesis import given # isort:skip
17+
1818
numeric_dtypes = st.one_of(
1919
npst.unsigned_integer_dtypes(), npst.integer_dtypes(), npst.floating_dtypes()
2020
)

xarray/__init__.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
""" isort:skip_file """
2-
# flake8: noqa
32

43
from ._version import get_versions
54

@@ -42,3 +41,55 @@
4241
from . import testing
4342

4443
from .core.common import ALL_DIMS
44+
45+
# A hardcoded __all__ variable is necessary to appease
46+
# `mypy --strict` running in projects that import xarray.
47+
__all__ = (
48+
# Sub-packages
49+
"ufuncs",
50+
"testing",
51+
"tutorial",
52+
# Top-level functions
53+
"align",
54+
"apply_ufunc",
55+
"as_variable",
56+
"auto_combine",
57+
"broadcast",
58+
"cftime_range",
59+
"combine_by_coords",
60+
"combine_nested",
61+
"concat",
62+
"decode_cf",
63+
"dot",
64+
"full_like",
65+
"load_dataarray",
66+
"load_dataset",
67+
"map_blocks",
68+
"merge",
69+
"ones_like",
70+
"open_dataarray",
71+
"open_dataset",
72+
"open_mfdataset",
73+
"open_rasterio",
74+
"open_zarr",
75+
"register_dataarray_accessor",
76+
"register_dataset_accessor",
77+
"save_mfdataset",
78+
"set_options",
79+
"show_versions",
80+
"where",
81+
"zeros_like",
82+
# Classes
83+
"CFTimeIndex",
84+
"Coordinate",
85+
"DataArray",
86+
"Dataset",
87+
"IndexVariable",
88+
"Variable",
89+
# Exceptions
90+
"MergeError",
91+
"SerializationWarning",
92+
# Constants
93+
"__version__",
94+
"ALL_DIMS",
95+
)

xarray/backends/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def maybe_decode_store(store, lock=False):
503503
elif engine == "pydap":
504504
store = backends.PydapDataStore.open(filename_or_obj, **backend_kwargs)
505505
elif engine == "h5netcdf":
506-
store = backends.H5NetCDFStore(
506+
store = backends.H5NetCDFStore.open(
507507
filename_or_obj, group=group, lock=lock, **backend_kwargs
508508
)
509509
elif engine == "pynio":
@@ -527,7 +527,7 @@ def maybe_decode_store(store, lock=False):
527527
if engine == "scipy":
528528
store = backends.ScipyDataStore(filename_or_obj, **backend_kwargs)
529529
elif engine == "h5netcdf":
530-
store = backends.H5NetCDFStore(
530+
store = backends.H5NetCDFStore.open(
531531
filename_or_obj, group=group, lock=lock, **backend_kwargs
532532
)
533533

@@ -981,7 +981,7 @@ def open_mfdataset(
981981
WRITEABLE_STORES: Dict[str, Callable] = {
982982
"netcdf4": backends.NetCDF4DataStore.open,
983983
"scipy": backends.ScipyDataStore,
984-
"h5netcdf": backends.H5NetCDFStore,
984+
"h5netcdf": backends.H5NetCDFStore.open,
985985
}
986986

987987

0 commit comments

Comments
 (0)