Skip to content

Commit 56bc724

Browse files
author
dcherian
committed
Squashed commit of the following:
commit 620b946 Author: Stephan Hoyer <[email protected]> Date: Sun Jan 27 13:02:03 2019 -0800 Fix test failures / warnings for pandas 0.24 (#2720) * Fix test failures / warnings for pandas 0.24 Fixes GH2717 * Brief doc note * Comment on name order commit 882deac Author: Stephan Hoyer <[email protected]> Date: Sun Jan 27 09:11:47 2019 -0800 DOC: refresh whats-new for 0.11.3 / 0.12.0 (#2718) commit 8ca8efe Author: Stephan Hoyer <[email protected]> Date: Sat Jan 26 10:14:49 2019 -0800 Update environment for doc build (#2708) * Update environment for doc build We were pinning very old versions for most of these packages. This should fix the failures on ReadTheDocs. * Build fixes commit 2e99c7d Author: Stephan Hoyer <[email protected]> Date: Fri Jan 25 13:52:17 2019 -0800 Print full environment fron conf.py (#2709) This should make it easier to debug the doc build environment. commit cc5015a Author: Stephan Hoyer <[email protected]> Date: Fri Jan 25 11:55:07 2019 -0800 BUG: ensure indexes are reset when coords are modified (#2707) This was introduced by the recent indexes refactor, but never made it into a release. commit aabda43 Author: Joe Hamman <[email protected]> Date: Fri Jan 25 08:38:45 2019 -0800 Remove py2 compat (#2645) * strip out PY2 compat code from pycompat.py * isort * remove 2 unused imports * remove extra import * no more future * no unicode literals * no more ReprMixin * cleanup merge * remove deprecated imports from collections * 2 more cleanups from shoyer
1 parent 3309d2a commit 56bc724

Some content is hidden

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

98 files changed

+463
-883
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ script:
6060
- python --version
6161
- python -OO -c "import xarray"
6262
- if [[ "$CONDA_ENV" == "docs" ]]; then
63-
conda install -c conda-forge --override-channels sphinx sphinx_rtd_theme sphinx-gallery numpydoc "gdal>2.2.4";
64-
sphinx-build -n -j auto -b html -d _build/doctrees doc _build/html;
63+
cd doc;
64+
sphinx-build -n -j auto -b html -d _build/doctrees . _build/html;
6565
elif [[ "$CONDA_ENV" == "lint" ]]; then
6666
pycodestyle xarray ;
6767
elif [[ "$CONDA_ENV" == "py36-hypothesis" ]]; then

ci/requirements-py36.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ dependencies:
2626
- pseudonetcdf>=3.0.1
2727
- eccodes
2828
- cdms2
29-
# - pynio # xref #2683
30-
# - iris>=1.10 # xref #2683
29+
# - pynio # xref #2683
30+
# - iris>=1.10 # xref #2683
3131
- pydap
3232
- lxml
3333
- pip:

doc/conf.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
# serve to show the default.
1414
from __future__ import absolute_import, division, print_function
1515

16+
from contextlib import suppress
1617
import datetime
17-
import importlib
1818
import os
19+
import subprocess
1920
import sys
2021

2122
import xarray
@@ -24,29 +25,33 @@
2425

2526
print("python exec:", sys.executable)
2627
print("sys.path:", sys.path)
27-
for name in ('numpy scipy pandas matplotlib dask IPython seaborn '
28-
'cartopy netCDF4 rasterio zarr iris flake8 '
29-
'sphinx_gallery cftime').split():
30-
try:
31-
module = importlib.import_module(name)
32-
if name == 'matplotlib':
33-
module.use('Agg')
34-
fname = module.__file__.rstrip('__init__.py')
35-
print("%s: %s, %s" % (name, module.__version__, fname))
36-
except ImportError:
37-
print("no %s" % name)
38-
# neither rasterio nor cartopy should be hard requirements for
39-
# the doc build.
40-
if name == 'rasterio':
41-
allowed_failures.update(['gallery/plot_rasterio_rgb.py',
42-
'gallery/plot_rasterio.py'])
43-
elif name == 'cartopy':
44-
allowed_failures.update(['gallery/plot_cartopy_facetgrid.py',
45-
'gallery/plot_rasterio_rgb.py',
46-
'gallery/plot_rasterio.py'])
28+
29+
if 'conda' in sys.executable:
30+
print('conda environment:')
31+
subprocess.run(['conda', 'list'])
32+
else:
33+
print('pip environment:')
34+
subprocess.run(['pip', 'list'])
4735

4836
print("xarray: %s, %s" % (xarray.__version__, xarray.__file__))
4937

38+
with suppress(ImportError):
39+
import matplotlib
40+
matplotlib.use('Agg')
41+
42+
try:
43+
import rasterio
44+
except ImportError:
45+
allowed_failures.update(['gallery/plot_rasterio_rgb.py',
46+
'gallery/plot_rasterio.py'])
47+
48+
try:
49+
import cartopy
50+
except ImportError:
51+
allowed_failures.update(['gallery/plot_cartopy_facetgrid.py',
52+
'gallery/plot_rasterio_rgb.py',
53+
'gallery/plot_rasterio.py'])
54+
5055
# -- General configuration ------------------------------------------------
5156

5257
# If your documentation needs a minimal Sphinx version, state it here.

doc/environment.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@ name: xarray-docs
22
channels:
33
- conda-forge
44
dependencies:
5-
- python=3.6
6-
- numpy=1.14.5
5+
- python=3.7
6+
- numpy=1.16.0
77
- pandas=0.23.3
8-
- scipy=1.1.0
9-
- matplotlib=2.2.2
8+
- scipy=1.2.0
9+
- matplotlib=3.0.2
1010
- seaborn=0.9.0
11-
- dask=0.18.2
12-
- ipython=6.4.0
13-
- netCDF4=1.4.0
14-
- cartopy=0.16.0
15-
- rasterio=1.0.1
11+
- dask=1.1.0
12+
- ipython=7.2.0
13+
- netCDF4=1.4.2
14+
- cartopy=0.17.0
15+
- rasterio=1.0.13
1616
- zarr=2.2.0
17-
- iris=2.1.0
18-
- flake8=3.5.0
17+
- iris=2.2.0
18+
- flake8=3.6.0
1919
- cftime=1.0.3.4
20-
- bottleneck=1.2
21-
- sphinx=1.7.6
20+
- bottleneck=1.2.1
21+
- sphinx=1.8.2
2222
- numpydoc=0.8.0
2323
- sphinx-gallery=0.2.0
24+
- pillow=5.4.1
25+
- sphinx_rtd_theme=0.4.2
26+
- mock=2.0.0

doc/examples/multidimensional-coords.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ grid, we can take advantage of xarray's ability to apply
7878
ax = plt.axes(projection=ccrs.PlateCarree());
7979
ds.Tair[0].plot.pcolormesh(ax=ax, transform=ccrs.PlateCarree(),
8080
x='xc', y='yc', add_colorbar=False);
81-
ax.coastlines();
8281
@savefig xarray_multidimensional_coords_12_0.png width=100%
83-
plt.tight_layout();
82+
ax.coastlines();
8483
8584
Multidimensional Groupby
8685
------------------------

doc/pandas.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ __ http://pandas.pydata.org/pandas-docs/stable/visualization.html
1414
__ http://stanford.edu/~mwaskom/software/seaborn/
1515

1616
.. ipython:: python
17-
:suppress:
17+
:suppress:
1818
1919
import numpy as np
2020
import pandas as pd
@@ -93,7 +93,6 @@ DataFrames:
9393
9494
s = ds['foo'].to_series()
9595
s
96-
9796
# or equivalently, with Series.to_xarray()
9897
xr.DataArray.from_series(s)
9998
@@ -173,11 +172,10 @@ So you can represent a Panel, in two ways:
173172
Let's take a look:
174173

175174
.. ipython:: python
176-
:okwarning:
175+
:okwarning:
177176
178177
panel = pd.Panel(np.random.rand(2, 3, 4), items=list('ab'), major_axis=list('mno'),
179178
minor_axis=pd.date_range(start='2000', periods=4, name='date'))
180-
181179
panel
182180
183181
As a DataArray:

doc/time-series.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ core functionality.
1515
import numpy as np
1616
import pandas as pd
1717
import xarray as xr
18-
1918
np.random.seed(123456)
2019
2120
Creating datetime64 data
@@ -241,7 +240,6 @@ coordinate with dates from a no-leap calendar and a
241240
242241
from itertools import product
243242
from cftime import DatetimeNoLeap
244-
245243
dates = [DatetimeNoLeap(year, month, 1) for year, month in
246244
product(range(1, 3), range(1, 13))]
247245
da = xr.DataArray(np.arange(24), coords=[dates], dims=['time'], name='foo')

doc/whats-new.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ What's New
1313
import xarray as xr
1414
np.random.seed(123456)
1515
16-
.. _whats-new.0.11.3:
16+
.. _whats-new.0.12.0:
1717

18-
v0.11.3 (unreleased)
18+
v0.12.0 (unreleased)
1919
--------------------
2020

2121
Breaking changes
@@ -49,14 +49,30 @@ Enhancements
4949
Bug fixes
5050
~~~~~~~~~
5151

52+
- Silenced warnings that appear when using pandas 0.24.
53+
By `Stephan Hoyer <https://github.com/shoyer>`_
5254
- Interpolating via resample now internally specifies ``bounds_error=False``
5355
as an argument to ``scipy.interpolate.interp1d``, allowing for interpolation
5456
from higher frequencies to lower frequencies. Datapoints outside the bounds
5557
of the original time coordinate are now filled with NaN (:issue:`2197`). By
5658
`Spencer Clark <https://github.com/spencerkclark>`_.
59+
60+
.. _whats-new.0.11.3:
61+
62+
v0.11.3 (26 January 2019)
63+
-------------------------
64+
65+
Bug fixes
66+
~~~~~~~~~
67+
5768
- Saving files with times encoded with reference dates with timezones
5869
(e.g. '2000-01-01T00:00:00-05:00') no longer raises an error
5970
(:issue:`2649`). By `Spencer Clark <https://github.com/spencerkclark>`_.
71+
- Fixed performance regression with ``open_mfdataset`` (:issue:`2662`).
72+
By `Tom Nicholas <http://github.com/TomNicholas>`_.
73+
- Fixed supplying an explicit dimension in the ``concat_dim`` argument to
74+
to ``open_mfdataset`` (:issue:`2647`).
75+
By `Ben Root <https://github.com/WeatherGod>`_.
6076

6177
.. _whats-new.0.11.2:
6278

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
'Operating System :: OS Independent',
1616
'Intended Audience :: Science/Research',
1717
'Programming Language :: Python',
18-
'Programming Language :: Python :: 2',
19-
'Programming Language :: Python :: 2.7',
2018
'Programming Language :: Python :: 3',
2119
'Programming Language :: Python :: 3.5',
2220
'Programming Language :: Python :: 3.6',

xarray/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# flake8: noqa
2-
from __future__ import absolute_import
3-
from __future__ import division
4-
from __future__ import print_function
52

63
from ._version import get_versions
74
__version__ = get_versions()['version']

xarray/backends/api.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
from __future__ import absolute_import, division, print_function
2-
31
import os.path
42
import warnings
53
from glob import glob
64
from io import BytesIO
75
from numbers import Number
6+
from pathlib import Path
87

98
import numpy as np
109

1110
from .. import Dataset, backends, conventions
1211
from ..core import indexing
1312
from ..core.combine import (
1413
_CONCAT_DIM_DEFAULT, _auto_combine, _infer_concat_order_from_positions)
15-
from ..core.pycompat import basestring, path_type
1614
from ..core.utils import close_on_error, is_grib_path, is_remote_uri
1715
from .common import ArrayWriter
1816
from .locks import _get_scheduler
@@ -99,7 +97,7 @@ def _normalize_path(path):
9997
def _validate_dataset_names(dataset):
10098
"""DataArray.name and Dataset keys must be a string or None"""
10199
def check_name(name):
102-
if isinstance(name, basestring):
100+
if isinstance(name, str):
103101
if not name:
104102
raise ValueError('Invalid name for DataArray or Dataset key: '
105103
'string must be length 1 or greater for '
@@ -117,7 +115,7 @@ def _validate_attrs(dataset):
117115
a string, an ndarray or a list/tuple of numbers/strings.
118116
"""
119117
def check_attr(name, value):
120-
if isinstance(name, basestring):
118+
if isinstance(name, str):
121119
if not name:
122120
raise ValueError('Invalid name for attr: string must be '
123121
'length 1 or greater for serialization to '
@@ -126,7 +124,7 @@ def check_attr(name, value):
126124
raise TypeError("Invalid name for attr: {} must be a string for "
127125
"serialization to netCDF files".format(name))
128126

129-
if not isinstance(value, (basestring, Number, np.ndarray, np.number,
127+
if not isinstance(value, (str, Number, np.ndarray, np.number,
130128
list, tuple)):
131129
raise TypeError('Invalid value for attr: {} must be a number, '
132130
'a string, an ndarray or a list/tuple of '
@@ -279,7 +277,7 @@ def maybe_decode_store(store, lock=False):
279277
from dask.base import tokenize
280278
# if passed an actual file path, augment the token with
281279
# the file modification time
282-
if (isinstance(filename_or_obj, basestring) and
280+
if (isinstance(filename_or_obj, str) and
283281
not is_remote_uri(filename_or_obj)):
284282
mtime = os.path.getmtime(filename_or_obj)
285283
else:
@@ -295,13 +293,13 @@ def maybe_decode_store(store, lock=False):
295293

296294
return ds2
297295

298-
if isinstance(filename_or_obj, path_type):
296+
if isinstance(filename_or_obj, Path):
299297
filename_or_obj = str(filename_or_obj)
300298

301299
if isinstance(filename_or_obj, backends.AbstractDataStore):
302300
store = filename_or_obj
303301
ds = maybe_decode_store(store)
304-
elif isinstance(filename_or_obj, basestring):
302+
elif isinstance(filename_or_obj, str):
305303

306304
if (isinstance(filename_or_obj, bytes) and
307305
filename_or_obj.startswith(b'\x89HDF')):
@@ -310,7 +308,7 @@ def maybe_decode_store(store, lock=False):
310308
filename_or_obj.startswith(b'CDF')):
311309
# netCDF3 file images are handled by scipy
312310
pass
313-
elif isinstance(filename_or_obj, basestring):
311+
elif isinstance(filename_or_obj, str):
314312
filename_or_obj = _normalize_path(filename_or_obj)
315313

316314
if engine is None:
@@ -352,7 +350,7 @@ def maybe_decode_store(store, lock=False):
352350

353351
# Ensure source filename always stored in dataset object (GH issue #2550)
354352
if 'source' not in ds.encoding:
355-
if isinstance(filename_or_obj, basestring):
353+
if isinstance(filename_or_obj, str):
356354
ds.encoding['source'] = filename_or_obj
357355

358356
return ds
@@ -588,15 +586,15 @@ def open_mfdataset(paths, chunks=None, concat_dim=_CONCAT_DIM_DEFAULT,
588586
.. [1] http://xarray.pydata.org/en/stable/dask.html
589587
.. [2] http://xarray.pydata.org/en/stable/dask.html#chunking-and-performance
590588
""" # noqa
591-
if isinstance(paths, basestring):
589+
if isinstance(paths, str):
592590
if is_remote_uri(paths):
593591
raise ValueError(
594592
'cannot do wild-card matching for paths that are remote URLs: '
595593
'{!r}. Instead, supply paths as an explicit list of strings.'
596594
.format(paths))
597595
paths = sorted(glob(paths))
598596
else:
599-
paths = [str(p) if isinstance(p, path_type) else p for p in paths]
597+
paths = [str(p) if isinstance(p, Path) else p for p in paths]
600598

601599
if not paths:
602600
raise IOError('no files to open')
@@ -681,7 +679,7 @@ def to_netcdf(dataset, path_or_file=None, mode='w', format=None, group=None,
681679
682680
The ``multifile`` argument is only for the private use of save_mfdataset.
683681
"""
684-
if isinstance(path_or_file, path_type):
682+
if isinstance(path_or_file, Path):
685683
path_or_file = str(path_or_file)
686684

687685
if encoding is None:
@@ -698,7 +696,7 @@ def to_netcdf(dataset, path_or_file=None, mode='w', format=None, group=None,
698696
raise NotImplementedError(
699697
'to_netcdf() with compute=False is not yet implemented when '
700698
'returning bytes')
701-
elif isinstance(path_or_file, basestring):
699+
elif isinstance(path_or_file, str):
702700
if engine is None:
703701
engine = _get_default_engine(path_or_file)
704702
path_or_file = _normalize_path(path_or_file)
@@ -733,7 +731,7 @@ def to_netcdf(dataset, path_or_file=None, mode='w', format=None, group=None,
733731

734732
if unlimited_dims is None:
735733
unlimited_dims = dataset.encoding.get('unlimited_dims', None)
736-
if isinstance(unlimited_dims, basestring):
734+
if isinstance(unlimited_dims, str):
737735
unlimited_dims = [unlimited_dims]
738736

739737
writer = ArrayWriter()
@@ -896,7 +894,7 @@ def to_zarr(dataset, store=None, mode='w-', synchronizer=None, group=None,
896894
897895
See `Dataset.to_zarr` for full API docs.
898896
"""
899-
if isinstance(store, path_type):
897+
if isinstance(store, Path):
900898
store = str(store)
901899
if encoding is None:
902900
encoding = {}

xarray/backends/cfgrib_.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import, division, print_function
2-
31
import numpy as np
42

53
from .. import Variable

0 commit comments

Comments
 (0)