8000 np.clip() to avoid floating point round-off errors · matplotlib/matplotlib@6b15663 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b15663

Browse files
committed
np.clip() to avoid floating point round-off errors
Add np.clip() to avoid floating point round-off errors on the macos github CI runners, see also #28823 (comment)
1 parent 89701eb commit 6b15663

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4053,6 +4053,6 @@ def as_cardan_angles(self):
40534053
qw = self.scalar
40544054
qx, qy, qz = self.vector[..., :]
40554055
azim = np.arctan2(2*(-qw*qz+qx*qy), qw*qw+qx*qx-qy*qy-qz*qz)
4056-
elev = np.arcsin( 2*( qw*qy+qz*qx)/(qw*qw+qx*qx+qy*qy+qz*qz)) # noqa E201
4057-
roll = np.arctan2(2*( qw*qx-qy*qz), qw*qw-qx*qx-qy*qy+qz*qz) # noqa E201
4056+
elev = np.arcsin(np.clip(2*(qw*qy+qz*qx)/(qw*qw+qx*qx+qy*qy+qz*qz)), -1, 1)
4057+
roll = np.arctan2(2*(qw*qx-qy*qz), qw*qw-qx*qx-qy*qy+qz*qz)
40584058
return elev, azim, roll

0 commit comments

Comments
 (0)
0