@@ -733,16 +733,14 @@ def set_zsort(self, zsort):
733
733
The function applied on the z-coordinates of the vertices in the
734
734
viewer's coordinate system, to determine the z-order.
735
735
"""
736
- def nansafe (func ):
737
- def f (x ):
738
- value = func (x )
739
- return np .inf if np .isnan (value ) else value
740
- return f
741
-
742
- self ._zsortfunc = nansafe (self ._zsort_functions [zsort ])
736
+ self ._zsortfunc = self ._zsort_functions [zsort ]
743
737
self ._sort_zpos = None
744
738
self .stale = True
745
739
740
+ def _zsortval (self , zs ):
741
+ nans = np .isnan (zs )
742
+ return np .inf if nans .all () else self ._zsortfunc (zs [~ nans ])
743
+
746
744
def get_vector (self , segments3d ):
747
745
"""Optimize points for projection."""
748
746
if len (segments3d ):
@@ -821,7 +819,7 @@ def do_3d_projection(self, renderer=None):
821
819
if xyzlist :
822
820
# sort by depth (furthest drawn first)
823
821
z_segments_2d = sorted (
824
- ((self ._zsortfunc (zs ), np .column_stack ([xs , ys ]), fc , ec , idx )
822
+ ((self ._zsortval (zs ), np .column_stack ([xs , ys ]), fc , ec , idx )
825
823
for idx , ((xs , ys , zs ), fc , ec )
826
824
in enumerate (zip (xyzlist , cface , cedge ))),
827
825
key = lambda x : x [0 ], reverse = True )
0 commit comments