Skip to content

Commit

Permalink
squash as well
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonBurns committed Dec 3, 2024
1 parent c45d328 commit d81a2c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rmgpy/molecule/resonance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,14 +1101,19 @@ def _clar_optimization(mol, recursion_constraints=None, clar_number=-1, save_ord
if status == 2: # infeasible
raise RuntimeError("All valid Clar formulae have been enumerated!")
else:
raise RuntimeError(f"Clar optimization failed (Exit Code {status}) for an unexpected reason: {result.message}")
raise RuntimeError(f"Optimization failed (Exit Code {status}) for an unexpected reason '{result.message}'")

_clar_number, solution = -result.fun, result.x

# optimization may have reached a bad local minimum - this case is rare
if _clar_number == 0:
return []

# on later runs, non-integer solutions occur - branching might be able to find actual solutions,
# but we just call it good enough here
if any([x != 1 and x != 0 for x in solution]):
raise RuntimeError("Optimization obtained a non-integer solution - no more formulae will be enumerated.")

# first solution, so the result should be an upper limit
if clar_number == -1:
clar_number = _clar_number
Expand Down

0 comments on commit d81a2c8

Please sign in to comment.