Skip to content

Commit 16db15e

Browse files
author
C.A.P. Linssen
committed
conditional propagators
1 parent f82503b commit 16db15e

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

odetoolbox/analytic_integrator.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ def __init__(self, solver_dict, spike_times: Optional[Dict[str, List[float]]] =
4242
:param enable_caching: Allow caching of results between requested times.
4343
"""
4444

45+
super(AnalyticIntegrator, self).__init__()
46+
4547
self.solver_dict = solver_dict
4648

4749
self.all_variable_symbols = self.solver_dict["state_variables"]
4850
self.all_variable_symbols = [sympy.Symbol(s) for s in self.all_variable_symbols]
4951

52+
self.set_spike_times(spike_times)
53+
5054
self.enable_caching = enable_caching
5155
self.enable_cache_update_ = True
5256
self.t = 0.
@@ -111,11 +115,6 @@ def __init__(self, solver_dict, spike_times: Optional[Dict[str, List[float]]] =
111115
backend="cython",
112116
helpers=Shape._sympy_autowrap_helpers)
113117

114-
#
115-
# set spike times
116-
#
117-
118-
self.set_spike_times(spike_times)
119118

120119
def get_all_variable_symbols(self):
121120
return self.all_variable_symbols

odetoolbox/integrator.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@ class Integrator:
3333

3434
all_variable_symbols = [] # type: List[sympy.Symbol]
3535

36-
def __init__(self, spike_times: Optional[Dict[str, List[float]]] = None):
37-
r"""
38-
:param spike_times: For each variable, used as a key, the list of times at which a spike occurs.
39-
"""
40-
self.set_spike_times(spike_times)
41-
42-
43-
def set_spike_times(self, spike_times: Optional[Dict[str, List[float]]] = None):
36+
def set_spike_times(self, spike_times: Optional[Dict[str, List[float]]]):
4437
r"""
4538
Internally converts to a global, sorted list of spike times.
4639

odetoolbox/mixed_integrator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, numeric_integrator, system_of_shapes, shapes, analytic_solver
7575
: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`.
7676
:param debug_plot_dir: If given, enable debug plotting to this directory. If enabled, matplotlib is imported and used for plotting.
7777
"""
78-
super(MixedIntegrator, self).__init__(spike_times)
78+
super(MixedIntegrator, self).__init__()
7979

8080
assert PYGSL_AVAILABLE
8181

@@ -128,6 +128,13 @@ def __init__(self, numeric_integrator, system_of_shapes, shapes, analytic_solver
128128
helpers=Shape._sympy_autowrap_helpers)
129129

130130

131+
#
132+
# make a sorted list of all spike times for all symbols
133+
#
134+
135+
self.set_spike_times(spike_times)
136+
137+
131138
def integrate_ode(self, initial_values=None, h_min_lower_bound=5E-9, raise_errors=True, debug=False):
132139
r"""
133140
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.

0 commit comments

Comments
 (0)