@@ -2866,31 +2866,33 @@ def _revalidate(self):
2866
2866
2867
2867
2868
2868
def nonsingular (vmin , vmax , expander = 0.001 , tiny = 1e-15 , increasing = True ):
2869
- '''
2869
+ """
2870
2870
Modify the endpoints of a range as needed to avoid singularities.
2871
2871
2872
- *vmin*, *vmax*
2873
- the initial endpoints.
2874
-
2875
- *tiny*
2876
- threshold for the ratio of the interval to the maximum absolute
2872
+ Parameters
2873
+ ----------
2874
+ vmin, vmax : float
2875
+ The initial endpoints.
2876
+ expander : float, optional, default: 0.001
2877
+ Fractional amount by which *vmin* and *vmax* are expanded if
2878
+ the original interval is too small, based on *tiny*.
2879
+ tiny : float, optional, default: 1e-15
2880
+ Threshold for the ratio of the interval to the maximum absolute
2877
2881
value of its endpoints. If the interval is smaller than
2878
2882
this, it will be expanded. This value should be around
2879
2883
1e-15 or larger; otherwise the interval will be approaching
2880
2884
the double precision resolution limit.
2885
+ increasing : bool, optional, default: True
2886
+ If True, swap *vmin*, *vmax* if *vmin* > *vmax*.
2887
+
2888
+ Returns
2889
+ -------
2890
+ vmin, vmax : float
2891
+ Endpoints, expanded and/or swapped if necessary.
2892
+ If either input is inf or NaN, or if both inputs are 0 or very
2893
+ close to zero, it returns -*expander*, *expander*.
2894
+ """
2881
2895
2882
- *expander*
2883
- fractional amount by which *vmin* and *vmax* are expanded if
2884
- the original interval is too small, based on *tiny*.
2885
-
2886
- *increasing*: [True | False]
2887
- If True (default), swap *vmin*, *vmax* if *vmin* > *vmax*
2888
-
2889
- Returns *vmin*, *vmax*, expanded and/or swapped if necessary.
2890
-
2891
- If either input is inf or NaN, or if both inputs are 0 or very
2892
- close to zero, it returns -*expander*, *expander*.
2893
- '''
2894
2896
if (not np .isfinite (vmin )) or (not np .isfinite (vmax )):
2895
2897
return - expander , expander
2896
2898
@@ -2918,25 +2920,65 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
2918
2920
2919
2921
2920
2922
def interval_contains (interval , val ):
2923
+ """
2924
+ Check, inclusively, whether an interval includes a given value.
2925
+
2926
+ Parameters
2927
+ ----------
2928
+ interval : sequence of scalar
2929
+ A 2-length sequence, endpoints that define the interval.
2930
+ val : scalar
2931
+ Value to check is within interval.
2932
+
2933
+ Returns
2934
+ -------
2935
+ bool
2936
+ Returns true if given val is within the interval.
2937
+ """
2921
2938
a , b = interval
2922
2939
return a <= val <= b or a >= val >= b
2923
2940
2924
2941
2925
2942
def interval_contains_open (interval , val ):
2943
+ """
2944
+ Check, excluding endpoints, whether an interval includes a given value.
2945
+
2946
+ Parameters
2947
+ ----------
2948
+ interval : sequence of scalar
2949
+ A 2-length sequence, endpoints that define the interval.
2950
+ val : scalar
2951
+ Value to check is within interval.
2952
+
2953
+ Returns
2954
+ -------
2955
+ bool
2956
+ Returns true if given val is within the interval.
2957
+ """
2926
2958
a , b = interval
2927
2959
return a < val < b or a > val > b
2928
2960
2929
2961
2930
2962
def offset_copy (trans , fig = None , x = 0.0 , y = 0.0 , units = 'inches' ):
2931
- '''
2963
+ """
2932
2964
Return a new transform with an added offset.
2933
- args:
2934
- trans is any transform
2935
- kwargs:
2936
- fig is the current figure; it can be None if units are 'dots'
2937
- x, y give the offset
2938
- units is 'inches', 'points' or 'dots'
2939
- '''
2965
+
2966
+ Parameters
2967
+ ----------
2968
+ trans : :class:`Transform` instance
2969
+ Any transform, to which offset will be applied.
2970
+ fig : :class:`~matplotlib.figure.Figure`, optional, default: None
2971
+ Current figure. It can be None if *units* are 'dots'.
2972
+ x, y : float, optional, default: 0.0
2973
+ Specifies the offset to apply.
2974
+ units : {'inches', 'points', 'dots'}, optional
2975
+ Units of the offset.
2976
+
2977
+ Returns
2978
+ -------
2979
+ trans : :class:`Transform` instance
2980
+ Transform with applied offset.
2981
+ """
2940
2982
if units == 'dots' :
2941
2983
return trans + Affine2D ().translate (x , y )
2942
2984
if fig is None :
0 commit comments