Skip to content

Commit dc77e96

Browse files
authored
Merge pull request #127 from ocefpaf/fix_linter
Fix linter
2 parents 30c5aa4 + 03f9e97 commit dc77e96

21 files changed

Lines changed: 161 additions & 171 deletions

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
#
43
# gsw documentation build configuration file, created by
54
# sphinx-quickstart on Mon Mar 13 15:27:45 2017.
@@ -56,6 +55,7 @@
5655
# |version| and |release|, also used in various other places throughout the
5756
# built documents.
5857
import gsw
58+
5959
version = release = gsw.__version__
6060

6161
# The language for content autogenerated by Sphinx. Refer to documentation

gsw/__init__.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,12 @@
3131
"""
3232

3333

34-
from ._fixed_wrapped_ufuncs import *
35-
36-
from .stability import *
37-
from .geostrophy import *
38-
from .utility import *
39-
from . import geostrophy
40-
from . import utility
41-
from . import stability
42-
from . import density
43-
from . import energy
44-
from . import conversions
45-
46-
from . import ice
47-
34+
from . import conversions, density, energy, geostrophy, ice, stability, utility
35+
from ._fixed_wrapped_ufuncs import * # noqa
4836
from .conversions import t90_from_t68
37+
from .geostrophy import * # noqa
38+
from .stability import * # noqa
39+
from .utility import * # noqa
4940

5041
try:
5142
from ._version import __version__

gsw/_utilities.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import numpy as np
44

5+
56
def masked_to_nan(arg):
67
"""
78
Convert a masked array to a float ndarray with nans; ensure
@@ -104,7 +105,7 @@ def indexer(shape, axis, order='C'):
104105
else:
105106
index_position = list(range(ndim))
106107

107-
for k in range(kmax):
108+
for _k in range(kmax):
108109
yield tuple(inds)
109110

110111
for i in index_position:
@@ -158,8 +159,8 @@ def __init__(self, *args, **kwargs):
158159
def __getattr__(self, name):
159160
try:
160161
return self[name]
161-
except KeyError:
162-
raise AttributeError("'Bunch' object has no attribute '%s'" % name)
162+
except KeyError as err:
163+
raise AttributeError(f"'Bunch' object has no attribute {name}. {err}")
163164

164165
def __setattr__(self, name, value):
165166
self[name] = value
@@ -208,7 +209,7 @@ def from_pyfile(self, filename):
208209
# Python 3 the scoping for list comprehensions would
209210
# lead to a NameError. Wrapping the code in a function
210211
# fixes this.
211-
d = dict()
212+
d = {}
212213
lines = ["def _temp_func():\n"]
213214
with open(filename) as f:
214215
lines.extend([" " + line for line in f])
@@ -232,12 +233,12 @@ def update_values(self, *args, **kw):
232233
already in the Bunch instance will raise a KeyError.
233234
"""
234235
strict = kw.pop("strict", False)
235-
newkw = dict()
236+
newkw = {}
236237
for d in args:
237238
newkw.update(d)
238239
newkw.update(kw)
239240
self._check_strict(strict, newkw)
240-
dsub = dict([(k, v) for (k, v) in newkw.items() if k in self])
241+
dsub = {k: v for (k, v) in newkw.items() if k in self}
241242
self.update(dsub)
242243

243244
def update_None(self, *args, **kw):
@@ -246,13 +247,13 @@ def update_None(self, *args, **kw):
246247
will be updated only if it is None.
247248
"""
248249
strict = kw.pop("strict", False)
249-
newkw = dict()
250+
newkw = {}
250251
for d in args:
251252
newkw.update(d)
252253
newkw.update(kw)
253254
self._check_strict(strict, newkw)
254-
dsub = dict([(k, v) for (k, v) in newkw.items()
255-
if k in self and self[k] is None])
255+
dsub = {k: v for (k, v) in newkw.items()
256+
if k in self and self[k] is None}
256257
self.update(dsub)
257258

258259
def _check_strict(self, strict, kw):
@@ -264,4 +265,4 @@ def _check_strict(self, strict, kw):
264265
ek = list(self.keys())
265266
ek.sort()
266267
raise KeyError(
267-
"Update keys %s don't match existing keys %s" % (bk, ek))
268+
f"Update keys {bk} don't match existing keys {ek}")

