Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase error tolerance in get_beat_time() #134

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sardine/base/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,12 @@ def get_beat_time(

# Due to potential rounding errors, we might get a duration
# that should be, but isn't actually equal to the interval.
# As such, we will replace any durations below a picosecond.
if math.isclose(duration, 0.0, rel_tol=0.0, abs_tol=1e-12):
# To mitigate this, we will replace any durations below 10
# microseconds.
# Rounding errors will worsen over time, but it is unlikely
# we'll get to a point where 10 microseconds is too little
# (but possible if sardine goes on for 5-6 years).
if math.isclose(duration, 0.0, rel_tol=0.0, abs_tol=1e-8):
return interval

return duration
Expand Down