Skip to content

Commit

Permalink
force more parameters to be keyword only
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Sep 5, 2024
1 parent 2b2488e commit 175c211
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pyro/compressible/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Simulation(NullSimulation):
"""

def initialize(self, extra_vars=None, ng=4):
def initialize(self, *, extra_vars=None, ng=4):
"""
Initialize the grid and variables for compressible flow and set
the initial conditions for the chosen problem.
Expand Down
5 changes: 3 additions & 2 deletions pyro/compressible_fv4/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

class Simulation(compressible_rk.Simulation):

def __init__(self, solver_name, problem_name, rp, timers=None, data_class=fv.FV2d):
def __init__(self, solver_name, problem_name, rp, *,
timers=None, data_class=fv.FV2d):
super().__init__(solver_name, problem_name, rp, timers=timers, data_class=data_class)

def initialize(self, extra_vars=None, ng=5):
def initialize(self, *, extra_vars=None, ng=5):
super().initialize(extra_vars=extra_vars, ng=ng)

def substep(self, myd):
Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible_react/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Simulation(compressible.Simulation):

def initialize(self, extra_vars=None, ng=4):
def initialize(self, *, extra_vars=None, ng=4):
"""
For the reacting compressible solver, our initialization of
the data is the same as the compressible solver, but we
Expand Down
2 changes: 1 addition & 1 deletion pyro/incompressible/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class Simulation(burgers_simulation):

def initialize(self, other_bc=False, aux_vars=()):
def initialize(self, *, other_bc=False, aux_vars=()):
"""
Initialize the grid and variables for incompressible flow and
set the initial conditions for the chosen problem.
Expand Down
4 changes: 2 additions & 2 deletions pyro/lm_atm/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class Basestate:
def __init__(self, ny, ng=0):
def __init__(self, ny, *, ng=0):
self.ny = ny
self.ng = ng
self.qy = ny + 2*ng
Expand All @@ -37,7 +37,7 @@ def jp(self, shift, buf=0):

class Simulation(NullSimulation):

def __init__(self, solver_name, problem_name, rp, timers=None):
def __init__(self, solver_name, problem_name, rp, *, timers=None):

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

Expand Down
2 changes: 1 addition & 1 deletion pyro/mesh/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class BC:
"""

def __init__(self,
def __init__(self, *,
xlb="outflow", xrb="outflow",
ylb="outflow", yrb="outflow",
xl_func=None, xr_func=None,
Expand Down
18 changes: 9 additions & 9 deletions pyro/mesh/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Grid2d:

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

def __init__(self, nx, ny, ng=1,
def __init__(self, nx, ny, *, ng=1,
xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0):
"""
Create a Grid2d object.
Expand Down Expand Up @@ -146,7 +146,7 @@ def __init__(self, nx, ny, ng=1,
self.xr2d = ArrayIndexer(d=xr2d, grid=self)
self.yr2d = ArrayIndexer(d=yr2d, grid=self)

def scratch_array(self, nvar=1):
def scratch_array(self, *, nvar=1):
"""
return a standard numpy array dimensioned to have the size
and number of ghostcells as the parent grid
Expand Down Expand Up @@ -198,10 +198,10 @@ class Cartesian2d(Grid2d):
y = y
"""

def __init__(self, nx, ny, ng=1,
def __init__(self, nx, ny, *, ng=1,
xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0):

super().__init__(nx, ny, ng, xmin, xmax, ymin, ymax)
super().__init__(nx, ny, ng=ng, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax)

self.coord_type = 0

Expand Down Expand Up @@ -242,7 +242,7 @@ class SphericalPolar(Grid2d):
theta = y
"""

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

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

super().__init__(nx, ny, ng, xmin, xmax, ymin, ymax)
super().__init__(nx, ny, ng=ng, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax)

self.coord_type = 1

Expand Down Expand Up @@ -332,7 +332,7 @@ class CellCenterData2d:

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

def __init__(self, grid, dtype=np.float64):
def __init__(self, grid, *, dtype=np.float64):

"""
Initialize the CellCenterData2d object.
Expand Down Expand Up @@ -608,14 +608,14 @@ def fill_BC(self, name):
except TypeError:
bnd.ext_bcs[self.BCs[name].yrb](self.BCs[name].yrb, "yrb", name, self, self.ivars)

def min(self, name, ng=0):
def min(self, name, *, ng=0):
"""
return the minimum of the variable name in the domain's valid region
"""
n = self.names.index(name)
return np.min(self.data.v(buf=ng, n=n))

def max(self, name, ng=0):
def max(self, name, *, ng=0):
"""
return the maximum of the variable name in the domain's valid region
"""
Expand Down
11 changes: 6 additions & 5 deletions pyro/pyro_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Pyro:
The main driver to run pyro.
"""

def __init__(self, solver_name, from_commandline=False):
def __init__(self, solver_name, *, from_commandline=False):
"""
Constructor
Expand Down Expand Up @@ -280,12 +280,13 @@ def get_sim(self):


class PyroBenchmark(Pyro):
"""
A subclass of Pyro for benchmarking. Inherits everything from pyro, but adds benchmarking routines.
"""A subclass of Pyro for benchmarking. Inherits everything from
pyro, but adds benchmarking routines.
"""

def __init__(self, solver_name, comp_bench=False,
reset_bench_on_fail=False, make_bench=False):
def __init__(self, solver_name, *,
comp_bench=False, reset_bench_on_fail=False, make_bench=False):
"""
Constructor
Expand Down
3 changes: 2 additions & 1 deletion pyro/simulation_null.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def bc_setup(rp):

class NullSimulation:

def __init__(self, solver_name, problem_name, rp, timers=None, data_class=patch.CellCenterData2d):
def __init__(self, solver_name, problem_name, rp, *,
timers=None, data_class=patch.CellCenterData2d):
"""
Initialize the Simulation object
Expand Down
2 changes: 1 addition & 1 deletion pyro/swe/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Simulation(NullSimulation):
"""

def initialize(self, extra_vars=None, ng=4):
def initialize(self, *, extra_vars=None, ng=4):
"""
Initialize the grid and variables for swe flow and set
the initial conditions for the chosen problem.
Expand Down

0 comments on commit 175c211

Please sign in to comment.