Refactors some of the logic of the internal function setup_simulation_lists in solver_classes.py into a function setup_args_lists in solver_utils.py, so that it can be reused elsewhere (e.g. it is needed in #73 for setting up list simulation in the new solvers introduced there).
Details and comments
setup_simulation_lists supports the functionality for allowing a user to pass one or more of t_span, y0, and signals as lists to Solver.solve, so that multiple simulations can be run with a single call. This consists of two parts:
Checking whether each of those arguments are "single instances" or lists of single instances (e.g. is t_span specifying one interval, or a list of intervals?), and turning them all into lists regardless.
Checking the compatibility of the argument lengths, then setting all to the same length (repeating single instances of necessary)
The first part of the above is naturally tied to the specifics of the arguments t_span, y0, and signals, however the second part is not, and this is what has been refactored into setup_args_lists to work for an arbitrary number of input arguments. This function takes in a list of arguments, a list of names of those arguments, and a list of functions for validating whether or not the argument is a "valid single input" or a list of "valid single inputs". It applies these functions to all of the arguments, and performs the second part above.
This allows the user to construct more functions like setup_simulation_lists by only needing to supply the list conversion/validation functions.
Summary
Refactors some of the logic of the internal function
setup_simulation_lists
insolver_classes.py
into a functionsetup_args_lists
insolver_utils.py
, so that it can be reused elsewhere (e.g. it is needed in #73 for setting up list simulation in the new solvers introduced there).Details and comments
setup_simulation_lists
supports the functionality for allowing a user to pass one or more oft_span
,y0
, andsignals
as lists toSolver.solve
, so that multiple simulations can be run with a single call. This consists of two parts:t_span
specifying one interval, or a list of intervals?), and turning them all into lists regardless.The first part of the above is naturally tied to the specifics of the arguments
t_span
,y0
, andsignals
, however the second part is not, and this is what has been refactored intosetup_args_lists
to work for an arbitrary number of input arguments. This function takes in a list of arguments, a list of names of those arguments, and a list of functions for validating whether or not the argument is a "valid single input" or a list of "valid single inputs". It applies these functions to all of the arguments, and performs the second part above.This allows the user to construct more functions like
setup_simulation_lists
by only needing to supply the list conversion/validation functions.