Skip to content

Commit 47e9944

Browse files
committed
fixup! Add a utility to compare TickInfo objects approximately
1 parent 0ea8294 commit 47e9944

File tree

1 file changed

+7
-3
lines changed
  • tests/timeseries/_resampling/wall_clock_timer

1 file changed

+7
-3
lines changed

tests/timeseries/_resampling/wall_clock_timer/util.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,23 @@ def __eq__(self, actual: object) -> bool:
131131
return abs(diff) <= self.abs
132132

133133

134+
# We need to rewrite most of the attributes in these classes to use approximate
135+
# comparisons. This means if a new field is added, we need to update the
136+
# approx_tick_info function below to handle the new fields. To catch this, we do
137+
# a sanity check here, so if new fields are added we get an early warning instead of
138+
# getting tests errors because of some rounding error in a newly added field.
134139
assert set(ClocksInfo.__dataclass_fields__.keys()) == {
135140
"monotonic_requested_sleep",
136141
"monotonic_time",
137142
"wall_clock_time",
138143
"monotonic_elapsed",
139144
"wall_clock_elapsed",
140145
"wall_clock_factor",
141-
}, "ClocksInfo fields have changed, please update the approx_tick_info function."
142-
146+
}, "ClocksInfo fields were added or removed, please update the approx_tick_info function."
143147
assert set(TickInfo.__dataclass_fields__.keys()) == {
144148
"expected_tick_time",
145149
"sleep_infos",
146-
}
150+
}, "TickInfo fields were added or removed, please update the approx_tick_info function."
147151

148152

149153
def approx_tick_info(

0 commit comments

Comments
 (0)