@@ -188,62 +188,38 @@ def test_plot_1d_missing(self):
188188
189189 @cleanup
190190 @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 ])
202199
200+ fig , ax = plt .subplots ()
201+ ax .bar (bars , counts )
203202 fig .canvas .draw ()
204203
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 )
214205
215206 @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 ])
231216
217+ fig , ax = plt .subplots ()
218+ ax .bar (bars , counts )
232219 fig .canvas .draw ()
233220
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 )
247223
248224 @cleanup
249225 @pytest .mark .usefixtures ("data" , "missing_data" )
0 commit comments