Skip to content

Commit

Permalink
Update CI and solve some deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Jan 31, 2024
1 parent f5e7e09 commit 502672f
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 106 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ jobs:
fail-fast: false
matrix:
test-env:
- py38-all
- py38-xarray-dev
- py38-all-rc
- py39-all
- py310-all
- py311-all
- py312-all
use-mpl:
- "--mpl"
include:
- test-env: py38-min
- test-env: py311-min
use-mpl: ""
- test-env: py38-xr
- test-env: py311-xr
use-mpl: ""
runs-on: ubuntu-latest
defaults:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env
channels:
- conda-forge
dependencies:
- python=3.7
- python=3.11
- six
- numpy
- scipy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env
channels:
- conda-forge
dependencies:
- python=3.8
- python=3.11
- six
- numpy
- scipy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env
channels:
- conda-forge
dependencies:
- python=3.8
- python=3.11
- six
- numpy
- scipy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test_env
channels:
- conda-forge
dependencies:
- python=3.9
- python=3.12
- six
- numpy
- scipy
Expand Down
28 changes: 0 additions & 28 deletions ci/requirements-py38-all-rc.yml

This file was deleted.

27 changes: 0 additions & 27 deletions ci/requirements-py38-all.yml

This file was deleted.

27 changes: 0 additions & 27 deletions ci/requirements-py38-xarray-dev.yml

This file was deleted.

10 changes: 5 additions & 5 deletions salem/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Dummy():
pass
crs_type = Dummy


def check_crs(crs, raise_on_error=False):
"""Checks if the crs represents a valid grid, projection or ESPG string.
Expand Down Expand Up @@ -1123,7 +1124,7 @@ def region_of_interest(self, shape=None, geometry=None, grid=None,
x0, y0 = cgrid.transform(*xy0, crs=crs, nearest=True)
x1, y1 = cgrid.transform(*xy1, crs=crs, nearest=True)
mask[np.min([y0, y1]):np.max([y0, y1]) + 1,
np.min([x0, x1]):np.max([x0, x1]) + 1] = 1
np.min([x0, x1]):np.max([x0, x1]) + 1] = 1

return mask

Expand All @@ -1138,7 +1139,6 @@ def to_dict(self):
--------
from_dict : create a Grid from a dict
"""
srs = self.proj.srs
return dict(proj=self.proj.srs, x0y0=(self.x0, self.y0),
nxny=(self.nx, self.ny), dxdy=(self.dx, self.dy),
pixel_ref=self.pixel_ref)
Expand Down Expand Up @@ -1242,8 +1242,7 @@ def to_geometry(self, to_crs=None):
ii.append(i)
out['j'] = jj
out['i'] = ii
out['geometry'] = geoms
out.crs = self.proj.srs
out.set_geometry(geoms, crs=self.proj.srs, inplace=True)

if check_crs(to_crs):
transform_geopandas(out, to_crs=to_crs, inplace=True)
Expand All @@ -1264,6 +1263,7 @@ def proj_is_same(p1, p2):
"""
if has_gdal:
# this is more robust, but gdal is a pain
osr.UseExceptions()
s1 = osr.SpatialReference()
s1.ImportFromProj4(p1.srs)
s2 = osr.SpatialReference()
Expand Down Expand Up @@ -1577,7 +1577,7 @@ def mercator_grid(center_ll=None, extent=None, ny=600, nx=None,

e, n = transform_proj(wgs84, projloc, lon, lat)

if origin== 'upper-left':
if origin == 'upper-left':
corner = (-xx / 2. + e, yy / 2. + n)
dxdy = (xx / nx, - yy / ny)
else:
Expand Down
4 changes: 2 additions & 2 deletions salem/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ def _wrf_grid_from_dataset(ds):

atol = 5e-3 if proj_id == 2 else 1e-3
check = np.isclose(reflon, mylon, atol=atol)
if not np.alltrue(check):
if not np.all(check):
n_pix = np.sum(~check)
maxe = np.max(np.abs(reflon - mylon))
if maxe < (360 - atol):
warnings.warn('For {} grid points, the expected accuracy ({}) '
'of our lons did not match those of the WRF '
'file. Max error: {}'.format(n_pix, atol, maxe))
check = np.isclose(reflat, mylat, atol=atol)
if not np.alltrue(check):
if not np.all(check):
n_pix = np.sum(~check)
maxe = np.max(np.abs(reflat - mylat))
warnings.warn('For {} grid points, the expected accuracy ({}) '
Expand Down
1 change: 0 additions & 1 deletion salem/tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def test_xarray(self):
class TestGeoNetcdf(unittest.TestCase):

def test_eraint(self):

f = get_demo_file('era_interim_tibet.nc')
d = GeoNetcdf(f)
assert d.grid.origin == 'upper-left'
Expand Down
5 changes: 2 additions & 3 deletions salem/tests/test_gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_constructor(self):
g.corner_grid.xy_coordinates)

ex = g.corner_grid.extent
assert_allclose([-0.5, 2.5, -0.5, 2.5], ex)
assert_allclose([-0.5, 2.5, -0.5, 2.5], ex)
assert_allclose(g.center_grid.extent,
g.corner_grid.extent)

Expand Down Expand Up @@ -157,7 +157,7 @@ def test_constructor(self):
g.corner_grid.xy_coordinates)

ex = g.corner_grid.extent
assert_allclose([-0.5, 2.5, -2.5, 0.5], ex)
assert_allclose([-0.5, 2.5, -2.5, 0.5], ex)
assert_allclose(g.center_grid.extent,
g.corner_grid.extent)

Expand All @@ -180,7 +180,6 @@ def test_constructor(self):

def test_comparisons(self):
"""See if the grids can compare themselves"""

args = dict(nxny=(3, 3), dxdy=(1, 1), x0y0=(0, 0), proj=wgs84)
g1 = Grid(**args)
self.assertEqual(g1.center_grid, g1.corner_grid)
Expand Down
3 changes: 1 addition & 2 deletions salem/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ def _create_dummy_shp(fname):
p4 = shpg.Point(1, 1)
df = gpd.GeoDataFrame()
df['name'] = ['Polygon', 'Line']
df['geometry'] = gpd.GeoSeries([p1, p2])
df.set_geometry(gpd.GeoSeries([p1, p2]), crs='epsg:4326', inplace=True)
of = os.path.join(testdir, fname)
df.crs = 'epsg:4326'
df.to_file(of)
return of

Expand Down
2 changes: 1 addition & 1 deletion salem/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def create_dummy_shp(fname):
p4 = shpg.Point(1, 1)
df = gpd.GeoDataFrame()
df['name'] = ['Polygon', 'Line']
df['geometry'] = gpd.GeoSeries([p1, p2])
df.set_geometry(gpd.GeoSeries([p1, p2]), inplace=True)
of = os.path.join(testdir, fname)
df.to_file(of)
return of
Expand Down

0 comments on commit 502672f

Please sign in to comment.