gsw/conversions.py

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,37 @@
4343
'z_from_p',
4444
]
4545

46-
from ._utilities import match_args_return
47-
4846
from ._fixed_wrapped_ufuncs import (
49-
adiabatic_lapse_rate_from_CT,
50-
C_from_SP,
51-
CT_from_enthalpy,
52-
CT_from_entropy,
53-
CT_from_pt,
54-
CT_from_rho,
55-
CT_from_t,
56-
deltaSA_from_SP,
57-
entropy_from_pt,
58-
entropy_from_t,
59-
pt0_from_t,
60-
pt_from_CT,
61-
pt_from_entropy,
62-
pt_from_t,
63-
SA_from_rho,
64-
SA_from_SP,
65-
SA_from_Sstar,
66-
SP_from_C,
67-
SP_from_SA,
68-
SP_from_SK,
69-
SP_from_SR,
70-
SP_from_Sstar,
71-
SR_from_SP,
72-
Sstar_from_SA,
73-
Sstar_from_SP,
74-
t_from_CT,
75-
p_from_z,
76-
z_from_p,
47+
C_from_SP,
48+
CT_from_enthalpy,
49+
CT_from_entropy,
50+
CT_from_pt,
51+
CT_from_rho,
52+
CT_from_t,
53+
SA_from_rho,
54+
SA_from_SP,
55+
SA_from_Sstar,
56+
SP_from_C,
57+
SP_from_SA,
58+
SP_from_SK,
59+
SP_from_SR,
60+
SP_from_Sstar,
61+
SR_from_SP,
62+
Sstar_from_SA,
63+
Sstar_from_SP,
64+
adiabatic_lapse_rate_from_CT,
65+
deltaSA_from_SP,
66+
entropy_from_pt,
67+
entropy_from_t,
68+
p_from_z,
69+
pt0_from_t,
70+
pt_from_CT,
71+
pt_from_entropy,
72+
pt_from_t,
73+
t_from_CT,
74+
z_from_p,
7775
)
76+
from ._utilities import match_args_return
7877

7978

8079
@match_args_return

gsw/density.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
in their own "energy" module.
99
"""
1010
from ._wrapped_ufuncs import (
11-
specvol,
12-
alpha,
13-
beta,
14-
alpha_on_beta,
15-
specvol_alpha_beta,
16-
specvol_anom_standard,
17-
rho,
18-
rho_alpha_beta,
19-
rho_t_exact,
20-
sigma0,
21-
sigma1,
22-
sigma2,
23-
sigma3,
24-
sigma4,
25-
sound_speed,
26-
kappa,
11+
alpha,
12+
alpha_on_beta,
13+
beta,
14+
kappa,
15+
rho,
16+
rho_alpha_beta,
17+
rho_t_exact,
18+
sigma0,
19+
sigma1,
20+
sigma2,
21+
sigma3,
22+
sigma4,
23+
sound_speed,
24+
specvol,
25+
specvol_alpha_beta,
26+
specvol_anom_standard,
2727
)

gsw/freezing.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
"""
44

55
from ._wrapped_ufuncs import (
6-
CT_freezing,
7-
CT_freezing_first_derivatives,
8-
CT_freezing_first_derivatives_poly,
9-
CT_freezing_poly,
10-
pot_enthalpy_ice_freezing,
11-
pot_enthalpy_ice_freezing_first_derivatives,
12-
pot_enthalpy_ice_freezing_first_derivatives_poly,
13-
pot_enthalpy_ice_freezing_poly,
14-
pressure_freezing_CT,
15-
SA_freezing_from_CT,
16-
SA_freezing_from_CT_poly,
17-
SA_freezing_from_t,
18-
SA_freezing_from_t_poly,
19-
t_freezing,
20-
t_freezing_first_derivatives,
21-
t_freezing_first_derivatives_poly,
6+
CT_freezing,
7+
CT_freezing_first_derivatives,
8+
CT_freezing_first_derivatives_poly,
9+
CT_freezing_poly,
10+
SA_freezing_from_CT,
11+
SA_freezing_from_CT_poly,
12+
SA_freezing_from_t,
13+
SA_freezing_from_t_poly,
14+
pot_enthalpy_ice_freezing,
15+
pot_enthalpy_ice_freezing_first_derivatives,
16+
pot_enthalpy_ice_freezing_first_derivatives_poly,
17+
pot_enthalpy_ice_freezing_poly,
18+
pressure_freezing_CT,
19+
t_freezing,
20+
t_freezing_first_derivatives,
21+
t_freezing_first_derivatives_poly,
2222
)

