Skip to content

Commit

Permalink
Unit tests (closes #28) and standardize cupsoda run signature (fixes
Browse files Browse the repository at this point in the history
…#26)

Note that cupsoda unit tests are not run on travis due to lack of GPU/CUDA
infrastructure. Developers should run the tests locally before committing
to github.
  • Loading branch information
alubbock authored and jamespino committed Sep 23, 2016
1 parent 03d7b52 commit 6cc581e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion pysb/cupsoda.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def __init__(self, model, tspan=None, cleanup=True, verbose=False,
# overwrite default integrator options
self.options.update(integrator_options)

def run(self, param_values, y0, tspan=None, outdir=None,
def run(self, tspan=None, param_values=None, y0=None, outdir=None,
prefix=None, **integrator_options):
"""Perform a set of integrations.
Expand Down Expand Up @@ -274,6 +274,29 @@ def run(self, param_values, y0, tspan=None, outdir=None,
"""

start_time = time.time()

if y0 is None and param_values is None:
warnings.warn("Neither 'y0' nor 'param_values' were supplied. "
"Running a single simulation with model defaults.")

if y0 is None:
# Run simulation using same parameters, varying initial conditions
species_names = [str(s) for s in self.model.species]
y0 = np.zeros(len(species_names))
for ic in self.model.initial_conditions:
y0[species_names.index(str(ic[0]))] = ic[1].value
y0 = np.repeat([y0],
1 if param_values is None else
param_values.shape[0],
axis=0)

if param_values is None:
# Run simulation using same initial conditions, varying parameters
param_values = np.repeat(np.array([[p.value for p in
self.model.parameters]]),
y0.shape[0],
axis=0)

# make sure tspan is defined somewhere
if tspan is not None:
self.tspan = tspan
Expand Down

0 comments on commit 6cc581e

Please sign in to comment.