Skip to content

Commit

Permalink
Various updates and fixes (#223)
Browse files Browse the repository at this point in the history
* Various updates and fixes

* More
  • Loading branch information
fmaussion committed Sep 6, 2022
1 parent cc89db2 commit 411a598
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
fail-fast: false
matrix:
test-env:
- py37-all
- py38-all
- py38-xarray-dev
- py38-all-rc
- py39-all
- py310-all
use-mpl:
- "--mpl"
include:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ docs/.doctrees
docs/auto_examples
docs/modules
salem/version.py
.pytest_cache
27 changes: 27 additions & 0 deletions ci/requirements-py310-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: test_env
channels:
- conda-forge
dependencies:
- python=3.10
- six
- numpy
- scipy
- pyproj
- joblib
- netCDF4
- shapely
- geopandas
- rasterio
- pandas
- xarray
- dask
- matplotlib
- scikit-image
- Pillow
- cartopy
- pip
- pip:
- coveralls==3.2.0
- pytest-cov
- pytest-mpl
- motionless
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 = '758f7ddd0fa6b5b1bd4c63b6dcfe8d5eec0f4c59'
sample_data_gh_commit = 'd975954c9bbd6505b2e7a2e06aa42f4696a0ad6b'
sample_data_dir = path.join(cache_dir, 'salem-sample-data-' +
sample_data_gh_commit)

Expand Down
4 changes: 2 additions & 2 deletions salem/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import copy
import warnings
from functools import partial
from distutils.version import LooseVersion
from packaging.version import Version

# External libs
import pyproj
Expand Down Expand Up @@ -1509,7 +1509,7 @@ def proj_to_cartopy(proj):
if cl.__name__ == 'Mercator':
kw_proj.pop('false_easting', None)
kw_proj.pop('false_northing', None)
if LooseVersion(cartopy.__version__) < LooseVersion('0.15'):
if Version(cartopy.__version__) < Version('0.15'):
kw_proj.pop('latitude_true_scale', None)
elif cl.__name__ == 'Stereographic':
kw_proj.pop('scale_factor', None)
Expand Down
4 changes: 4 additions & 0 deletions salem/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,13 @@ def _check_data(self, data=None, crs=None, interp='nearest',
with warnings.catch_warnings():
mess = "invalid value encountered in reduce"
warnings.filterwarnings("ignore", message=mess)
mess = "All-NaN slice encountered"
warnings.filterwarnings("ignore", message=mess)
mess = ("Possible precision loss when converting from "
"int64 to float64")
warnings.filterwarnings("ignore", message=mess)
mess = "Passing `np.nan` to mean no clipping in np.clip"
warnings.filterwarnings("ignore", message=mess)
try:
data = imresize(data.filled(np.NaN),
(self.grid.ny, self.grid.nx),
Expand Down
8 changes: 4 additions & 4 deletions salem/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,10 @@ def roi(self, ds=None, **kwargs):
kwargs.setdefault('grid', grid)

mask = self.grid.region_of_interest(**kwargs)
coords = {self.y_dim: self._obj[self.y_dim].values,
self.x_dim: self._obj[self.x_dim].values}
mask = xr.DataArray(mask, coords=coords,
dims=(self.y_dim, self.x_dim))
# coords = {self.y_dim: self._obj[self.y_dim].values,
# self.x_dim: self._obj[self.x_dim].values}
# mask = xr.DataArray(mask, coords=coords,
# dims=(self.y_dim, self.x_dim))

out = self._obj.where(mask, other=other)

Expand Down
8 changes: 4 additions & 4 deletions salem/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import division
import unittest
from distutils.version import LooseVersion
from packaging.version import Version
import os
from salem import python_version
from six.moves.urllib.request import urlopen
Expand Down Expand Up @@ -40,11 +40,11 @@ def has_internet():

try:
import matplotlib
mpl_version = LooseVersion(matplotlib.__version__)
has_matplotlib = mpl_version >= LooseVersion('2')
mpl_version = Version(matplotlib.__version__)
has_matplotlib = mpl_version >= Version('2')
except ImportError:
has_matplotlib = False
mpl_version = LooseVersion('0.0.0')
mpl_version = Version('0.0.0')

try:
import rasterio
Expand Down
9 changes: 5 additions & 4 deletions salem/tests/test_graphics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import division
from distutils.version import LooseVersion
from packaging.version import Version

import warnings
import os
Expand All @@ -24,9 +24,9 @@
from mpl_toolkits.axes_grid1 import make_axes_locatable

import geopandas as gpd
MPL_VERSION = LooseVersion(mpl.__version__)
ftver = LooseVersion(mpl.ft2font.__freetype_version__)
if ftver >= LooseVersion('2.8.0'):
MPL_VERSION = Version(mpl.__version__)
ftver = Version(mpl.ft2font.__freetype_version__)
if ftver >= Version('2.8.0'):
freetype_subdir = 'freetype_28'
else:
freetype_subdir = 'freetype_old'
Expand Down Expand Up @@ -893,6 +893,7 @@ def test_plot_on_map():
@requires_matplotlib
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir)
def test_example_docs():

import salem
from salem.utils import get_demo_file
ds = salem.open_xr_dataset(get_demo_file('wrfout_d01.nc'))
Expand Down

0 comments on commit 411a598

Please sign in to comment.