Skip to content

Error in dt comparison due to float64 precision #99

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

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 8 additions & 4 deletions labscript/labscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,8 @@ def collect_change_times(self, all_outputs, outputs_by_clockline):
# Check that the pseudoclock can handle updates this fast
for i, t in enumerate(all_change_times[:-1]):
dt = all_change_times[i+1] - t
if dt < 1.0/self.clock_limit:
epsilon = (1.0/self.clock_limit)*1E-15
if dt < 1.0/self.clock_limit - epsilon:
raise LabscriptError(
"Commands have been issued to devices attached to "
f"{self.name} at t={t} and t={all_change_times[i+1]}. "
Expand Down Expand Up @@ -852,7 +853,8 @@ def collect_change_times(self, all_outputs, outputs_by_clockline):
# isn't too close to the time of the last instruction:
if not self.parent_device.stop_time in change_time_list:
dt = self.parent_device.stop_time - change_time_list[-1]
if abs(dt) < 1.0/clock_line.clock_limit:
epsilon = (1.0/clock_line.clock_limit)*1E-15
if abs(dt) < 1.0/clock_line.clock_limit - epsilon:
raise LabscriptError(
"The stop time of the experiment is "
f"t={self.parent_device.stop_time}, but the last "
Expand All @@ -879,7 +881,8 @@ def collect_change_times(self, all_outputs, outputs_by_clockline):
# Check that no two instructions are too close together:
for i, t in enumerate(change_time_list[:-1]):
dt = change_time_list[i+1] - t
if dt < 1.0/clock_line.clock_limit:
epsilon = (1.0/clock_line.clock_limit)*1E-15
if dt < 1.0/clock_line.clock_limit - epsilon:
raise LabscriptError(
"Commands have been issued to devices attached to "
f"clockline {clock_line.name} at t={t} and "
Expand All @@ -898,7 +901,8 @@ def collect_change_times(self, all_outputs, outputs_by_clockline):
# would force this clock tick to be faster than the minimum
# clock high time)
dt = all_change_times[j+1] - t
if dt < (2 * clock_line.minimum_clock_high_time):
epsilon = (2 * clock_line.minimum_clock_high_time)*1E-15
if dt < (2 * clock_line.minimum_clock_high_time) - epsilon:
raise LabscriptError(
"Commands have been issued to devices attached to "
f"{self.name} at t={t} and t={all_change_times[j+1]}. "
Expand Down