libb.thresh

thresh(x, thresh=0.0)[source]

Round to nearest integer if within threshold distance.

Parameters:
  • x (float) – Number to potentially round.

  • thresh (float) – Distance threshold for rounding.

Returns:

Rounded integer or original value.

Positive Numbers:

>>> thresh(74.9888, 0.05)
75
>>> thresh(75.01, 0.05)
75

Negative Numbers:

>>> thresh(-74.988, 0.05)
-75
>>> thresh(-75.01, 0.05)
-75

Return Original:

>>> thresh(74.90, 0.05)
74.9
>>> thresh(75.06, 0.05)
75.06