@@ -188,62 +188,34 @@ def test_plot_1d_missing(self):
188
188
189
189
@cleanup
190
190
@pytest .mark .usefixtures ("data" )
191
- def test_plot_bytes (self ):
191
+ @pytest .mark .parametrize ("bins" ,
192
+ [['a' , 'b' , 'c' , 'a' ],
193
+ [b'a' , b'b' , b'c' , b'a' ],
194
+ np .array ([b'a' , b'b' , b'c' , b'a' ])])
195
+ def test_plot_bytes (self , bins ):
192
196
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 )
202
197
198
+ fig , ax = plt .subplots ()
199
+ ax .bar (bins , counts )
203
200
fig .canvas .draw ()
204
201
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 )
202
+ self .axis_test (ax .xaxis , self .dticks , self .dlabels , self .dunit_data )
214
203
215
204
@cleanup
216
- def test_plot_numlike (self ):
205
+ @pytest .mark .parametrize ("bins" ,
206
+ [['1' , '11' , '3' , '1' ],
207
+ np .array (['1' , '11' , '3' , '1' ]),
208
+ [b'1' , b'11' , b'3' , b'1' ],
209
+ np .array ([b'1' , b'11' , b'3' , b'1' ])])
210
+ def test_plot_numlike (self , bins ):
217
211
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 )
231
212
213
+ fig , ax = plt .subplots ()
214
+ ax .bar (bins , counts )
232
215
fig .canvas .draw ()
233
216
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 )
217
+ unitmap = MockUnitData ([('1' , 0 ), ('11' , 1 ), ('3' , 2 )])
218
+ self .axis_test (ax .xaxis , [0 , 1 , 2 ], ['1' , '11' , '3' ], unitmap )
247
219
248
220
@cleanup
249
221
@pytest .mark .usefixtures ("data" , "missing_data" )
0 commit comments