20
20
AutoMinorLocator ,
21
21
)
22
22
23
+
23
24
def _make_inset_locator (rect , trans , parent ):
24
25
"""
25
26
Helper function to locate inset axes, used in
@@ -63,6 +64,7 @@ def _parse_conversion(name, otherargs):
63
64
else :
64
65
raise ValueError (f'"{ name } " not a possible conversion string' )
65
66
67
+
66
68
class Secondary_Axis (_AxesBase ):
67
69
"""
68
70
General class to hold a Secondary_X/Yaxis.
@@ -417,7 +419,7 @@ def transform_affine(self, values):
417
419
return np .asarray (values ) * self ._slope + self ._offset
418
420
419
421
def inverted (self ):
420
- return _InvertedLinearTransform (self ._slope , self ._offset )
422
+ return _InverseLinearTransform (self ._slope , self ._offset )
421
423
422
424
423
425
class _InverseLinearTransform (mtransforms .AffineBase ):
@@ -440,18 +442,20 @@ def transform_affine(self, values):
440
442
def inverted (self ):
441
443
return _LinearTransform (self ._slope , self ._offset )
442
444
445
+
443
446
def _mask_out_of_bounds (a ):
444
447
"""
445
448
Return a Numpy array where all values outside ]0, 1[ are
446
449
replaced with NaNs. If all values are inside ]0, 1[, the original
447
450
array is returned.
448
451
"""
449
- a = numpy .array (a , float )
452
+ a = np .array (a , float )
450
453
mask = (a <= 0.0 ) | (a >= 1.0 )
451
454
if mask .any ():
452
- return numpy .where (mask , numpy .nan , a )
455
+ return np .where (mask , np .nan , a )
453
456
return a
454
457
458
+
455
459
class _InvertTransform (mtransforms .Transform ):
456
460
"""
457
461
Return a/x
@@ -462,16 +466,9 @@ class _InvertTransform(mtransforms.Transform):
462
466
is_separable = True
463
467
has_inverse = True
464
468
465
- def __init__ (self , fac , out_of_bounds = 'mask' ):
469
+ def __init__ (self , fac ):
466
470
mtransforms .Transform .__init__ (self )
467
471
self ._fac = fac
468
- self .out_of_bounds = out_of_bounds
469
- if self .out_of_bounds == 'mask' :
470
- self ._handle_out_of_bounds = _mask_out_of_bounds
471
- elif self .out_of_bounds == 'clip' :
472
- self ._handle_out_of_bounds = _clip_out_of_bounds
473
- else :
474
- raise ValueError ("`out_of_bounds` muse be either 'mask' or 'clip'" )
475
472
476
473
def transform_non_affine (self , values ):
477
474
with np .errstate (divide = "ignore" , invalid = "ignore" ):
@@ -493,22 +490,14 @@ class _PowerTransform(mtransforms.Transform):
493
490
is_separable = True
494
491
has_inverse = True
495
492
496
- def __init__ (self , a , b , out_of_bounds = 'mask' ):
493
+ def __init__ (self , a , b ):
497
494
mtransforms .Transform .__init__ (self )
498
495
self ._a = a
499
496
self ._b = b
500
- self .out_of_bounds = out_of_bounds
501
- if self .out_of_bounds == 'mask' :
502
- self ._handle_out_of_bounds = _mask_out_of_bounds
503
- elif self .out_of_bounds == 'clip' :
504
- self ._handle_out_of_bounds = _clip_out_of_bounds
505
- else :
506
- raise ValueError ("`out_of_bounds` muse be either 'mask' or 'clip'" )
507
497
508
498
def transform_non_affine (self , values ):
509
499
with np .errstate (divide = "ignore" , invalid = "ignore" ):
510
500
q = self ._b * (values ** self ._a )
511
- print ('forward' , values , q )
512
501
return q
513
502
514
503
def inverted (self ):
@@ -526,21 +515,14 @@ class _InversePowerTransform(mtransforms.Transform):
526
515
is_separable = True
527
516
has_inverse = True
528
517
529
- def __init__ (self , a , b , out_of_bounds = 'mask' ):
518
+ def __init__ (self , a , b ):
530
519
mtransforms .Transform .__init__ (self )
531
520
self ._a = a
532
521
self ._b = b
533
- self .out_of_bounds = out_of_bounds
534
- if self .out_of_bounds == 'mask' :
535
- self ._handle_out_of_bounds = _mask_out_of_bounds
536
- elif self .out_of_bounds == 'clip' :
537
- self ._handle_out_of_bounds = _clip_out_of_bounds
538
- else :
539
- raise ValueError ("`out_of_bounds` must be either 'mask' or 'clip'" )
540
522
541
523
def transform_non_affine (self , values ):
542
524
with np .errstate (divide = "ignore" , invalid = "ignore" ):
543
- q = (values / self ._b ) ** (1 / self ._a )
525
+ q = (values / self ._b ) ** (1 / self ._a )
544
526
print (values , q )
545
527
return q
546
528
0 commit comments