From 7a314d3124bb74583850e9ede8d265f1605ae7bf Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 3 Dec 2017 16:41:03 -0500 Subject: [PATCH] [Python/1D] Callbacks can be disabled by setting to None --- interfaces/cython/cantera/onedim.pyx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/interfaces/cython/cantera/onedim.pyx b/interfaces/cython/cantera/onedim.pyx index cbed3cdf2..fddaaaa9b 100644 --- a/interfaces/cython/cantera/onedim.pyx +++ b/interfaces/cython/cantera/onedim.pyx @@ -583,6 +583,11 @@ cdef class Sim1D: interrupt function is used to trap KeyboardInterrupt exceptions so that `ctrl-c` can be used to break out of the C++ solver loop. """ + if f is None: + self.sim.setInterrupt(NULL) + self._interrupt = None + return + if not isinstance(f, Func1): f = Func1(f) self._interrupt = f @@ -594,6 +599,11 @@ cdef class Sim1D: The signature of *f* is `float f(float)`. The argument passed to *f* is the size of the timestep. The output is ignored. """ + if f is None: + self.sim.setTimeStepCallback(NULL) + self._time_step_callback = None + return + if not isinstance(f, Func1): f = Func1(f) self._time_step_callback = f @@ -605,6 +615,11 @@ cdef class Sim1D: solve, before regridding. The signature of *f* is `float f(float)`. The argument passed to *f* is "0" and the output is ignored. """ + if f is None: + self.sim.setSteadyCallback(NULL) + self._steady_callback = None + return + if not isinstance(f, Func1): f = Func1(f) self._steady_callback = f