Skip to content

Commit

Permalink
Handle LinAlgError when computing matrix condition numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
moeyensj committed Mar 1, 2024
1 parent 790e919 commit d4e1de0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions thor/orbits/od.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,16 @@ def od(
ATWA = np.sum(ATWA, axis=2)
ATWb = np.sum(ATWb, axis=2)

ATWA_condition = np.linalg.cond(ATWA)
ATWb_condition = np.linalg.cond(ATWb)
try:
# Calculate the condition number of both matrices
ATWA_condition = np.linalg.cond(ATWA)
ATWb_condition = np.linalg.cond(ATWb)
except np.linalg.LinAlgError:
ATWA_condition = np.nan
ATWb_condition = np.nan
logger.debug(
f"Matrix condition calculation failed for {orbit.orbit_id[0].as_py()}"
)

if (ATWA_condition > 1e15) or (ATWb_condition > 1e15):
delta_prev /= DELTA_DECREASE_FACTOR
Expand Down

0 comments on commit d4e1de0

Please sign in to comment.