@@ -2523,9 +2523,11 @@ def point_vector_to_line(point, vector, length):
2523
2523
arrow_length_ratio = kwargs .pop ('arrow_length_ratio' , 0.3 )
2524
2524
2525
2525
# handle args
2526
- if len (args ) < 6 :
2527
- ValueError ('Wrong number of arguments' )
2528
2526
argi = 6
2527
+ if len (args ) < argi :
2528
+ ValueError ('Wrong number of arguments. Expected %d got %d' %
2529
+ (argi , len (args )))
2530
+
2529
2531
# first 6 arguments are X, Y, Z, U, V, W
2530
2532
input_args = args [:argi ]
2531
2533
# if any of the args are scalar, convert into list
@@ -2549,24 +2551,17 @@ def point_vector_to_line(point, vector, length):
2549
2551
2550
2552
if any (len (v ) == 0 for v in input_args ):
2551
2553
# No quivers, so just make an empty collection and return early
2552
- linec = art3d .Line3DCollection ([], * args [6 :], ** kwargs )
2554
+ linec = art3d .Line3DCollection ([], * args [argi :], ** kwargs )
2553
2555
self .add_collection (linec )
2554
2556
return linec
2555
2557
2556
- points = input_args [:3 ]
2557
- vectors = input_args [3 :]
2558
-
2559
- # Below assertions must be true before proceed
2558
+ # Following assertions must be true before proceeding
2560
2559
# must all be ndarray
2561
2560
assert all (isinstance (k , np .ndarray ) for k in input_args )
2562
2561
# must all in same shape
2563
2562
assert len (set ([k .shape for k in input_args ])) == 1
2564
2563
2565
- # X, Y, Z, U, V, W
2566
- coords = (np .array (k ) if not isinstance (k , np .ndarray ) else k
2567
- for k in args )
2568
- coords = [k .flatten () for k in coords ]
2569
- xs , ys , zs , us , vs , ws = coords
2564
+ xs , ys , zs , us , vs , ws = input_args [:argi ]
2570
2565
lines = []
2571
2566
2572
2567
# for each arrow
@@ -2578,12 +2573,11 @@ def point_vector_to_line(point, vector, length):
2578
2573
u = us [i ]
2579
2574
v = vs [i ]
2580
2575
w = ws [i ]
2581
- if any (k is np .ma .masked for k in [x , y , z , u , v , w ]):
2582
- continue
2583
2576
2584
2577
# (u,v,w) expected to be normalized, recursive to fix A=0 scenario.
2585
2578
if u == 0 and v == 0 and w == 0 :
2586
- raise ValueError ("u,v,w can't be all zero" )
2579
+ # Just don't make a quiver for such a case.
2580
+ continue
2587
2581
2588
2582
# normalize
2589
2583
norm = math .sqrt (u ** 2 + v ** 2 + w ** 2 )
@@ -2603,6 +2597,7 @@ def point_vector_to_line(point, vector, length):
2603
2597
ua1 , va1 , wa1 = d1 [0 ], d1 [1 ], d1 [2 ]
2604
2598
ua2 , va2 , wa2 = d2 [0 ], d2 [1 ], d2 [2 ]
2605
2599
2600
+ # TODO: num should probably get parameterized
2606
2601
t = np .linspace (0 , length * arrow_length_ratio , num = 20 )
2607
2602
la1x = x - t * ua1
2608
2603
la1y = y - t * va1
@@ -2616,7 +2611,7 @@ def point_vector_to_line(point, vector, length):
2616
2611
line = list (zip (la2x , la2y , la2z ))
2617
2612
lines .append (line )
2618
2613
2619
- linec = art3d .Line3DCollection (lines , * args [6 :], ** kwargs )
2614
+ linec = art3d .Line3DCollection (lines , * args [argi :], ** kwargs )
2620
2615
self .add_collection (linec )
2621
2616
2622
2617
self .auto_scale_xyz (xs , ys , zs , had_data )
0 commit comments