MCPcopy Index your code
hub / github.com/numpy/numpy / _DomainSafeDivide

Class _DomainSafeDivide

numpy/ma/core.py:891–909  ·  view source on GitHub ↗

Define a domain for safe division.

Source from the content-addressed store, hash-verified

889
890
891class _DomainSafeDivide:
892 """
893 Define a domain for safe division.
894
895 """
896
897 def __init__(self, tolerance=None):
898 self.tolerance = tolerance
899
900 def __call__(self, a, b):
901 # Delay the selection of the tolerance to here in order to reduce numpy
902 # import times. The calculation of these parameters is a substantial
903 # component of numpy's import time.
904 if self.tolerance is None:
905 self.tolerance = np.finfo(float).tiny
906 # don't call ma ufuncs from __array_wrap__ which would fail for scalars
907 a, b = np.asarray(a), np.asarray(b)
908 with np.errstate(all='ignore'):
909 return umath.absolute(a) * self.tolerance >= umath.absolute(b)
910
911
912class _DomainGreater:

Callers 3

core.pyFile · 0.85
__ifloordiv__Method · 0.85
__itruediv__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…