@@ -2866,31 +2866,33 @@ def _revalidate(self):
28662866
28672867
28682868def nonsingular (vmin , vmax , expander = 0.001 , tiny = 1e-15 , increasing = True ):
2869- '''
2869+ """
28702870 Modify the endpoints of a range as needed to avoid singularities.
28712871
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
28772881 value of its endpoints. If the interval is smaller than
28782882 this, it will be expanded. This value should be around
28792883 1e-15 or larger; otherwise the interval will be approaching
28802884 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+ """
28812895
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- '''
28942896 if (not np .isfinite (vmin )) or (not np .isfinite (vmax )):
28952897 return - expander , expander
28962898
@@ -2918,25 +2920,65 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
29182920
29192921
29202922def 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+ """
29212938 a , b = interval
29222939 return a <= val <= b or a >= val >= b
29232940
29242941
29252942def 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+ """
29262958 a , b = interval
29272959 return a < val < b or a > val > b
29282960
29292961
29302962def offset_copy (trans , fig = None , x = 0.0 , y = 0.0 , units = 'inches' ):
2931- '''
2963+ """
29322964 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+ """
29402982 if units == 'dots' :
29412983 return trans + Affine2D ().translate (x , y )
29422984 if fig is None :
0 commit comments