diff --git a/odetoolbox/analytic_integrator.py b/odetoolbox/analytic_integrator.py index 2bbe6b1a..8413fbcd 100644 --- a/odetoolbox/analytic_integrator.py +++ b/odetoolbox/analytic_integrator.py @@ -42,15 +42,13 @@ def __init__(self, solver_dict, spike_times: Optional[Dict[str, List[float]]] = :param enable_caching: Allow caching of results between requested times. """ - super(AnalyticIntegrator, self).__init__() + super(AnalyticIntegrator, self).__init__(spike_times) self.solver_dict = solver_dict self.all_variable_symbols = self.solver_dict["state_variables"] self.all_variable_symbols = [sympy.Symbol(s) for s in self.all_variable_symbols] - self.set_spike_times(spike_times) - self.enable_caching = enable_caching self.enable_cache_update_ = True self.t = 0. diff --git a/odetoolbox/integrator.py b/odetoolbox/integrator.py index 7927ae96..cdd1fdae 100644 --- a/odetoolbox/integrator.py +++ b/odetoolbox/integrator.py @@ -33,7 +33,14 @@ class Integrator: all_variable_symbols = [] # type: List[sympy.Symbol] - def set_spike_times(self, spike_times: Optional[Dict[str, List[float]]]): + def __init__(self, spike_times: Optional[Dict[str, List[float]]] = None): + r""" + :param spike_times: For each variable, used as a key, the list of times at which a spike occurs. + """ + self.set_spike_times(spike_times) + + + def set_spike_times(self, spike_times: Optional[Dict[str, List[float]]] = None): r""" Internally converts to a global, sorted list of spike times. diff --git a/odetoolbox/mixed_integrator.py b/odetoolbox/mixed_integrator.py index 9509d7f6..78b35f06 100644 --- a/odetoolbox/mixed_integrator.py +++ b/odetoolbox/mixed_integrator.py @@ -75,7 +75,7 @@ def __init__(self, numeric_integrator, system_of_shapes, shapes, analytic_solver :param alias_spikes: Whether to alias spike times to the numerical integration grid. :python:`False` means that precise integration will be used for spike times whenever possible. :python:`True` means that after taking a timestep :math:`dt` and arriving at :math:`t`, spikes from :math:`\langle t - dt, t]` will only be processed at time :math:`t`. :param debug_plot_dir: If given, enable debug plotting to this directory. If enabled, matplotlib is imported and used for plotting. """ - super(MixedIntegrator, self).__init__() + super(MixedIntegrator, self).__init__(spike_times) assert PYGSL_AVAILABLE @@ -128,13 +128,6 @@ def __init__(self, numeric_integrator, system_of_shapes, shapes, analytic_solver helpers=Shape._sympy_autowrap_helpers) - # - # make a sorted list of all spike times for all symbols - # - - self.set_spike_times(spike_times) - - def integrate_ode(self, initial_values=None, h_min_lower_bound=5E-9, raise_errors=True, debug=False): r""" This function computes the average step size and the minimal step size that a given integration method from GSL uses to evolve a certain system of ODEs during a certain simulation time, integration method from GSL and spike train.