deltakit.circuit.Circuit.approx_equals#

Circuit.approx_equals(other: object, *, rel_tol: float = 1e-09, abs_tol: float = 0) bool#

Determine whether two circuits are approximately equal within a tolerance. The tolerance accounts for small differences in the error probabilities of measurement gates and noise channels. All other gates, noise channels, annotations and properties must be equal.

Parameters:
  • other (object) – The other object to which to compare this gate layer.

  • rel_tol (float) – The allowed relative difference between the error probabilities of two measurement gates or noise channels, if this is larger than that calculated from abs_tol. Has the same meaning as in math.isclose. By default, 1e-9.

  • abs_tol (float, optional) – The allowed absolute difference between the error probabilities of two measurement gates or noise channels, if this is larger than that calculated from rel_tol. Has the same meaning as in math.isclose. By default, 0.0.

Returns:

Whether the two circuits are approximately equal.

Return type:

bool