@@ -448,12 +448,16 @@ def test_init(self):
448448 lctr = mticker .AsinhLocator (linear_width = 2.718 , numticks = 19 )
449449 assert lctr .linear_width == 2.718
450450 assert lctr .numticks == 19
451+ assert lctr .base == 0
451452
452453 def test_set_params (self ):
453454 lctr = mticker .AsinhLocator (linear_width = 5 ,
454- numticks = 17 , symthresh = 0.125 )
455+ numticks = 17 , symthresh = 0.125 ,
456+ base = 4 , subs = (2.5 , 3.25 ))
455457 assert lctr .numticks == 17
456458 assert lctr .symthresh == 0.125
459+ assert lctr .base == 4
460+ assert lctr .subs == (2.5 , 3.25 )
457461
458462 lctr .set_params (numticks = 23 )
459463 assert lctr .numticks == 23
@@ -465,8 +469,20 @@ def test_set_params(self):
465469 lctr .set_params (symthresh = None )
466470 assert lctr .symthresh == 0.5
467471
472+ lctr .set_params (base = 7 )
473+ assert lctr .base == 7
474+ lctr .set_params (base = None )
475+ assert lctr .base == 7
476+
477+ lctr .set_params (subs = (2 , 4.125 ))
478+ assert lctr .subs == (2 , 4.125 )
479+ lctr .set_params (subs = None )
480+ assert lctr .subs == (2 , 4.125 )
481+ lctr .set_params (subs = [])
482+ assert lctr .subs is None
483+
468484 def test_linear_values (self ):
469- lctr = mticker .AsinhLocator (linear_width = 100 , numticks = 11 )
485+ lctr = mticker .AsinhLocator (linear_width = 100 , numticks = 11 , base = 0 )
470486
471487 assert_almost_equal (lctr .tick_values (- 1 , 1 ),
472488 np .arange (- 1 , 1.01 , 0.2 ))
@@ -476,7 +492,7 @@ def test_linear_values(self):
476492 np .arange (- 0.01 , 0.0101 , 0.002 ))
477493
478494 def test_wide_values (self ):
479- lctr = mticker .AsinhLocator (linear_width = 0.1 , numticks = 11 )
495+ lctr = mticker .AsinhLocator (linear_width = 0.1 , numticks = 11 , base = 0 )
480496
481497 assert_almost_equal (lctr .tick_values (- 100 , 100 ),
482498 [- 100 , - 20 , - 5 , - 1 , - 0.2 ,
@@ -487,7 +503,7 @@ def test_wide_values(self):
487503
488504 def test_near_zero (self ):
489505 """Check that manually injected zero will supersede nearby tick"""
490- lctr = mticker .AsinhLocator (linear_width = 100 , numticks = 3 )
506+ lctr = mticker .AsinhLocator (linear_width = 100 , numticks = 3 , base = 0 )
491507
492508 assert_almost_equal (lctr .tick_values (- 1.1 , 0.9 ), [- 1.0 , 0.0 , 0.9 ])
493509
@@ -504,7 +520,7 @@ class DummyAxis:
504520 def get_data_interval (cls ): return cls .bounds
505521
506522 lctr = mticker .AsinhLocator (linear_width = 1 , numticks = 3 ,
507- symthresh = 0.25 )
523+ symthresh = 0.25 , base = 0 )
508524 lctr .axis = DummyAxis
509525
510526 DummyAxis .bounds = (- 1 , 2 )
@@ -519,6 +535,20 @@ def get_data_interval(cls): return cls.bounds
519535 DummyAxis .bounds = (1 , 1.1 )
520536 assert_almost_equal (lctr (), [1 , 1.05 , 1.1 ])
521537
538+ def test_base_rounding (self ):
539+ lctr10 = mticker .AsinhLocator (linear_width = 1 , numticks = 8 ,
540+ base = 10 , subs = (1 , 3 , 5 ))
541+ assert_almost_equal (lctr10 .tick_values (- 110 , 110 ),
542+ [- 500 , - 300 , - 100 , - 50 , - 30 , - 10 , - 5 , - 3 , - 1 ,
543+ - 0.5 , - 0.3 , - 0.1 , 0 , 0.1 , 0.3 , 0.5 ,
544+ 1 , 3 , 5 , 10 , 30 , 50 , 100 , 300 , 500 ])
545+
546+ lctr5 = mticker .AsinhLocator (linear_width = 1 , numticks = 20 , base = 5 )
547+ assert_almost_equal (lctr5 .tick_values (- 1050 , 1050 ),
548+ [- 625 , - 125 , - 25 , - 5 , - 1 , - 0.2 , 0 ,
549+ 0.2 , 1 , 5 , 25 , 125 , 625 ])
550+
551+
522552
523553class TestScalarFormatter :
524554 offset_data = [
0 commit comments