Skip to content

Commit 81b8b54

Browse files
committed
Fixed compatibility issues with xarray 0.10
1 parent ceb0c02 commit 81b8b54

5 files changed

Lines changed: 42 additions & 4 deletions

File tree

.travis.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ language: generic
22
matrix:
33
include:
44
# linux environments
5+
- env:
6+
- PYTHON_VERSION=3.6
7+
- XARRAY_VERSION=0.10
8+
os: linux
59
- env:
610
- PYTHON_VERSION=3.6
711
- XARRAY_VERSION=0.9
@@ -18,6 +22,10 @@ matrix:
1822
- PYTHON_VERSION=3.5
1923
- XARRAY_VERSION=0.8
2024
os: linux
25+
- env:
26+
- PYTHON_VERSION=2.7
27+
- XARRAY_VERSION=0.10
28+
os: linux
2129
- env:
2230
- PYTHON_VERSION=2.7
2331
- XARRAY_VERSION=0.9
@@ -27,13 +35,17 @@ matrix:
2735
- XARRAY_VERSION=0.8
2836
os: linux
2937
# osx environments
38+
- env:
39+
- PYTHON_VERSION=3.6
40+
- XARRAY_VERSION=0.10
41+
os: osx
3042
- env:
3143
- PYTHON_VERSION=3.6
3244
- XARRAY_VERSION=0.9
3345
os: osx
3446
- env:
3547
- PYTHON_VERSION=2.7
36-
- XARRAY_VERSION=0.9
48+
- XARRAY_VERSION=0.10
3749
os: osx
3850
addons: # install cdo
3951
apt:

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ environment:
1212
XARRAY_VERSION: "0.8"
1313
- PYTHON_VERSION: "3.6"
1414
XARRAY_VERSION: "0.9"
15+
- PYTHON_VERSION: "3.6"
16+
XARRAY_VERSION: "0.10"
1517
install:
1618
# Install miniconda Python
1719
- "powershell ./ci/install_python.ps1"

psyplot/data.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ def _get_dims(arr):
9191
return tuple(filter(lambda d: d != VARIABLELABEL, arr.dims))
9292

9393

94+
def _open_store(store_mod, store_cls, fname):
95+
try:
96+
return getattr(import_module(store_mod), store_cls).open(fname)
97+
except AttributeError:
98+
return getattr(import_module(store_mod), store_cls)(fname)
99+
100+
94101
@docstrings.get_sectionsf('setup_coords')
95102
@dedent
96103
def setup_coords(arr_names=None, sort=[], dims={}, **kwargs):
@@ -4066,13 +4073,13 @@ def _open_ds_from_store(fname, store_mod=None, store_cls=None, **kwargs):
40664073
store_mod = repeat(store_mod)
40674074
if isstring(store_cls):
40684075
store_cls = repeat(store_cls)
4069-
fname = [getattr(import_module(sm), sc)(f)
4076+
fname = [_open_store(sm, sc, f)
40704077
for sm, sc, f in zip(store_mod, store_cls, fname)]
40714078
kwargs['engine'] = None
40724079
kwargs['lock'] = False
40734080
return open_mfdataset(fname, **kwargs)
40744081
if store_mod is not None and store_cls is not None:
4075-
fname = getattr(import_module(store_mod), store_cls)(fname)
4082+
fname = _open_store(store_mod, store_cls, fname)
40764083
return open_dataset(fname, **kwargs)
40774084

40784085

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: psyplot_py3.6_xr0.10
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python=3.6
6+
- matplotlib
7+
- dask
8+
- xarray=0.10.*
9+
- netCDF4
10+
- seaborn
11+
- scipy # necessary for scipy engine test
12+
- gdal # for psyplot.gdal_store
13+
- pip:
14+
- pytest

tests/test_data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,10 @@ def _test_engine(self, engine):
11851185
store_mod, store = ds.psy.data_store
11861186
# try to load the dataset
11871187
mod = import_module(store_mod)
1188-
ds2 = psyd.open_dataset(getattr(mod, store)(fname))
1188+
try:
1189+
ds2 = psyd.open_dataset(getattr(mod, store).open(fname))
1190+
except AttributeError:
1191+
ds2 = psyd.open_dataset(getattr(mod, store)(fname))
11891192
ds.close()
11901193
ds2.close()
11911194
ds.psy.filename = None

0 commit comments

Comments
 (0)