@@ -122,71 +122,69 @@ def test_expand_with_tight_layout():
122
122
fig .tight_layout () # where the crash used to happen
123
123
124
124
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 ] ))
127
127
@pytest .mark .parametrize ('total' , (250 , 100 , 0 , - 1 , None ))
128
128
@pytest .mark .parametrize ('sep' , (250 , 1 , 0 , - 1 ))
129
129
@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 ):
131
131
# Check a (rather arbitrary) set of parameters due to successive similar
132
132
# issue tickets (at least #10476 and #10784) related to corner cases
133
133
# triggered inside this function when calling higher-level functions
134
134
# (e.g. `Axes.legend`).
135
135
# 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 )
137
137
138
138
139
139
_Params = namedtuple ('_params' , 'wd_list, total, sep, expected' )
140
140
141
141
142
- @pytest .mark .parametrize ('wd_list , total, sep, expected' , [
142
+ @pytest .mark .parametrize ('widths , total, sep, expected' , [
143
143
_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 ])),
145
145
_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 ])),
147
147
_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 ])),
149
149
])
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' )
152
152
assert result [0 ] == expected [0 ]
153
153
assert_allclose (result [1 ], expected [1 ])
154
154
155
155
156
- @pytest .mark .parametrize ('wd_list , total, sep, expected' , [
156
+ @pytest .mark .parametrize ('widths , total, sep, expected' , [
157
157
_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 ])),
159
159
_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 ])),
161
161
_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 ])),
163
163
])
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' )
166
166
assert result [0 ] == expected [0 ]
167
167
assert_allclose (result [1 ], expected [1 ])
168
168
169
169
170
- @pytest .mark .parametrize ('wd_list , total, sep, expected' , [
170
+ @pytest .mark .parametrize ('widths , total, sep, expected' , [
171
171
_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 ])),
173
173
_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 ])),
176
175
_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 ])),
179
177
# the case total=None, sep=None is tested separately below
180
178
])
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' )
183
181
assert result [0 ] == expected [0 ]
184
182
assert_allclose (result [1 ], expected [1 ])
185
183
186
184
187
185
def test_get_packed_offsets_equal_total_none_sep_none ():
188
186
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' )
190
188
191
189
192
190
@pytest .mark .parametrize ('child_type' , ['draw' , 'image' , 'text' ])
0 commit comments