@@ -122,71 +122,69 @@ def test_expand_with_tight_layout():
122122 fig .tight_layout () # where the crash used to happen
123123
124124
125- @pytest .mark .parametrize ('wd_list ' ,
126- ([( 150 , 1 ) ], [( 150 , 1 )] * 3 , [( 0.1 , 1 ) ], [( 0.1 , 1 )] * 2 ))
125+ @pytest .mark .parametrize ('widths ' ,
126+ ([150 ], [150 , 150 , 150 ] , [0.1 ], [0.1 , 0.1 ] ))
127127@pytest .mark .parametrize ('total' , (250 , 100 , 0 , - 1 , None ))
128128@pytest .mark .parametrize ('sep' , (250 , 1 , 0 , - 1 ))
129129@pytest .mark .parametrize ('mode' , ("expand" , "fixed" , "equal" ))
130- def test_get_packed_offsets (wd_list , total , sep , mode ):
130+ def test_get_packed_offsets (widths , total , sep , mode ):
131131 # Check a (rather arbitrary) set of parameters due to successive similar
132132 # issue tickets (at least #10476 and #10784) related to corner cases
133133 # triggered inside this function when calling higher-level functions
134134 # (e.g. `Axes.legend`).
135135 # These are just some additional smoke tests. The output is untested.
136- _get_packed_offsets (wd_list , total , sep , mode = mode )
136+ _get_packed_offsets (widths , total , sep , mode = mode )
137137
138138
139139_Params = namedtuple ('_params' , 'wd_list, total, sep, expected' )
140140
141141
142- @pytest .mark .parametrize ('wd_list , total, sep, expected' , [
142+ @pytest .mark .parametrize ('widths , total, sep, expected' , [
143143 _Params ( # total=None
144- [( 3 , 0 ), ( 1 , 0 ), ( 2 , 0 ) ], total = None , sep = 1 , expected = (8 , [0 , 4 , 6 ])),
144+ [3 , 1 , 2 ], total = None , sep = 1 , expected = (8 , [0 , 4 , 6 ])),
145145 _Params ( # total larger than required
146- [( 3 , 0 ), ( 1 , 0 ), ( 2 , 0 ) ], total = 10 , sep = 1 , expected = (10 , [0 , 4 , 6 ])),
146+ [3 , 1 , 2 ], total = 10 , sep = 1 , expected = (10 , [0 , 4 , 6 ])),
147147 _Params ( # total smaller than required
148- [( 3 , 0 ), ( 1 , 0 ), ( 2 , 0 ) ], total = 5 , sep = 1 , expected = (5 , [0 , 4 , 6 ])),
148+ [3 , 1 , 2 ], total = 5 , sep = 1 , expected = (5 , [0 , 4 , 6 ])),
149149])
150- def test_get_packed_offsets_fixed (wd_list , total , sep , expected ):
151- result = _get_packed_offsets (wd_list , total , sep , mode = 'fixed' )
150+ def test_get_packed_offsets_fixed (widths , total , sep , expected ):
151+ result = _get_packed_offsets (widths , total , sep , mode = 'fixed' )
152152 assert result [0 ] == expected [0 ]
153153 assert_allclose (result [1 ], expected [1 ])
154154
155155
156- @pytest .mark .parametrize ('wd_list , total, sep, expected' , [
156+ @pytest .mark .parametrize ('widths , total, sep, expected' , [
157157 _Params ( # total=None (implicit 1)
158- [( .1 , 0 )] * 3 , total = None , sep = None , expected = (1 , [0 , .45 , .9 ])),
158+ [.1 , .1 , .1 ] , total = None , sep = None , expected = (1 , [0 , .45 , .9 ])),
159159 _Params ( # total larger than sum of widths
160- [( 3 , 0 ), ( 1 , 0 ), ( 2 , 0 ) ], total = 10 , sep = 1 , expected = (10 , [0 , 5 , 8 ])),
160+ [3 , 1 , 2 ], total = 10 , sep = 1 , expected = (10 , [0 , 5 , 8 ])),
161161 _Params ( # total smaller sum of widths: overlapping boxes
162- [( 3 , 0 ), ( 1 , 0 ), ( 2 , 0 ) ], total = 5 , sep = 1 , expected = (5 , [0 , 2.5 , 3 ])),
162+ [3 , 1 , 2 ], total = 5 , sep = 1 , expected = (5 , [0 , 2.5 , 3 ])),
163163])
164- def test_get_packed_offsets_expand (wd_list , total , sep , expected ):
165- result = _get_packed_offsets (wd_list , total , sep , mode = 'expand' )
164+ def test_get_packed_offsets_expand (widths , total , sep , expected ):
165+ result = _get_packed_offsets (widths , total , sep , mode = 'expand' )
166166 assert result [0 ] == expected [0 ]
167167 assert_allclose (result [1 ], expected [1 ])
168168
169169
170- @pytest .mark .parametrize ('wd_list , total, sep, expected' , [
170+ @pytest .mark .parametrize ('widths , total, sep, expected' , [
171171 _Params ( # total larger than required
172- [( 3 , 0 ), ( 2 , 0 ), ( 1 , 0 ) ], total = 6 , sep = None , expected = (6 , [0 , 2 , 4 ])),
172+ [3 , 2 , 1 ], total = 6 , sep = None , expected = (6 , [0 , 2 , 4 ])),
173173 _Params ( # total smaller sum of widths: overlapping boxes
174- [(3 , 0 ), (2 , 0 ), (1 , 0 ), (.5 , 0 )], total = 2 , sep = None ,
175- expected = (2 , [0 , 0.5 , 1 , 1.5 ])),
174+ [3 , 2 , 1 , .5 ], total = 2 , sep = None , expected = (2 , [0 , 0.5 , 1 , 1.5 ])),
176175 _Params ( # total larger than required
177- [(.5 , 0 ), (1 , 0 ), (.2 , 0 )], total = None , sep = 1 ,
178- expected = (6 , [0 , 2 , 4 ])),
176+ [.5 , 1 , .2 ], total = None , sep = 1 , expected = (6 , [0 , 2 , 4 ])),
179177 # the case total=None, sep=None is tested separately below
180178])
181- def test_get_packed_offsets_equal (wd_list , total , sep , expected ):
182- result = _get_packed_offsets (wd_list , total , sep , mode = 'equal' )
179+ def test_get_packed_offsets_equal (widths , total , sep , expected ):
180+ result = _get_packed_offsets (widths , total , sep , mode = 'equal' )
183181 assert result [0 ] == expected [0 ]
184182 assert_allclose (result [1 ], expected [1 ])
185183
186184
187185def test_get_packed_offsets_equal_total_none_sep_none ():
188186 with pytest .raises (ValueError ):
189- _get_packed_offsets ([( 1 , 0 )] * 3 , total = None , sep = None , mode = 'equal' )
187+ _get_packed_offsets ([1 , 1 , 1 ] , total = None , sep = None , mode = 'equal' )
190188
191189
192190@pytest .mark .parametrize ('child_type' , ['draw' , 'image' , 'text' ])
0 commit comments