Skip to content

Commit

Permalink
add try..except around singularity detection
Browse files Browse the repository at this point in the history
  • Loading branch information
C.A.P. Linssen committed Sep 19, 2023
1 parent 75e47ca commit cf49c9f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions odetoolbox/system_of_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Check warning on line 206 in odetoolbox/system_of_shapes.py

View check run for this annotation

Codecov / codecov/patch

odetoolbox/system_of_shapes.py#L205-L206

Added lines #L205 - L206 were not covered by tests

logging.debug("System of equations:")
logging.debug("x = " + str(self.x_))
Expand Down

0 comments on commit cf49c9f

Please sign in to comment.