Skip to content

Commit

Permalink
ref: avoid division-by-zero warning
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 4, 2024
1 parent ae58c9b commit 137f873
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion shapeout2/gui/pipeline_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,13 @@ def compute_contour_opening_angles(plot_state, contour):
b = np.array(cr) - np.array(c0)
absa = np.sqrt(np.sum(a ** 2))
absb = np.sqrt(np.sum(b ** 2))
phi = np.arccos(np.sum(a * b) / (absa * absb))
denom = absa * absb
# avoid division by zero warnings
if isinstance(denom, np.ndarray):
denom[denom == 0] = np.nan
elif denom == 0:
denom = np.nan
phi = np.arccos(np.sum(a * b) / denom)
if np.abs(phi) > np.pi/2:
phi -= np.sign(phi) * np.pi
opang[jj] = phi
Expand Down

0 comments on commit 137f873

Please sign in to comment.