gsw/geostrophy.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66

77
from . import _gsw_ufuncs
8-
from ._utilities import match_args_return, indexer
8+
from ._utilities import indexer, match_args_return
99
from .conversions import z_from_p
1010

1111
__all__ = ['geo_strf_dyn_height',
@@ -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-
' %s and %s' % (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

gsw/ice.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33
"""
44

55
from ._wrapped_ufuncs import (
6-
adiabatic_lapse_rate_ice,
7-
alpha_wrt_t_ice,
8-
chem_potential_water_ice,
9-
cp_ice,
10-
enthalpy_ice,
11-
entropy_ice,
12-
Helmholtz_energy_ice,
13-
ice_fraction_to_freeze_seawater,
14-
internal_energy_ice,
15-
kappa_const_t_ice,
16-
kappa_ice,
17-
melting_ice_equilibrium_SA_CT_ratio,
18-
melting_ice_equilibrium_SA_CT_ratio_poly,
19-
melting_ice_into_seawater,
20-
melting_ice_SA_CT_ratio,
21-
melting_ice_SA_CT_ratio_poly,
22-
melting_seaice_equilibrium_SA_CT_ratio,
23-
melting_seaice_equilibrium_SA_CT_ratio_poly,
24-
melting_seaice_into_seawater,
25-
melting_seaice_SA_CT_ratio,
26-
melting_seaice_SA_CT_ratio_poly,
27-
pot_enthalpy_from_pt_ice,
28-
pot_enthalpy_from_pt_ice_poly,
29-
pressure_coefficient_ice,
30-
pt0_from_t_ice,
31-
pt_from_pot_enthalpy_ice,
32-
pt_from_pot_enthalpy_ice_poly,
33-
pt_from_t_ice,
34-
rho_ice,
35-
seaice_fraction_to_freeze_seawater,
36-
sound_speed_ice,
37-
specvol_ice,
38-
t_from_pt0_ice,
6+
Helmholtz_energy_ice,
7+
adiabatic_lapse_rate_ice,
8+
alpha_wrt_t_ice,
9+
chem_potential_water_ice,
10+
cp_ice,
11+
enthalpy_ice,
12+
entropy_ice,
13+
ice_fraction_to_freeze_seawater,
14+
internal_energy_ice,
15+
kappa_const_t_ice,
16+
kappa_ice,
17+
melting_ice_equilibrium_SA_CT_ratio,
18+
melting_ice_equilibrium_SA_CT_ratio_poly,
19+
melting_ice_into_seawater,
20+
melting_ice_SA_CT_ratio,
21+
melting_ice_SA_CT_ratio_poly,
22+
melting_seaice_equilibrium_SA_CT_ratio,
23+
melting_seaice_equilibrium_SA_CT_ratio_poly,
24+
melting_seaice_into_seawater,
25+
melting_seaice_SA_CT_ratio,
26+
melting_seaice_SA_CT_ratio_poly,
27+
pot_enthalpy_from_pt_ice,
28+
pot_enthalpy_from_pt_ice_poly,
29+
pressure_coefficient_ice,
30+
pt0_from_t_ice,
31+
pt_from_pot_enthalpy_ice,
32+
pt_from_pot_enthalpy_ice_poly,
33+
pt_from_t_ice,
34+
rho_ice,
35+
seaice_fraction_to_freeze_seawater,
36+
sound_speed_ice,
37+
specvol_ice,
38+
t_from_pt0_ice,
3939
)

gsw/stability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import numpy as np
1818

19-
from ._utilities import match_args_return, axis_slicer
2019
from ._gsw_ufuncs import grav, specvol_alpha_beta
20+
from ._utilities import axis_slicer, match_args_return
2121

2222
__all__ = ['Nsquared',
2323
'Turner_Rsubrho',

0 commit comments

Comments
 (0)