From cf49c9f12f7bbc18712ef07e01f5ea9e06a65777 Mon Sep 17 00:00:00 2001 From: "C.A.P. Linssen" Date: Tue, 19 Sep 2023 04:50:53 -0700 Subject: [PATCH] add try..except around singularity detection --- odetoolbox/system_of_shapes.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/odetoolbox/system_of_shapes.py b/odetoolbox/system_of_shapes.py index ee3683bb..9a7f87b5 100644 --- a/odetoolbox/system_of_shapes.py +++ b/odetoolbox/system_of_shapes.py @@ -195,12 +195,15 @@ def generate_propagator_solver(self): if sympy.I in sympy.preorder_traversal(P): raise PropagatorGenerationException("The imaginary unit was found in the propagator matrix. This can happen if the dynamical system that was passed to ode-toolbox is unstable, i.e. one or more state variables will diverge to minus or positive infinity.") - condition = SingularityDetection.find_singularities(P, self.A_) - if condition: - logging.warning("Under certain conditions, the propagator matrix is singular (contains infinities).") - logging.warning("List of all conditions that result in a singular propagator:") - for cond in condition: - logging.warning("\t" + r" ∧ ".join([str(k) + " = " + str(v) for k, v in cond.items()])) + try: + condition = SingularityDetection.find_singularities(P, self.A_) + if condition: + logging.warning("Under certain conditions, the propagator matrix is singular (contains infinities).") + logging.warning("List of all conditions that result in a singular propagator:") + for cond in condition: + logging.warning("\t" + r" ∧ ".join([str(k) + " = " + str(v) for k, v in cond.items()])) + except Exception as e: + logging.warning("Could not check the propagator matrix for singularities.") logging.debug("System of equations:") logging.debug("x = " + str(self.x_))