Skip to content

Commit 291cae3

Browse files
committed
f-strings
1 parent 92997c8 commit 291cae3

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

gsw/geostrophy.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,15 @@ def geo_strf_dyn_height(SA, CT, p, p_ref=0, axis=0, max_dp=1.0,
5050
"""
5151
interp_methods = {'pchip' : 2, 'linear' : 1}
5252
if interp_method not in interp_methods:
53-
raise ValueError('interp_method must be one of %s'
54-
% (interp_methods.keys(),))
53+
raise ValueError(f'interp_method must be one of {interp_methods.keys()}')
5554
if SA.shape != CT.shape:
56-
raise ValueError('Shapes of SA and CT must match; found %s and %s'
57-
% (SA.shape, CT.shape))
55+
raise ValueError(f'Shapes of SA and CT must match; found {SA.shape} and {CT.shape}')
5856
if p.ndim == 1 and SA.ndim > 1:
5957
if len(p) != SA.shape[axis]:
60-
raise ValueError('With 1-D p, len(p) must be SA.shape[axis];\n'
61-
' found %d versus %d on specified axis, %d'
62-
% (len(p), SA.shape[axis], axis))
58+
raise ValueError(
59+
f'With 1-D p, len(p) must be SA.shape[axis];\n'
60+
f' found {len(p)} versus {SA.shape[axis]} on specified axis, {axis}'
61+
)
6362
ind = [np.newaxis] * SA.ndim
6463
ind[axis] = slice(None)
6564
p = p[tuple(ind)]
@@ -294,12 +293,10 @@ def geostrophic_velocity(geo_strf, lon, lat, p=0, axis=0):
294293
lon = unwrap(lon)
295294

296295
if lon.shape != lat.shape or lon.ndim != 1:
297-
raise ValueError('lon, lat must be 1-D and matching; found shapes'
298-
' {} and {}'.format(lon.shape, lat.shape))
296+
raise ValueError(f'lon, lat must be 1-D and matching; found shapes {lon.shape} and {lat.shape}')
299297

300298
if geo_strf.ndim not in (1, 2):
301-
raise ValueError('geo_strf must be 1-D or 2-d; found shape %s'
302-
% (geo_strf.shape,))
299+
raise ValueError(f'geo_strf must be 1-D or 2-d; found shape {geo_strf.shape}')
303300

304301
laxis = 0 if axis else -1
305302

0 commit comments

Comments
 (0)