@@ -3992,72 +3992,57 @@ def test_hlines():
3992
3992
ax5 .set_ylim (0 , 15 )
3993
3993
3994
3994
3995
- def generate_hlines_with_colors_inputs ():
3996
- colors = cycler ('colors' , [['red' , 'green' , 'blue' , 'purple' , 'orange' ]])
3997
- base_y = cycler (
3998
- 'y' , [[1 , 2 , 3 , np .nan , 5 ], np .ma .masked_equal ([1 , 2 , 3 , 4 , 5 ], 4 )])
3999
- base_max = cycler ('xmax' , [np .ones (5 )])
4000
- base_min = cycler ('xmin' , [0 ])
4001
- base_line_width = cycler ('linewidth' , [5 ])
4002
- original = base_y * base_min * base_max * colors * base_line_width
3995
+ def generate_lines_with_colors_inputs ():
3996
+ colors = ['red' , 'green' , 'blue' , 'purple' , 'orange' ]
3997
+ xy_nan = [1 , 2 , 3 , np .nan , 5 ]
3998
+ xy_mask = np .ma .masked_equal ([1 , 2 , 3 , 4 , 5 ], 4 )
3999
+ lines_nan = [{'base_xy' : xy_nan ,
4000
+ 'base_max' : np .ones (5 ),
4001
+ 'base_min' : [0 ],
4002
+ 'linewidth' : 5 ,
4003
+ 'colors' : colors }]
4004
+ lines_mask = [{'base_xy' : xy_mask ,
4005
+ 'base_max' : np .ones (5 ),
4006
+ 'base_min' : [0 ],
4007
+ 'linewidth' : 5 ,
4008
+ 'colors' : colors }]
4009
+
4010
+ return [* lines_nan , * lines_mask ]
4011
+
4012
+
4013
+ @pytest .mark .parametrize ('kwargs' , generate_lines_with_colors_inputs ())
4014
+ @check_figures_equal (extensions = ["png" ])
4015
+ def test_vlines_with_colors (fig_test , fig_ref , kwargs ):
4016
+ kwargs ['x' ] = kwargs .pop ('base_xy' )
4017
+ kwargs ['ymin' ] = kwargs .pop ('base_min' )
4018
+ kwargs ['ymax' ] = kwargs .pop ('base_max' )
4019
+ fig_test .subplots ().vlines (** kwargs )
4003
4020
4004
4021
expect = {
4005
- 'y' : [1 , 2 , 3 , 5 ],
4006
- 'xmin' : 0 , 'xmax' : [1 , 2 , 3 , 5 ],
4007
- 'colors' : ['red' , 'green' , 'blue' , 'orange' ]}
4008
-
4009
- result = []
4010
-
4011
- for i in original :
4012
- result .append ({'original' : i , 'expect' : expect })
4022
+ 'x' : [1 , 2 , 3 , 5 ],
4023
+ 'ymin' : [0 ],
4024
+ 'ymax' : np .ones (4 ),
4025
+ 'colors' : ['red' , 'green' , 'blue' , 'orange' ],
4026
+ 'linewidth' : 5 }
4027
+ fig_ref .subplots ().vlines (** expect )
4013
4028
4014
- return result
4015
4029
4016
-
4017
- @pytest .mark .parametrize ('kwargs' , generate_hlines_with_colors_inputs ())
4030
+ @pytest .mark .parametrize ('kwargs' , generate_lines_with_colors_inputs ())
4018
4031
@check_figures_equal (extensions = ["png" ])
4019
4032
def test_hlines_with_colors (fig_test , fig_ref , kwargs ):
4020
- fig_test , ax0 = plt .subplots ()
4021
- test = kwargs .pop ('original' )
4022
- ax0 .hlines (** test )
4023
-
4024
- fig_ref , ax1 = plt .subplots ()
4025
- ref = kwargs .pop ('expect' )
4026
- ax1 .hlines (** ref )
4027
-
4028
-
4029
- def generate_vlines_with_colors_inputs ():
4030
- colors = cycler ('colors' , [['red' , 'green' , 'blue' , 'purple' , 'orange' ]])
4031
- base_x = cycler (
4032
- 'x' , [[1 , 2 , 3 , np .nan , 5 ], np .ma .masked_equal ([1 , 2 , 3 , 4 , 5 ], 4 )])
4033
- base_max = cycler ('ymax' , [np .ones (5 )])
4034
- base_min = cycler ('ymin' , [0 ])
4035
- base_line_width = cycler ('linewidth' , [5 ])
4036
- original = base_x * base_min * base_max * colors * base_line_width
4033
+ kwargs ['y' ] = kwargs .pop ('base_xy' )
4034
+ kwargs ['xmin' ] = kwargs .pop ('base_min' )
4035
+ kwargs ['xmax' ] = kwargs .pop ('base_max' )
4036
+ fig_test .subplots ().hlines (** kwargs )
4037
4037
4038
4038
expect = {
4039
- 'x' : [1 , 2 , 3 , 5 ],
4040
- 'ymin' : 0 ,
4041
- 'ymax' : [1 , 2 , 3 , 5 ],
4042
- 'colors' : ['red' , 'green' , 'blue' , 'orange' ]}
4043
-
4044
- result = []
4045
- for i in original :
4046
- result .append ({'original' : i , 'expect' : expect })
4047
-
4048
- return result
4049
-
4050
-
4051
- @pytest .mark .parametrize ('kwargs' , generate_vlines_with_colors_inputs ())
4052
- @check_figures_equal (extensions = ["png" ])
4053
- def test_vlines_with_colors (fig_test , fig_ref , kwargs ):
4054
- fig_test , ax0 = plt .subplots ()
4055
- test = kwargs .pop ('original' )
4056
- ax0 .vlines (** test )
4039
+ 'y' : [1 , 2 , 3 , 5 ],
4040
+ 'xmin' : [0 ],
4041
+ 'xmax' : np .ones (4 ),
4042
+ 'colors' : ['red' , 'green' , 'blue' , 'orange' ],
4043
+ 'linewidth' : 5 }
4057
4044
4058
- fig_ref , ax1 = plt .subplots ()
4059
- ref = kwargs .pop ('expect' )
4060
- ax1 .vlines (** ref )
4045
+ fig_ref .subplots ().hlines (** expect )
4061
4046
4062
4047
4063
4048
@image_comparison (['step_linestyle' , 'step_linestyle' ], remove_text = True )
0 commit comments