@@ -673,54 +673,49 @@ def test_no_warn_big_data_when_loc_specified():
673
673
fig .draw_artist (legend ) # Check that no warning is emitted.
674
674
675
675
676
- def test_plot_multiple_input_multiple_label ():
676
+ @pytest .mark .parametrize ('label_array' , [['low' , 'high' ], ('low' , 'high' ), np .array (['low' , 'high' ])])
677
+ def test_plot_multiple_input_multiple_label (label_array ):
677
678
# test ax.plot() with multidimensional input
678
679
# and multiple labels
679
680
x = [1 , 2 , 3 ]
680
681
y = [[1 , 2 ],
681
682
[2 , 5 ],
682
683
[4 , 9 ]]
683
- label_arrays = [['low' , 'high' ],
684
- ('low' , 'high' ),
685
- np .array (['low' , 'high' ])]
686
- for label in label_arrays :
687
- fig , ax = plt .subplots ()
688
- ax .plot (x , y , label = label )
689
- leg = ax .legend ()
690
- legend_texts = [entry .get_text () for entry in leg .get_texts ()]
691
- assert legend_texts == ['low' , 'high' ]
692
684
685
+ fig , ax = plt .subplots ()
686
+ ax .plot (x , y , label = label_array )
687
+ leg = ax .legend ()
688
+ legend_texts = [entry .get_text () for entry in leg .get_texts ()]
689
+ assert legend_texts == ['low' , 'high' ]
693
690
694
- def test_plot_multiple_input_single_label ():
691
+
692
+ @pytest .mark .parametrize ('label' , ['one' , 1 , int ])
693
+ def test_plot_multiple_input_single_label (label ):
695
694
# test ax.plot() with multidimensional input
696
695
# and single label
697
696
x = [1 , 2 , 3 ]
698
697
y = [[1 , 2 ],
699
698
[2 , 5 ],
700
699
[4 , 9 ]]
701
- labels = ['one' , 1 , int ]
702
- for label in labels :
703
- fig , ax = plt .subplots ()
704
- ax .plot (x , y , label = label )
705
- leg = ax .legend ()
706
- legend_texts = [entry .get_text () for entry in leg .get_texts ()]
707
- assert legend_texts == [str (label )] * 2
708
700
701
+ fig , ax = plt .subplots ()
702
+ ax .plot (x , y , label = label )
703
+ leg = ax .legend ()
704
+ legend_texts = [entry .get_text () for entry in leg .get_texts ()]
705
+ assert legend_texts == [str (label )] * 2
709
706
710
- def test_plot_single_input_multiple_label ():
707
+
708
+ @pytest .mark .parametrize ('label_array' , [['low' , 'high' ], ('low' , 'high' ), np .array (['low' , 'high' ])])
709
+ def test_plot_single_input_multiple_label (label_array ):
711
710
# test ax.plot() with 1D array like input
712
711
# and iterable label
713
712
x = [1 , 2 , 3 ]
714
713
y = [2 , 5 , 6 ]
715
- label_arrays = [['low' , 'high' ],
716
- ('low' , 'high' ),
717
- np .array (['low' , 'high' ])]
718
- for label in label_arrays :
719
- fig , ax = plt .subplots ()
720
- ax .plot (x , y , label = label )
721
- leg = ax .legend ()
722
- assert len (leg .get_texts ()) == 1
723
- assert leg .get_texts ()[0 ].get_text () == str (label )
714
+ fig , ax = plt .subplots ()
715
+ ax .plot (x , y , label = label_array )
716
+ leg = ax .legend ()
717
+ assert len (leg .get_texts ()) == 1
718
+ assert leg .get_texts ()[0 ].get_text () == str (label_array )
724
719
725
720
726
721
def test_plot_multiple_label_incorrect_length_exception ():
0 commit comments