@@ -458,7 +458,6 @@ def get_transform(self):
458
458
return self ._transform
459
459
460
460
461
-
462
461
class AsinhScale (ScaleBase ):
463
462
"""
464
463
A quasi-logarithmic scale based on the inverse hyperbolic sine (asinh)
@@ -480,6 +479,8 @@ def __init__(self, axis, *, a0=1.0, **kwargs):
480
479
The scale parameter defining the extent of the quasi-linear region.
481
480
"""
482
481
super ().__init__ (axis )
482
+ if a0 <= 0.0 :
483
+ raise ValueError ("Scale parameter 'a0' must be strictly positive" )
483
484
self .a0 = a0
484
485
485
486
def get_transform (self ):
@@ -490,7 +491,7 @@ def set_default_locators_and_formatters(self, axis):
490
491
major_formatter = '{x:.3g}' )
491
492
492
493
class AsinhTransform (Transform ):
493
- input_dims = output_dims = 1
494
+ input_dims = output_dims = 1
494
495
495
496
def __init__ (self , a0 ):
496
497
super ().__init__ ()
@@ -503,7 +504,7 @@ def inverted(self):
503
504
return AsinhScale .InvertedAsinhTransform (self .a0 )
504
505
505
506
class InvertedAsinhTransform (Transform ):
506
- input_dims = output_dims = 1
507
+ input_dims = output_dims = 1
507
508
508
509
def __init__ (self , a0 ):
509
510
super ().__init__ ()
@@ -526,9 +527,11 @@ def __init__(self, a0, apx_tick_count=12):
526
527
Parameters
527
528
----------
528
529
a0 : float
529
- The scale parameter defining the extent of the quasi-linear region.
530
+ The scale parameter defining the extent
531
+ of the quasi-linear region.
530
532
apx_tick_count : int, default: 12
531
- The approximate number of major ticks that will fit along the entire axis
533
+ The approximate number of major ticks that will fit
534
+ along the entire axis
532
535
"""
533
536
super ().__init__ ()
534
537
self .a0 = a0
@@ -539,12 +542,14 @@ def __call__(self):
539
542
return self .tick_values (dmin , dmax )
540
543
541
544
def tick_values (self , vmin , vmax ):
542
- # Construct a set of "on-screen" locations that are uniformly spaced:
545
+ # Construct a set of "on-screen" locations
546
+ # that are uniformly spaced:
543
547
ymin , ymax = self .a0 * np .arcsinh (np .array ([vmin , vmax ]) / self .a0 )
544
548
ys = np .linspace (ymin , ymax , self .apx_tick_count )
545
549
if (ymin * ymax ) < 0 :
546
- # Ensure that zero tick-mark is included if the axis stradles zero
547
- ys = np .hstack ([ ys , 0.0 ])
550
+ # Ensure that the zero tick-mark is included,
551
+ # if the axis stradles zero
552
+ ys = np .hstack ([ys , 0.0 ])
548
553
549
554
# Transform the "on-screen" grid to the data space:
550
555
xs = self .a0 * np .sinh (ys / self .a0 )
@@ -554,14 +559,14 @@ def tick_values(self, vmin, vmax):
554
559
decades = (
555
560
np .where (xs >= 0 , 1 , - 1 ) *
556
561
np .power (10 , np .where (zero_xs , 1.0 ,
557
- np .floor (np .log10 (np .abs (xs ) + zero_xs * 1e-6 ))))
562
+ np .floor (np .log10 (np .abs (xs )
563
+ + zero_xs * 1e-6 ))))
558
564
)
559
565
qs = decades * np .round (xs / decades )
560
566
561
567
return np .array (sorted (set (qs )))
562
568
563
569
564
-
565
570
class LogitTransform (Transform ):
566
571
input_dims = output_dims = 1
567
572
0 commit comments