Skip to content

Commit 30c4e41

Browse files
authored
force more parameters to be keyword only (#251)
1 parent a1a8124 commit 30c4e41

File tree

11 files changed

+29
-26
lines changed

11 files changed

+29
-26
lines changed

pyro/compressible/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Simulation(NullSimulation):
9999
100100
"""
101101

102-
def initialize(self, extra_vars=None, ng=4):
102+
def initialize(self, *, extra_vars=None, ng=4):
103103
"""
104104
Initialize the grid and variables for compressible flow and set
105105
the initial conditions for the chosen problem.

pyro/compressible_fv4/simulation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
class Simulation(compressible_rk.Simulation):
77

8-
def __init__(self, solver_name, problem_name, rp, timers=None, data_class=fv.FV2d):
8+
def __init__(self, solver_name, problem_name, rp, *,
9+
timers=None, data_class=fv.FV2d):
910
super().__init__(solver_name, problem_name, rp, timers=timers, data_class=data_class)
1011

11-
def initialize(self, extra_vars=None, ng=5):
12+
def initialize(self, *, extra_vars=None, ng=5):
1213
super().initialize(extra_vars=extra_vars, ng=ng)
1314

1415
def substep(self, myd):

pyro/compressible_react/simulation.py

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

99
class Simulation(compressible.Simulation):
1010

11-
def initialize(self, extra_vars=None, ng=4):
11+
def initialize(self, *, extra_vars=None, ng=4): # pylint: disable=useless-parent-delegation
1212
"""
1313
For the reacting compressible solver, our initialization of
1414
the data is the same as the compressible solver, but we

pyro/compressible_rk/fluxes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def fluxes(my_data, rp, ivars, solid, tc):
115115
tm_states = tc.timer("interfaceStates")
116116
tm_states.begin()
117117

118-
V_l = myg.scratch_array(ivars.nvar)
119-
V_r = myg.scratch_array(ivars.nvar)
118+
V_l = myg.scratch_array(nvar=ivars.nvar)
119+
V_r = myg.scratch_array(nvar=ivars.nvar)
120120

121121
for n in range(ivars.nvar):
122122
V_l.ip(1, n=n, buf=2)[:, :] = q.v(n=n, buf=2) + 0.5 * ldx.v(n=n, buf=2)

pyro/incompressible/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class Simulation(burgers_simulation):
1717

18-
def initialize(self, other_bc=False, aux_vars=()):
18+
def initialize(self, *, other_bc=False, aux_vars=()):
1919
"""
2020
Initialize the grid and variables for incompressible flow and
2121
set the initial conditions for the chosen problem.

pyro/lm_atm/simulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class Basestate:
15-
def __init__(self, ny, ng=0):
15+
def __init__(self, ny, *, ng=0):
1616
self.ny = ny
1717
self.ng = ng
1818
self.qy = ny + 2*ng
@@ -37,7 +37,7 @@ def jp(self, shift, buf=0):
3737

3838
class Simulation(NullSimulation):
3939

40-
def __init__(self, solver_name, problem_name, rp, timers=None):
40+
def __init__(self, solver_name, problem_name, rp, *, timers=None):
4141

4242
NullSimulation.__init__(self, solver_name, problem_name, rp, timers=timers)
4343

pyro/mesh/boundary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class BC:
7575
7676
"""
7777

78-
def __init__(self,
78+
def __init__(self, *,
7979
xlb="outflow", xrb="outflow",
8080
ylb="outflow", yrb="outflow",
8181
xl_func=None, xr_func=None,

pyro/mesh/patch.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Grid2d:
5959

6060
# pylint: disable=too-many-instance-attributes
6161

62-
def __init__(self, nx, ny, ng=1,
62+
def __init__(self, nx, ny, *, ng=1,
6363
xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0):
6464
"""
6565
Create a Grid2d object.
@@ -146,7 +146,7 @@ def __init__(self, nx, ny, ng=1,
146146
self.xr2d = ArrayIndexer(d=xr2d, grid=self)
147147
self.yr2d = ArrayIndexer(d=yr2d, grid=self)
148148

149-
def scratch_array(self, nvar=1):
149+
def scratch_array(self, *, nvar=1):
150150
"""
151151
return a standard numpy array dimensioned to have the size
152152
and number of ghostcells as the parent grid
@@ -198,10 +198,10 @@ class Cartesian2d(Grid2d):
198198
y = y
199199
"""
200200

201-
def __init__(self, nx, ny, ng=1,
201+
def __init__(self, nx, ny, *, ng=1,
202202
xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0):
203203

204-
super().__init__(nx, ny, ng, xmin, xmax, ymin, ymax)
204+
super().__init__(nx, ny, ng=ng, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax)
205205

206206
self.coord_type = 0
207207

@@ -242,7 +242,7 @@ class SphericalPolar(Grid2d):
242242
theta = y
243243
"""
244244

245-
def __init__(self, nx, ny, ng=1,
245+
def __init__(self, nx, ny, *, ng=1,
246246
xmin=0.2, xmax=1.0, ymin=0.0, ymax=1.0):
247247

248248
# Make sure theta is within [0, PI]
@@ -252,7 +252,7 @@ def __init__(self, nx, ny, ng=1,
252252
assert xmin - ng*(xmax-xmin)/nx >= 0.0, \
253253
"xmin (r-direction), must be large enough so ghost cell doesn't have negative x."
254254

255-
super().__init__(nx, ny, ng, xmin, xmax, ymin, ymax)
255+
super().__init__(nx, ny, ng=ng, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax)
256256

257257
self.coord_type = 1
258258

@@ -332,7 +332,7 @@ class CellCenterData2d:
332332

333333
# pylint: disable=too-many-instance-attributes
334334

335-
def __init__(self, grid, dtype=np.float64):
335+
def __init__(self, grid, *, dtype=np.float64):
336336

337337
"""
338338
Initialize the CellCenterData2d object.
@@ -608,14 +608,14 @@ def fill_BC(self, name):
608608
except TypeError:
609609
bnd.ext_bcs[self.BCs[name].yrb](self.BCs[name].yrb, "yrb", name, self, self.ivars)
610610

611-
def min(self, name, ng=0):
611+
def min(self, name, *, ng=0):
612612
"""
613613
return the minimum of the variable name in the domain's valid region
614614
"""
615615
n = self.names.index(name)
616616
return np.min(self.data.v(buf=ng, n=n))
617617

618-
def max(self, name, ng=0):
618+
def max(self, name, *, ng=0):
619619
"""
620620
return the maximum of the variable name in the domain's valid region
621621
"""

pyro/pyro_sim.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Pyro:
3636
The main driver to run pyro.
3737
"""
3838

39-
def __init__(self, solver_name, from_commandline=False):
39+
def __init__(self, solver_name, *, from_commandline=False):
4040
"""
4141
Constructor
4242
@@ -280,12 +280,13 @@ def get_sim(self):
280280

281281

282282
class PyroBenchmark(Pyro):
283-
"""
284-
A subclass of Pyro for benchmarking. Inherits everything from pyro, but adds benchmarking routines.
283+
"""A subclass of Pyro for benchmarking. Inherits everything from
284+
pyro, but adds benchmarking routines.
285+
285286
"""
286287

287-
def __init__(self, solver_name, comp_bench=False,
288-
reset_bench_on_fail=False, make_bench=False):
288+
def __init__(self, solver_name, *,
289+
comp_bench=False, reset_bench_on_fail=False, make_bench=False):
289290
"""
290291
Constructor
291292

pyro/simulation_null.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ def bc_setup(rp):
102102

103103
class NullSimulation:
104104

105-
def __init__(self, solver_name, problem_name, rp, timers=None, data_class=patch.CellCenterData2d):
105+
def __init__(self, solver_name, problem_name, rp, *,
106+
timers=None, data_class=patch.CellCenterData2d):
106107
"""
107108
Initialize the Simulation object
108109

0 commit comments

Comments
 (0)