@@ -246,7 +246,7 @@ def paths_to_3d_segments_with_codes(paths, zs=0, zdir='z'):
246
246
247
247
return np .asarray (segments ), np .asarray (codes_list )
248
248
else :
249
- return np .empty ((3 , 0 ), dtype = ' float64' ), np .array ([], dtype = ' uint8' )
249
+ return np .empty ((0 , 3 ), dtype = np . float64 ), np .array ([], dtype = np . uint8 )
250
250
251
251
252
252
class Line3DCollection (LineCollection ):
@@ -606,15 +606,17 @@ def set_zsort(self, zsort):
606
606
def get_vector (self , segments3d ):
607
607
"""Optimize points for projection"""
608
608
609
- self ._seg_sizes = np .array ([len (c ) for c in segments3d ])
609
+ self ._seg_sizes = np .array ([len (c ) for c in segments3d ], dtype = np . int )
610
610
self ._vec = []
611
611
612
612
# Store the points in a single array for easier projection
613
613
n_segments = np .sum (self ._seg_sizes )
614
614
self ._vec = np .empty ((4 , n_segments ))
615
615
# Put all segments in a big array
616
- self ._vec [:3 , :] = np .vstack (segments3d ).T
617
- self ._vec [3 , :] = 1
616
+ # TODO: avoid copy in np.vstack when segments3d is a 3D numpy array
617
+ if n_segments :
618
+ self ._vec [:3 , :] = np .vstack (segments3d ).T
619
+ self ._vec [3 , :] = 1
618
620
619
621
def set_verts (self , verts , closed = True ):
620
622
"""Set 3D vertices."""
0 commit comments