@@ -188,62 +188,38 @@ def test_plot_1d_missing(self):
188
188
189
189
@cleanup
190
190
@pytest .mark .usefixtures ("data" )
191
- def test_plot_bytes (self ):
192
- counts = np .array ([4 , 6 , 5 , 1 ])
193
- fig , ax = plt .subplots (ncols = 3 )
194
-
195
- ax [0 ].bar (self .d , counts )
196
-
197
- types = [v .encode ('ascii' ) for v in self .d ]
198
- ax [1 ].bar (types , counts )
199
-
200
- types = np .array (types )
201
- ax [2 ].bar (types , counts )
191
+ @pytest .mark .parametrize ("bars" ,
192
+ [['a' , 'b' , 'c' ],
193
+ [b'a' , b'b' , b'c' ],
194
+ np .array ([b'a' , b'b' , b'c' ])],
195
+ ids = ['string list' , 'bytes list' ,
196
+ 'bytes ndarray' ])
197
+ def test_plot_bytes (self , bars ):
198
+ counts = np .array ([4 , 6 , 5 ])
202
199
200
+ fig , ax = plt .subplots ()
201
+ ax .bar (bars , counts )
203
202
fig .canvas .draw ()
204
203
205
- # All three plots should look like the string one.
206
- self .axis_test (ax [1 ].xaxis ,
207
- ax [0 ].xaxis .get_majorticklocs (),
208
- lt (ax [0 ].xaxis .get_majorticklabels ()),
209
- ax [0 ].xaxis .unit_data )
210
- self .axis_test (ax [2 ].xaxis ,
211
- ax [0 ].xaxis .get_majorticklocs (),
212
- lt (ax [0 ].xaxis .get_majorticklabels ()),
213
- ax [0 ].xaxis .unit_data )
204
+ self .axis_test (ax .xaxis , self .dticks , self .dlabels , self .dunit_data )
214
205
215
206
@cleanup
216
- def test_plot_numlike (self ):
217
- counts = np .array ([4 , 6 , 5 , 1 ])
218
- fig , ax = plt .subplots (ncols = 4 )
219
-
220
- types = ['1' , '11' , '3' , '1' ]
221
- ax [0 ].bar (types , counts )
222
-
223
- types = np .array (types )
224
- ax [1 ].bar (types , counts )
225
-
226
- types = [b'1' , b'11' , b'3' , b'1' ]
227
- ax [2 ].bar (types , counts )
228
-
229
- types = np .array (types )
230
- ax [3 ].bar (types , counts )
207
+ @pytest .mark .parametrize ("bars" ,
208
+ [['1' , '11' , '3' ],
209
+ np .array (['1' , '11' , '3' ]),
210
+ [b'1' , b'11' , b'3' ],
211
+ np .array ([b'1' , b'11' , b'3' ])],
212
+ ids = ['string list' , 'string ndarray' ,
213
+ 'bytes list' , 'bytes ndarray' ])
214
+ def test_plot_numlike (self , bars ):
215
+ counts = np .array ([4 , 6 , 5 ])
231
216
217
+ fig , ax = plt .subplots ()
218
+ ax .bar (bars , counts )
232
219
fig .canvas .draw ()
233
220
234
- # All four plots should look like the string one.
235
- self .axis_test (ax [1 ].xaxis ,
236
- ax [0 ].xaxis .get_majorticklocs (),
237
- lt (ax [0 ].xaxis .get_majorticklabels ()),
238
- ax [0 ].xaxis .unit_data )
239
- self .axis_test (ax [2 ].xaxis ,
240
- ax [0 ].xaxis .get_majorticklocs (),
241
- lt (ax [0 ].xaxis .get_majorticklabels ()),
242
- ax [0 ].xaxis .unit_data )
243
- self .axis_test (ax [3 ].xaxis ,
244
- ax [0 ].xaxis .get_majorticklocs (),
245
- lt (ax [0 ].xaxis .get_majorticklabels ()),
246
- ax [0 ].xaxis .unit_data )
221
+ unitmap = MockUnitData ([('1' , 0 ), ('11' , 1 ), ('3' , 2 )])
222
+ self .axis_test (ax .xaxis , [0 , 1 , 2 ], ['1' , '11' , '3' ], unitmap )
247
223
248
224
@cleanup
249
225
@pytest .mark .usefixtures ("data" , "missing_data" )
0 commit comments