Skip to content

Commit e66cd0f

Browse files
committed
Ensure NaN values properly handled in sorted
1 parent dba02be commit e66cd0f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import math
11+
import sys
1112

1213
import numpy as np
1314

@@ -733,7 +734,13 @@ def set_zsort(self, zsort):
733734
The function applied on the z-coordinates of the vertices in the
734735
viewer's coordinate system, to determine the z-order.
735736
"""
736-
self._zsortfunc = self._zsort_functions[zsort]
737+
def nansafe(func):
738+
def f(x):
739+
value = func(x)
740+
return sys.maxsize if np.isnan(value) else value
741+
return f
742+
743+
self._zsortfunc = nansafe(self._zsort_functions[zsort])
737744
self._sort_zpos = None
738745
self.stale = True
739746

0 commit comments

Comments
 (0)