Skip to content

Commit

Permalink
Update test matrix for new MPL (#154)
Browse files Browse the repository at this point in the history
* Update test matrix for new MPL

* Fix mpl

* Update base and pin mpl

* warnings
  • Loading branch information
fmaussion committed Aug 2, 2019
1 parent 8b5b358 commit 69666ac
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ examples/*checkpoints
# Tests stuffs
salem/tests/result_images
result_images
sandbox.py
sandbox*.py

# Packages
*.egg
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ matrix:
- env: CONDA_ENV=py36-xr MPL=
- env: CONDA_ENV=py36-xarray-dev MPL=--mpl
- env: CONDA_ENV=py36-all-rc MPL=--mpl
- env: CONDA_ENV=py37-all MPL=--mpl
allow_failures:
- env: CONDA_ENV=py27-all MPL=--mpl
- env: CONDA_ENV=py36-xr MPL=
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-py27-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies:
- scikit-image
- descartes
- cartopy
- pip
- pip:
- coveralls
- pytest-cov
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-py36-all-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- scikit-image
- descartes
- cartopy
- pip
- pip:
- coveralls
- pytest-cov
Expand Down
3 changes: 2 additions & 1 deletion ci/requirements-py36-all-xr10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ dependencies:
- pandas
- xarray=0.10.9
- dask
- matplotlib<3.0.0
- matplotlib=3.0.3
- scikit-image
- Pillow
- descartes
- cartopy
- pip
- pip:
- coveralls
- pytest-cov
Expand Down
3 changes: 2 additions & 1 deletion ci/requirements-py36-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ dependencies:
- pandas
- xarray
- dask
- matplotlib<3.0.0
- matplotlib=3.0.3
- scikit-image
- Pillow
- descartes
- cartopy
- pip
- pip:
- coveralls
- pytest-cov
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-py36-min.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies:
- netCDF4
- pandas
- xarray
- pip
- pip:
- coveralls
- pytest-cov
1 change: 1 addition & 0 deletions ci/requirements-py36-xarray-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
- scikit-image
- descartes
- cartopy
- pip
- pip:
- git+https://github.com/pydata/xarray.git
- coveralls
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-py36-xr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- pandas
- xarray
- dask
- pip
- pip:
- coveralls
- pytest-cov
28 changes: 28 additions & 0 deletions ci/requirements-py37-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: test_env
channels:
- conda-forge
dependencies:
- python=3.7
- six
- numpy
- scipy
- pyproj
- joblib
- netCDF4
- shapely
- geopandas
- rasterio
- pandas
- xarray
- dask
- matplotlib=3.0.3
- scikit-image
- Pillow
- descartes
- cartopy
- pip
- pip:
- coveralls
- pytest-cov
- pytest-mpl
- motionless
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
markers =
mpl_image_compare: matplotlib image comparison
2 changes: 1 addition & 1 deletion salem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _lazy_property(self):
if not path.exists(download_dir):
makedirs(download_dir)

sample_data_gh_commit = 'b6d201fd8c228d5a1a6ea97964ef769dfef186ec'
sample_data_gh_commit = '877863f465cb3fdf9be8abd13c433f5f3a5828d6'
sample_data_dir = path.join(cache_dir, 'salem-sample-data-' +
sample_data_gh_commit)

Expand Down
18 changes: 11 additions & 7 deletions salem/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ def _memory_shapefile_to_grid(shape_cpath, grid=None,

shape = read_shapefile(shape_cpath, cached=True)
e = grid.extent_in_crs(crs=shape.crs)
p = np.nonzero(~((shape['min_x'] > e[1]) |
(shape['max_x'] < e[0]) |
(shape['min_y'] > e[3]) |
(shape['max_y'] < e[2])))
p = np.nonzero(~((shape['min_x'].to_numpy() > e[1]) |
(shape['max_x'].to_numpy() < e[0]) |
(shape['min_y'].to_numpy() > e[3]) |
(shape['max_y'].to_numpy() < e[2])))
shape = shape.iloc[p]
shape = gis.transform_geopandas(shape, to_crs=grid, inplace=True)
return shape
Expand Down Expand Up @@ -217,7 +217,8 @@ def _wrf_grid_from_dataset(ds):
reflon = reflon[0, :, :]
reflat = reflat[0, :, :]
mylon, mylat = grid.ll_coordinates
atol = 1e-3

atol = 5e-3 if proj_id == 2 else 1e-3
check = np.isclose(reflon, mylon, atol=atol)
if not np.alltrue(check):
n_pix = np.sum(~check)
Expand Down Expand Up @@ -1144,8 +1145,11 @@ def open_mf_wrf_dataset(paths, chunks=None, compat='no_conflicts', lock=None,

if preprocess is not None:
datasets = [preprocess(ds) for ds in datasets]

combined = xr.auto_combine(datasets, concat_dim='time', compat=compat)
try:
combined = xr.combine_nested(datasets, concat_dim='time',
compat=compat)
except AttributeError:
combined = xr.auto_combine(datasets, concat_dim='time', compat=compat)
combined._file_obj = _MultiFileCloser(file_objs)
combined.attrs = datasets[0].attrs

Expand Down
4 changes: 2 additions & 2 deletions salem/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,8 @@ def test_cartopy_polar():

fig = plt.figure(figsize=(8, 8))

ods = open_wrf_dataset(get_demo_file('geo_em_d02_polarstereo.nc')).isel(time=0)
ods = open_wrf_dataset(get_demo_file('geo_em_d02_polarstereo.nc'))
ods = ods.isel(time=0)

ax = plt.subplot(2, 2, 1)
smap = ods.salem.get_map()
Expand All @@ -1044,5 +1045,4 @@ def test_cartopy_polar():
ax.gridlines()
ax.scatter(ds.XLONG_M, ds.XLAT_M, transform=cartopy.crs.PlateCarree(), s=5)

plt.tight_layout()
return fig

0 comments on commit 69666ac

Please sign in to comment.