@@ -226,6 +226,17 @@ class TestScalarFormatter(object):
226226
227227 use_offset_data = [True , False ]
228228
229+ scilimits_data = [
230+ (False , (0 , 0 ), (10.0 , 20.0 ), 0 ),
231+ (True , (- 2 , 2 ), (- 10 , 20 ), 0 ),
232+ (True , (- 2 , 2 ), (- 20 , 10 ), 0 ),
233+ (True , (- 2 , 2 ), (- 110 , 120 ), 2 ),
234+ (True , (- 2 , 2 ), (- 120 , 110 ), 2 ),
235+ (True , (- 2 , 2 ), (- .001 , 0.002 ), - 3 ),
236+ (True , (0 , 0 ), (- 1e5 , 1e5 ), 5 ),
237+ (True , (6 , 6 ), (- 1e5 , 1e5 ), 6 ),
238+ ]
239+
229240 @pytest .mark .parametrize ('left, right, offset' , offset_data )
230241 def test_offset_value (self , left , right , offset ):
231242 fig , ax = plt .subplots ()
@@ -255,6 +266,18 @@ def test_use_offset(self, use_offset):
255266 tmp_form = mticker .ScalarFormatter ()
256267 assert use_offset == tmp_form .get_useOffset ()
257268
269+ @pytest .mark .parametrize (
270+ 'sci_type, scilimits, lim, orderOfMag' , scilimits_data )
271+ def test_scilimits (self , sci_type , scilimits , lim , orderOfMag ):
272+ tmp_form = mticker .ScalarFormatter ()
273+ tmp_form .set_scientific (sci_type )
274+ tmp_form .set_powerlimits (scilimits )
275+ fig , ax = plt .subplots ()
276+ ax .yaxis .set_major_formatter (tmp_form )
277+ ax .set_ylim (* lim )
278+ tmp_form .set_locs (ax .yaxis .get_majorticklocs ())
279+ assert orderOfMag == tmp_form .orderOfMagnitude
280+
258281
259282class FakeAxis (object ):
260283 """Allow Formatter to be called without having a "full" plot set up."""
0 commit comments