Skip to content

Commit e1d3e6a

Browse files
fix deprecation warnings/errors on pytest of schimpy
1 parent 7287e7e commit e1d3e6a

7 files changed

Lines changed: 19 additions & 11 deletions

File tree

schimpy/param.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ def set_interval(self, name, freq):
100100
dt = int(self["dt"])
101101
if type(freq) in (str, pd.Timedelta):
102102
freq = pd.tseries.frequencies.to_offset(freq)
103-
dt = pd.tseries.frequencies.to_offset(f"{dt}S")
103+
dt = pd.tseries.frequencies.to_offset(f"{dt}s")
104104
nspool = freq / dt
105105
elif isinstance(freq, pd.offsets.DateOffset):
106-
dt = pd.tseries.frequencies.to_offset(f"{dt}S")
106+
dt = pd.tseries.frequencies.to_offset(f"{dt}s")
107107
nspool = freq / dt
108108
if abs(nspool - round(nspool)) > 0.01:
109109
raise ValueError("Output interval not divisible by dt")
@@ -326,7 +326,7 @@ def test_param():
326326
print(parms.run_start)
327327
print("Stack")
328328
print(parms.nc_stack)
329-
parms.nc_stack = "8H"
329+
parms.nc_stack = "8h"
330330
print(parms.nc_stack)
331331
print("IHFSKIP")
332332
print(parms["ihfskip"])
@@ -335,7 +335,7 @@ def test_param():
335335
parms.station_out = None
336336
print(parms.station_out_freq)
337337
print(parms["iout_sta"])
338-
parms.station_out_freq = "15T"
338+
parms.station_out_freq = "15min"
339339
print(parms.station_out_freq)
340340
print(parms["iout_sta"])
341341

schimpy/schism_linestring.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
wkbLineString,
1313
Feature,
1414
CreateGeometryFromWkb,
15+
UseExceptions,
1516
)
1617
import os
1718
import copy
1819

20+
UseExceptions() # Enable exceptions (recommended)
21+
1922

2023
class LineString(shapely.geometry.LineString):
2124
""" """
@@ -182,7 +185,7 @@ def write(self, fpath, lines, spatial_reference=None, driver_name=None, **kwargs
182185
if val is not None:
183186
feature.SetField(j, val)
184187
layer.CreateFeature(feature)
185-
datasource.Destroy()
188+
datasource.Close()
186189

187190

188191
class LineStringIoFactory(object):

schimpy/schism_polygon.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
wkbPolygon,
1515
FieldDefn,
1616
Feature,
17+
UseExceptions,
1718
)
1819
import numpy as np
1920
import os
2021

22+
UseExceptions() # Enable exceptions (recommended)
23+
2124

2225
class SchismPolygon(Polygon):
2326
"""
@@ -291,7 +294,7 @@ def write(self, fpath, polygons, spatial_reference=None, driver_name=None):
291294
feature.SetField(1, polygon.type)
292295
feature.SetField(2, polygon.attribute)
293296
layer.CreateFeature(feature)
294-
datasource.Destroy()
297+
datasource.Close()
295298

296299

297300
class SchismPolygonIoFactory(object):

schimpy/vgrid_opt2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
Package for optimising vgrid smoothness, shape and completeness
44
"""
5-
from scipy.ndimage.filters import gaussian_filter1d
5+
from scipy.ndimage import gaussian_filter1d
66
from schimpy.lsc2 import *
77

88

tests/test_params.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def test_param_special(datadir):
3434
assert parms["rnday"] == 3000
3535
parms.run_start = "2010-02-04"
3636
assert parms.run_start == pd.Timestamp(2010, 2, 4)
37-
parms.nc_stack = "8H"
38-
assert parms.nc_stack == pd.tseries.frequencies.to_offset("8H")
37+
parms.nc_stack = "8h"
38+
assert parms.nc_stack == pd.tseries.frequencies.to_offset("8h")
3939
parms.nc_stack = pd.tseries.frequencies.to_offset("1D")
4040
assert parms["ihfskip"] == 86400 / 90
4141
parms.hotstart_freq = None
@@ -44,12 +44,12 @@ def test_param_special(datadir):
4444
assert parms["nhot"] == 1
4545
assert parms["nhot_write"] == (5 * 86400 / parms["dt"])
4646

47-
parms.station_out_freq = "30T"
47+
parms.station_out_freq = "30min"
4848
assert parms["iout_sta"] == 1
4949
assert parms["nspool_sta"] == 20
5050
parms.station_out_freq = None
5151
assert parms["iout_sta"] == 0
52-
parms.station_out_freq = "15T"
52+
parms.station_out_freq = "15min"
5353

5454
print(parms.hotstart_freq)
5555
print(parms["nhot"])

tests/testdata/prepare_schism/simple_triquad/main_good.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Main input file of SELFE pre-processor
2+
prepro_output_dir: ./
23
mesh:
34
mesh_inputfile: testmesh.2dm
45
# mesh input file: baydelta73.gr3

tests/testdata/prepare_schism/simple_triquad/main_good_echo.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
prepro_output_dir: ./
12
mesh:
23
mesh_inputfile: testmesh.2dm
34
open_boundaries:

0 commit comments

Comments
 (0)