Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate init kwargs to ScipyOdeSimulator #381

Merged
merged 2 commits into from Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions pysb/simulator/scipyode.py
Expand Up @@ -147,11 +147,16 @@ def __init__(self, model, tspan=None, initials=None, param_values=None,
verbose=verbose,
**kwargs)
# We'll need to know if we're using the Jacobian when we get to run()
self._use_analytic_jacobian = kwargs.get('use_analytic_jacobian',
self._use_analytic_jacobian = kwargs.pop('use_analytic_jacobian',
False)
self.cleanup = kwargs.get('cleanup', True)
integrator = kwargs.get('integrator', 'vode')
compiler_mode = kwargs.get('compiler', None)
self.cleanup = kwargs.pop('cleanup', True)
integrator = kwargs.pop('integrator', 'vode')
compiler_mode = kwargs.pop('compiler', None)
integrator_options = kwargs.pop('integrator_options', {})
if kwargs:
raise ValueError('Unknown keyword argument(s): {}'.format(
', '.join(kwargs.keys())
))
# Generate the equations for the model
pysb.bng.generate_equations(self._model, self.cleanup, self.verbose)

Expand Down Expand Up @@ -339,7 +344,7 @@ def jacobian(t, y, p):
options.update(
self.default_integrator_options[integrator]) # default options

options.update(kwargs.get('integrator_options', {})) # overwrite
options.update(integrator_options) # overwrite
# defaults
self.opts = options

Expand Down
4 changes: 4 additions & 0 deletions pysb/tests/test_simulator_scipy.py
Expand Up @@ -55,6 +55,10 @@ def test_vode_solver_run(self):
simres = self.sim.run()
assert simres._nsims == 1

@raises(ValueError)
def test_invalid_init_kwarg(self):
ScipyOdeSimulator(self.model, tspan=self.time, spam='eggs')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 spam, egg, spam, spam, bacon and spam!


def test_lsoda_solver_run(self):
"""Test lsoda."""
solver_lsoda = ScipyOdeSimulator(self.model, tspan=self.time,
Expand Down