|View source on GitHub|
Approximately compares two objects.
cirq.protocols.approx_eq( val: Any, other: Any, *, atol: Union[int, float] = 1e-08 ) -> bool
val implements SupportsApproxEquality protocol then it is invoked and
takes precedence over all other checks:
- For primitive numeric types
floatapproximate equality is delegated to math.isclose().
- For complex primitive type the real and imaginary parts are treated independently and compared using math.isclose().
otherboth iterable of the same length, consecutive elements are compared recursively. Types of
otherdoes not necessarily needs to match each other. They just need to be iterable and have the same structure.
||Source object for approximate comparison.|
||Target object for approximate comparison.|
||The minimum absolute tolerance. See np.isclose() documentation for details. Defaults to 1e-8 which matches np.isclose() default absolute tolerance.|
|True if objects are approximately equal, False otherwise.|