@@ -178,12 +178,10 @@ def set_3d_properties(self, z=0, zdir='z', axlim_clip=False):
178
178
179
179
@artist .allow_rasterization
180
180
def draw (self , renderer ):
181
+ pos3d = np .array ([self ._x , self ._y , self ._z ], dtype = float )
181
182
if self ._axlim_clip :
182
183
mask = _viewlim_mask (self ._x , self ._y , self ._z , self .axes )
183
- pos3d = np .ma .array ((self ._x , self ._y , self ._z ),
184
- dtype = float , mask = mask ).filled (np .nan )
185
- else :
186
- pos3d = np .asanyarray ([self ._x , self ._y , self ._z ])
184
+ pos3d [mask ] = np .nan
187
185
188
186
proj = proj3d ._proj_trans_points ([pos3d , pos3d + self ._dir_vec ], self .axes .M )
189
187
dx = proj [0 ][1 ] - proj [0 ][0 ]
@@ -465,7 +463,8 @@ def do_3d_projection(self):
465
463
self .axes )
466
464
if np .any (viewlim_mask ):
467
465
# broadcast mask to 3D
468
- viewlim_mask = viewlim_mask [..., np .newaxis ].repeat (3 , axis = - 1 )
466
+ viewlim_mask = np .broadcast_to (viewlim_mask [..., np .newaxis ],
467
+ (* viewlim_mask .shape , 3 ))
469
468
mask = mask | viewlim_mask
470
469
xyzs = np .ma .array (proj3d ._proj_transform_vectors (segments , self .axes .M ),
471
470
mask = mask )
@@ -1100,15 +1099,17 @@ def _get_vector(self, segments3d):
1100
1099
"""
1101
1100
if isinstance (segments3d , np .ndarray ):
1102
1101
if segments3d .ndim != 3 or segments3d .shape [- 1 ] != 3 :
1103
- raise ValueError ("segments3d must be a MxNx3 array, but got " +
1104
- "shape {}" . format ( segments3d .shape ) )
1102
+ raise ValueError ("segments3d must be a MxNx3 array, but got "
1103
+ f "shape { segments3d .shape } " )
1105
1104
if isinstance (segments3d , np .ma .MaskedArray ):
1106
1105
self ._faces = segments3d .data
1107
1106
self ._invalid_vertices = segments3d .mask .any (axis = - 1 )
1108
1107
else :
1109
1108
self ._faces = segments3d
1110
1109
self ._invalid_vertices = False
1111
1110
else :
1111
+ # Turn the potentially ragged list into a numpy array for later speedups
1112
+ # If it is ragged, set the unused vertices per face as invalid
1112
1113
num_faces = len (segments3d )
1113
1114
num_verts = np .fromiter (map (len , segments3d ), dtype = np .intp )
1114
1115
max_verts = num_verts .max (initial = 0 )
@@ -1117,8 +1118,6 @@ def _get_vector(self, segments3d):
1117
1118
segments [i , :len (face )] = face
1118
1119
self ._faces = segments
1119
1120
self ._invalid_vertices = np .arange (max_verts ) >= num_verts [:, None ]
1120
- assert self ._invalid_vertices is False or \
1121
- self ._invalid_vertices .shape == self ._faces .shape [:- 1 ]
1122
1121
1123
1122
def set_verts (self , verts , closed = True ):
1124
1123
"""
@@ -1184,11 +1183,7 @@ def do_3d_projection(self):
1184
1183
needs_masking = np .any (self ._invalid_vertices )
1185
1184
num_faces = len (self ._faces )
1186
1185
mask = self ._invalid_vertices
1187
-
1188
- # Some faces might contain masked vertices, so we want to ignore any
1189
- # errors that those might cause
1190
- with np .errstate (invalid = 'ignore' , divide = 'ignore' ):
1191
- pfaces = proj3d ._proj_transform_vectors (self ._faces , self .axes .M )
1186
+ pfaces = proj3d ._proj_transform_vectors (self ._faces , self .axes .M )
1192
1187
1193
1188
if self ._axlim_clip :
1194
1189
viewlim_mask = _viewlim_mask (self ._faces [..., 0 ], self ._faces [..., 1 ],
0 commit comments