Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
def transform_non_affine(self, prob):
with numpy.errstate(divide="ignore", invalid="ignore"):
prob = self._handle_out_of_bounds(
numpy.asarray(prob) / self.factor
)
q = self.dist.ppf(prob)
return q
def inverted(self):
return QuantileTransform(self.dist, as_pct=self.as_pct,
out_of_bounds=self.out_of_bounds)
class QuantileTransform(_ProbTransformMixin):
"""
MPL axes transform class to convert probabilities or percents to
quantiles.
Parameters
----------
dist : scipy.stats distribution
The distribution whose ``cdf`` and ``pdf`` methods will set the
scale of the axis.
as_pct : bool, optional (True)
Toggles the formatting of the probabilities associated with the
tick labels as percentages (0 - 100) or fractions (0 - 1).
out_of_bounds : string, optional ('mask' or 'clip')
Determines how data outside the range of valid values is
handled. The default behavior is to mask the data.
Alternatively, the data can be clipped to values arbitrarily
self.as_pct = as_pct
self.out_of_bounds = out_of_bounds
if self.as_pct:
self.factor = 100.0
else:
self.factor = 1.0
if self.out_of_bounds == 'mask':
self._handle_out_of_bounds = _mask_out_of_bounds
elif self.out_of_bounds == 'clip':
self._handle_out_of_bounds = _clip_out_of_bounds
else:
raise ValueError("`out_of_bounds` muse be either 'mask' or 'clip'")
class ProbTransform(_ProbTransformMixin):
"""
MPL axes transform class to convert quantiles to probabilities
or percents.
Parameters
----------
dist : scipy.stats distribution
The distribution whose ``cdf`` and ``pdf`` methods will set the
scale of the axis.
as_pct : bool, optional (True)
Toggles the formatting of the probabilities associated with the
tick labels as percentages (0 - 100) or fractions (0 - 1).
out_of_bounds : string, optional ('mask' or 'clip')
Determines how data outside the range of valid values is
handled. The default behavior is to mask the data.
Alternatively, the data can be clipped to values arbitrarily