Skip to content

Commit 72616d2

Browse files
authored
Merge pull request #839 from hui2000ji/patch-1
fix: struc.rings._minimum_angle sometimes return nan
2 parents 6aeebd5 + 0f0e4fe commit 72616d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/biotite/structure/rings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ def _minimum_angle(v1, v2):
427427
have no 'preferred side'.
428428
"""
429429
# Do not distinguish between the 'sides' of the rings -> take absolute of cosine
430-
return np.arccos(np.abs(vector_dot(v1, v2)))
430+
# Clamp to 1.0, as due to numeric instability values slightly above 1.0 may appear
431+
return np.arccos(np.minimum(np.abs(vector_dot(v1, v2)), 1.0))
431432

432433

433434
def _is_within_tolerance(angles, expected_angle, tolerance):

0 commit comments

Comments
 (0)