MCPcopy Create free account
hub / github.com/numpy/numpy / _DomainSafeDivide

Class _DomainSafeDivide

numpy/ma/core.py:840–858  ·  view source on GitHub ↗

Define a domain for safe division.

Source from the content-addressed store, hash-verified

838
839
840class _DomainSafeDivide:
841 """
842 Define a domain for safe division.
843
844 """
845
846 def __init__(self, tolerance=None):
847 self.tolerance = tolerance
848
849 def __call__(self, a, b):
850 # Delay the selection of the tolerance to here in order to reduce numpy
851 # import times. The calculation of these parameters is a substantial
852 # component of numpy's import time.
853 if self.tolerance is None:
854 self.tolerance = np.finfo(float).tiny
855 # don't call ma ufuncs from __array_wrap__ which would fail for scalars
856 a, b = np.asarray(a), np.asarray(b)
857 with np.errstate(invalid='ignore'):
858 return umath.absolute(a) * self.tolerance >= umath.absolute(b)
859
860
861class _DomainGreater:

Callers 4

core.pyFile · 0.85
__idiv__Method · 0.85
__ifloordiv__Method · 0.85
__itruediv__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected