cirq.Tolerance¶
-
class
cirq.Tolerance(rtol: float = 1e-05, atol: float = 1e-08, equal_nan: bool = False)[source]¶ Specifies thresholds for doing approximate equality.
-
__init__(rtol: float = 1e-05, atol: float = 1e-08, equal_nan: bool = False) → None[source]¶ Initializes a Tolerance instance with the specified parameters.
Notes
Matrix Comparisons (methods beginning with “all_”) are done bynumpy.allclose, which considers x and yto be close when abs(x - y) <= atol + rtol * abs(y). Seenumpy.allclose’s documentation for more details. The scalarmethods perform the same calculations without the numpymatrix construction.Parameters: - rtol – Relative tolerance.
- atol – Absolute tolerance.
- equal_nan – Whether NaNs are equal to each other.
Methods
all_close(a, b)all_near_zero(a)all_near_zero_mod(a, period)close(a, b)near_zero(a)near_zero_mod(a, period)Attributes
DEFAULTZERO-