round_or_fail#

tqec.utils.round_or_fail(f, atol=1e-08)[source]#

Try to round the provided f to the nearest integer and raise if f was not close enough to this integer.

Parameters:
  • f (float) – a floating-point value that should be close (absolute tolerance of atol) to its nearest integer number.

  • atol (float) – absolute tolerance between the provided f and round(f) that is acceptable.

Raises:

TQECException – if abs(f - round(f)) > atol

Returns:

int(round(f))

Return type:

int