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

Small changes to 'BngSimulator.run' to support optional arguments to #408

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lh64
Copy link
Contributor

@lh64 lh64 commented Jan 24, 2019

BNG's 'generate_network' method. Added a new optional argument, 'netgen_args', to the 'BngSimulator.run' call signature. This is a dictionary that gets passed to 'bngfile.action' when the 'generate_network' command is called.

BNG's 'generate_network' method. Added a new optional argument,
'netgen_args', to the 'BngSimulator.run' call signature. This is a
dictionary that gets passed to 'bngfile.action' when the
'generate_network' command is called.
@lh64 lh64 requested a review from alubbock January 24, 2019 10:20
@coveralls
Copy link

coveralls commented Jan 24, 2019

Coverage Status

Coverage increased (+0.03%) to 79.232% when pulling 0a151fc on netgen_args into c267f1e on master.

Copy link
Member

@alubbock alubbock left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Two issues and a question:

  1. It's not a good idea to have a mutable default argument, in this case a dictionary (see here for explanation). The simplest solution is to make to write netgen_args=None, and then add if netgen_args is None: netgen_args = {}.
  2. A small test or two would help. I'd suggest one with a working netgen argument, and an invalid one to test that an error is raised.
  3. Should this be extended to other simulators, or is there no need, since generate_equations can be called beforehand with arguments in those cases?

@lh64
Copy link
Contributor Author

lh64 commented Jan 25, 2019

Ok, thanks.

  1. I'll change netgen_args={} to netgen_args=None, as you suggest.
  2. I'll also add a test. The only issue here is that it's not actually possible to pass an argument that will cause an error. BNG doesn't check that your arguments are valid, so unrecognized arguments just end up getting ignored. I suppose we could fix that on the PySB side but it's true of all BNG methods (including simulate, etc.), so I'm not sure it makes sense. What do you think?
  3. I think we can just pass kwargs to generate_equations for the other simulators. But those will need to be updated. ScipyOdeSimulator, for example, doesn't provide any way to pass kwargs over to generate_equations.

`BngSimulator.run` and added a simple validation test to
test_simulator_bng.py.
@alubbock
Copy link
Member

alubbock commented Feb 4, 2019

One other thing: netgen_kwargs is ignored if method=='nf'. Should probably raise a ValueError in that case, stating that the arguments are incompatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants