Archived
feat(latency): latency experiments, LATENCY.md, Kalshi's slow-connection recycle
Extension 4. `engineering-challenge latency EXCHANGE OUT.csv` opens 16 connections to the same busy markets and writes every copy of every change; `scripts/latency/analyse.py` gives each connection's speed, whether it persists, what keeping the fastest would gain, lateness by address, and lag with the clock's offset. LATENCY.md writes up four runs: on Polymarket speed persists but is worth under a millisecond, at the median only; on Kalshi's demo keeping the fastest pair lowers p99 by 28% and 42%, the threshold agreed before the runs. So the collector now recycles a Kalshi connection whose mean lateness stays, 3 minutes running, in the slowest quarter and above twice everyone's, ahead of its hourly turn. Kalshi's rule measures each duplicate's lateness; the orchestrator judges once a minute. A duplicate's lag in Polymarket's minute line is now its "lateness". Roadmap milestone 7, roadmap/07.
This commit is contained in:
22 files changed
+2132
-55
No files matched your search
@@ -8,3 +8,8 @@ cd "$(dirname "$0")/.."
|
||||
cargo fmt --check
|
||||
cargo clippy --all-targets -- -D warnings
|
||||
cargo test
|
||||
|
||||
# The latency analysis (scripts/latency/): ruff pinned, run through uvx.
|
||||
uvx ruff@0.15.0 format --check scripts/latency
|
||||
uvx ruff@0.15.0 check scripts/latency
|
||||
python3 -m unittest discover -s scripts/latency
|
||||
@@ -0,0 +1,258 @@
|
||||
"""The latency probe's CSV, analysed (roadmap/07): lateness, missed changes,
|
||||
each connection's speed per minute, whether speed persists, what racing
|
||||
would gain, lateness by address, and lag. Standard library only.
|
||||
|
||||
Usage: python3 scripts/latency/analyse.py RUN.csv
|
||||
|
||||
Terms (GLOSSARY.md): a copy's lateness is how long after the change's first
|
||||
copy it came; a connection's speed is its median lateness over a minute;
|
||||
lag is a receive time minus the exchange's timestamp.
|
||||
"""
|
||||
|
||||
import csv
|
||||
import itertools
|
||||
import statistics
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
MINUTE_US = 60_000_000
|
||||
# The fastest of the first minute, against the others (persistence).
|
||||
TOP = 4
|
||||
# Connections a symbol has in the collector: first one wins (ADR 0003).
|
||||
PAIR = 2
|
||||
|
||||
|
||||
class Run:
|
||||
"""A run's changes, each with every connection's first copy of it."""
|
||||
|
||||
def __init__(self, lines):
|
||||
self.connections = {} # connection -> address
|
||||
self.down = {} # connection -> when it went down, µs
|
||||
self.offsets = [] # the clock's offsets, µs
|
||||
# (symbol, identity) -> [exchange_ms, {connection: received_us}]
|
||||
self.changes = {}
|
||||
rows = []
|
||||
for line in lines:
|
||||
if line.startswith("#"):
|
||||
self._note(line[1:].strip())
|
||||
else:
|
||||
rows.append(line)
|
||||
for row in csv.DictReader(rows):
|
||||
connection = int(row["connection"])
|
||||
self.connections[connection] = row["address"]
|
||||
key = (row["symbol"], row["identity"])
|
||||
change = self.changes.setdefault(key, [int(row["exchange_ms"]), {}])
|
||||
# A server's repeat on one connection: its first copy counts.
|
||||
change[1].setdefault(connection, int(row["received_us"]))
|
||||
self.up_from = {} # connection -> its first copy, µs
|
||||
for _, copies in self.changes.values():
|
||||
for connection, received in copies.items():
|
||||
self.up_from[connection] = min(self.up_from.get(connection, received), received)
|
||||
|
||||
def _note(self, note):
|
||||
fields = note.split(",")
|
||||
if fields[0] == "down":
|
||||
self.down[int(fields[1])] = int(fields[2])
|
||||
elif fields[0] == "offset" and fields[2]:
|
||||
self.offsets.append(int(fields[2]))
|
||||
|
||||
def first(self, change):
|
||||
return min(change[1].values())
|
||||
|
||||
def minutes(self):
|
||||
"""Each full minute's changes, from the run's first change."""
|
||||
firsts = [(self.first(change), change) for change in self.changes.values()]
|
||||
if not firsts:
|
||||
return []
|
||||
start = min(first for first, _ in firsts)
|
||||
last = max(first for first, _ in firsts)
|
||||
count = (last - start) // MINUTE_US # the last, partial, left out
|
||||
minutes = [[] for _ in range(count)]
|
||||
for first, change in firsts:
|
||||
minute = (first - start) // MINUTE_US
|
||||
if minute < count:
|
||||
minutes[minute].append(change)
|
||||
return minutes
|
||||
|
||||
def up(self, connection, at):
|
||||
"""From its first copy (its subscribe done) until it went down."""
|
||||
never = float("inf")
|
||||
return self.up_from.get(connection, never) <= at < self.down.get(connection, never)
|
||||
|
||||
def lateness(self, changes, connections):
|
||||
"""The lateness of the first copy among `connections`, change by
|
||||
change, behind the first of all; and how many changes none of them
|
||||
delivered while up."""
|
||||
lateness, missed = [], 0
|
||||
for change in changes:
|
||||
first = self.first(change)
|
||||
copies = [change[1][c] for c in connections if c in change[1]]
|
||||
if copies:
|
||||
lateness.append(min(copies) - first)
|
||||
elif any(self.up(c, first) for c in connections):
|
||||
missed += 1
|
||||
return lateness, missed
|
||||
|
||||
|
||||
def quantile(values, q):
|
||||
"""As the collector's log computes it: the value at index n * q."""
|
||||
ordered = sorted(values)
|
||||
return ordered[min(int(len(ordered) * q), len(ordered) - 1)]
|
||||
|
||||
|
||||
def speeds(run, minute):
|
||||
"""Each connection's speed over a minute's changes, µs."""
|
||||
result = {}
|
||||
for connection in run.connections:
|
||||
lateness, _ = run.lateness(minute, [connection])
|
||||
if lateness:
|
||||
result[connection] = statistics.median(lateness)
|
||||
return result
|
||||
|
||||
|
||||
def ranked(speeds_by_connection):
|
||||
return sorted(speeds_by_connection, key=lambda c: (speeds_by_connection[c], c))
|
||||
|
||||
|
||||
def persistence(run, minutes):
|
||||
"""The rank correlation of the connections' speeds between each minute
|
||||
and the next."""
|
||||
per_minute = [speeds(run, minute) for minute in minutes]
|
||||
correlations = []
|
||||
for this, following in itertools.pairwise(per_minute):
|
||||
both = sorted(set(this) & set(following))
|
||||
if len(both) > 2:
|
||||
correlations.append(
|
||||
statistics.correlation(
|
||||
[this[c] for c in both],
|
||||
[following[c] for c in both],
|
||||
method="ranked",
|
||||
)
|
||||
)
|
||||
return correlations
|
||||
|
||||
|
||||
def summary(lateness):
|
||||
if not lateness:
|
||||
return None
|
||||
return statistics.median(lateness), quantile(lateness, 0.99)
|
||||
|
||||
|
||||
def top_against_rest(run, minutes, top=TOP):
|
||||
"""The `top` fastest of the first minute against the others, over the
|
||||
minutes after it: (median, p99) of their copies' lateness each."""
|
||||
order = ranked(speeds(run, minutes[0]))
|
||||
top, rest = order[:top], order[top:]
|
||||
later = [change for minute in minutes[1:] for change in minute]
|
||||
|
||||
def copies(connections):
|
||||
lateness = []
|
||||
for connection in connections:
|
||||
lateness += run.lateness(later, [connection])[0]
|
||||
return summary(lateness)
|
||||
|
||||
return copies(top), copies(rest)
|
||||
|
||||
|
||||
def racing(run, minutes, pair=PAIR):
|
||||
"""The `pair` fastest of the first minute kept, against a pair at
|
||||
random (every pair, averaged), over the minutes after it: the (median,
|
||||
p99) of the pair's lateness (first one wins: the sooner of its two
|
||||
copies), and its missed changes. None if too few connections deliver
|
||||
after the first minute to compare."""
|
||||
order = ranked(speeds(run, minutes[0]))
|
||||
later = [change for minute in minutes[1:] for change in minute]
|
||||
picked_lateness, picked_missed = run.lateness(later, order[:pair])
|
||||
pairs = [run.lateness(later, list(two)) for two in itertools.combinations(order, pair)]
|
||||
random = [s for s in (summary(lateness) for lateness, _ in pairs) if s]
|
||||
picked = summary(picked_lateness)
|
||||
if len(order) < pair or picked is None or not random:
|
||||
return None
|
||||
return (
|
||||
picked,
|
||||
picked_missed,
|
||||
(statistics.mean(m for m, _ in random), statistics.mean(p for _, p in random)),
|
||||
statistics.mean(missed for _, missed in pairs),
|
||||
)
|
||||
|
||||
|
||||
def by_address(run, changes):
|
||||
"""(median, p99) of lateness by address, every copy counted."""
|
||||
addresses = {}
|
||||
for connection, address in run.connections.items():
|
||||
addresses.setdefault(address, []).extend(run.lateness(changes, [connection])[0])
|
||||
return {address: summary(lateness) for address, lateness in sorted(addresses.items())}
|
||||
|
||||
|
||||
def lag(run, changes):
|
||||
"""(median, p99) of the first copies' lag, µs, raw and corrected by the
|
||||
clock's mean offset (positive: the local clock is behind)."""
|
||||
raw = [run.first(change) - change[0] * 1000 for change in changes]
|
||||
offset = statistics.mean(run.offsets) if run.offsets else 0
|
||||
return summary(raw), summary([value + offset for value in raw]), offset
|
||||
|
||||
|
||||
def ms(micros):
|
||||
return f"{micros / 1000:.2f}"
|
||||
|
||||
|
||||
def report(run):
|
||||
minutes = run.minutes()
|
||||
changes = [change for minute in minutes for change in minute]
|
||||
if not changes:
|
||||
return f"{len(run.connections)} connections, no change over a full minute"
|
||||
lines = [
|
||||
f"{len(run.connections)} connections, {len(changes)} changes "
|
||||
f"over {len(minutes)} full minutes",
|
||||
"",
|
||||
"| Connection | Address | Speed per minute (ms) | Missed |",
|
||||
"|---|---|---|---|",
|
||||
]
|
||||
per_minute = [speeds(run, minute) for minute in minutes]
|
||||
for connection, address in sorted(run.connections.items()):
|
||||
row = " ".join(ms(s[connection]) if connection in s else "-" for s in per_minute)
|
||||
_, missed = run.lateness(changes, [connection])
|
||||
lines.append(f"| {connection} | {address} | {row} | {missed} |")
|
||||
if len(minutes) >= 2:
|
||||
correlations = persistence(run, minutes)
|
||||
if correlations:
|
||||
each = " ".join(f"{c:.2f}" for c in correlations)
|
||||
mean = statistics.mean(correlations)
|
||||
lines += ["", f"Persistence: rank correlation minute to minute {each}, mean {mean:.2f}"]
|
||||
top, rest = top_against_rest(run, minutes)
|
||||
if top and rest:
|
||||
lines.append(
|
||||
f"The {TOP} fastest of minute 1 after it: {ms(top[0])} ms median, "
|
||||
f"{ms(top[1])} ms p99; the others: {ms(rest[0])} ms, {ms(rest[1])} ms"
|
||||
)
|
||||
else:
|
||||
lines.append(f"The {TOP} fastest of minute 1 against the others: too few connections")
|
||||
raced = racing(run, minutes)
|
||||
if raced:
|
||||
picked, picked_missed, random, random_missed = raced
|
||||
gain = (random[1] - picked[1]) / random[1] if random[1] else 0
|
||||
lines.append(
|
||||
f"Racing: the {PAIR} fastest of minute 1, {ms(picked[0])} ms median, "
|
||||
f"{ms(picked[1])} ms p99, {picked_missed} missed; a pair at random, "
|
||||
f"{ms(random[0])} ms, {ms(random[1])} ms, {random_missed:.1f} missed; "
|
||||
f"p99 {gain:.0%} lower"
|
||||
)
|
||||
else:
|
||||
lines.append("Racing: too few connections deliver after minute 1")
|
||||
lines += ["", "| Address | Median (ms) | p99 (ms) |", "|---|---|---|"]
|
||||
for address, lateness in by_address(run, changes).items():
|
||||
cells = f"{ms(lateness[0])} | {ms(lateness[1])}" if lateness else "- | -"
|
||||
lines.append(f"| {address} | {cells} |")
|
||||
raw, corrected, offset = lag(run, changes)
|
||||
lines += [
|
||||
"",
|
||||
f"Lag of the first copies: raw {ms(raw[0])} ms median, {ms(raw[1])} ms p99; "
|
||||
f"corrected by the clock's offset ({ms(offset)} ms): "
|
||||
f"{ms(corrected[0])} ms, {ms(corrected[1])} ms",
|
||||
]
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with Path(sys.argv[1]).open() as file:
|
||||
print(report(Run(file)))
|
||||
@@ -0,0 +1,15 @@
|
||||
# The analysis scripts' lint: every rule, less those that don't fit two
|
||||
# standalone scripts.
|
||||
line-length = 100
|
||||
|
||||
[lint]
|
||||
select = ["ALL"]
|
||||
ignore = [
|
||||
"D", # docstrings: written where they say something, not on every function
|
||||
"ANN", # type annotations: two scripts, no type checker run
|
||||
"T201", # print: the report is printed
|
||||
"PLR2004", # magic values: the tests compare hand-computed numbers
|
||||
"PT009", # unittest's assertEqual: the tests use unittest, no pytest
|
||||
"INP001", # no package: scripts run directly
|
||||
"COM812", # trailing commas: conflicts with the formatter
|
||||
]
|
||||
@@ -0,0 +1,203 @@
|
||||
"""analyse.py on runs small enough to work out by hand.
|
||||
|
||||
Run from `scripts/ci.sh`: `python3 -m unittest discover -s scripts/latency`.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import analyse
|
||||
|
||||
S = 1_000_000_000_000 # the run's first change, µs
|
||||
MIN = analyse.MINUTE_US
|
||||
ADDRESS = {0: "A", 1: "B", 2: "A"}
|
||||
|
||||
|
||||
def csv(copies, notes=()):
|
||||
"""`copies`: (connection, change, received_us, exchange_ms)."""
|
||||
lines = ["connection,address,symbol,identity,received_us,exchange_ms"]
|
||||
lines += [f"# {note}" for note in notes]
|
||||
for connection, change, received, exchange_ms in copies:
|
||||
lines.append(f"{connection},{ADDRESS[connection]},s,{change},{received},{exchange_ms}")
|
||||
return [line + "\n" for line in lines]
|
||||
|
||||
|
||||
# Minute 1: c1 and c2 (connection 2 misses c2); minute 2: c3 and c4; c5 only
|
||||
# ends minute 2, its own minute partial. Lateness in µs:
|
||||
# conn 0 conn 1 conn 2
|
||||
# c1 0 1000 3000
|
||||
# c2 0 2000 -
|
||||
# c3 1000 0 4000
|
||||
# c4 3000 0 5000
|
||||
RUN = csv(
|
||||
[
|
||||
(0, "c1", S, (S - 10_000) // 1000),
|
||||
(1, "c1", S + 1000, 0),
|
||||
(2, "c1", S + 3000, 0),
|
||||
# A server's repeat on connection 1: its first copy counts.
|
||||
(1, "c1", S + 50_000, 0),
|
||||
(0, "c2", S + 10_000_000, 0),
|
||||
(1, "c2", S + 10_002_000, 0),
|
||||
(1, "c3", S + MIN, 0),
|
||||
(0, "c3", S + MIN + 1000, 0),
|
||||
(2, "c3", S + MIN + 4000, 0),
|
||||
(1, "c4", S + MIN + 10_000_000, 0),
|
||||
(0, "c4", S + MIN + 10_003_000, 0),
|
||||
(2, "c4", S + MIN + 10_005_000, 0),
|
||||
(0, "c5", S + 2 * MIN + 5_000_000, 0),
|
||||
(1, "c5", S + 2 * MIN + 5_000_000, 0),
|
||||
(2, "c5", S + 2 * MIN + 5_000_000, 0),
|
||||
],
|
||||
notes=["offset,start,400,3000", "offset,end,600,3000"],
|
||||
)
|
||||
|
||||
|
||||
class Analyse(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.run = analyse.Run(RUN)
|
||||
self.minutes = self.run.minutes()
|
||||
|
||||
def test_full_minutes_only(self):
|
||||
self.assertEqual([len(minute) for minute in self.minutes], [2, 2])
|
||||
|
||||
def test_the_first_copy_is_not_late_and_a_repeat_is_ignored(self):
|
||||
lateness, _ = self.run.lateness(self.minutes[0], [0])
|
||||
self.assertEqual(lateness, [0, 0])
|
||||
lateness, _ = self.run.lateness(self.minutes[0], [1])
|
||||
self.assertEqual(lateness, [1000, 2000])
|
||||
|
||||
def test_a_change_a_connection_lacks_is_missed_by_it(self):
|
||||
changes = self.minutes[0] + self.minutes[1]
|
||||
self.assertEqual([self.run.lateness(changes, [c])[1] for c in (0, 1, 2)], [0, 0, 1])
|
||||
|
||||
def test_speeds_and_their_persistence(self):
|
||||
self.assertEqual(analyse.speeds(self.run, self.minutes[0]), {0: 0, 1: 1500, 2: 3000})
|
||||
self.assertEqual(analyse.speeds(self.run, self.minutes[1]), {0: 2000, 1: 0, 2: 4500})
|
||||
# Ranks (1, 2, 3) then (2, 1, 3).
|
||||
self.assertEqual(analyse.persistence(self.run, self.minutes), [0.5])
|
||||
|
||||
def test_the_fastest_of_minute_one_against_the_others(self):
|
||||
top, rest = analyse.top_against_rest(self.run, self.minutes, top=1)
|
||||
self.assertEqual(top, (2000, 3000))
|
||||
# [0, 0, 4000, 5000]: the median between, p99 the last.
|
||||
self.assertEqual(rest, (2000, 5000))
|
||||
|
||||
def test_racing(self):
|
||||
# Kept: connections 0 and 1, the sooner copy 0 for c3 and c4. At
|
||||
# random: (0, 1) [0, 0], (0, 2) [1000, 3000] (median 2000, p99 3000),
|
||||
# (1, 2) [0, 0].
|
||||
self.assertEqual(
|
||||
analyse.racing(self.run, self.minutes, pair=2), ((0, 0), 0, (2000 / 3, 1000), 0)
|
||||
)
|
||||
|
||||
def test_by_address(self):
|
||||
changes = self.minutes[0] + self.minutes[1]
|
||||
self.assertEqual(
|
||||
analyse.by_address(self.run, changes),
|
||||
# A: [0, 0, 1000, 3000] and [3000, 4000, 5000]; B: [1000, 2000, 0, 0].
|
||||
{"A": (3000, 5000), "B": (500, 2000)},
|
||||
)
|
||||
|
||||
def test_lag_raw_and_corrected_by_the_mean_offset(self):
|
||||
raw, corrected, offset = analyse.lag(self.run, self.minutes[0][:1])
|
||||
self.assertEqual((raw, corrected, offset), ((10_000, 10_000), (10_500, 10_500), 500))
|
||||
|
||||
def test_speed_is_the_median_and_racing_keeps_the_fastest(self):
|
||||
# Minute 1: lateness 0, 0, 0 on connection 0; 0, 0, 3000 on 1 (its
|
||||
# median 0, its mean 1000); 2000 each on 2. Order 0, 1, 2, so the
|
||||
# pair kept is (0, 1). Minute 2: connection 1 is now the slowest.
|
||||
copies = []
|
||||
for n, late in enumerate([0, 0, 3000]):
|
||||
at = S + n * 1_000_000
|
||||
copies += [(0, f"a{n}", at, 0), (1, f"a{n}", at + late, 0), (2, f"a{n}", at + 2000, 0)]
|
||||
copies += [
|
||||
(0, "b", S + MIN, 0),
|
||||
(1, "b", S + MIN + 9000, 0),
|
||||
(2, "b", S + MIN + 1000, 0),
|
||||
(0, "end", S + 2 * MIN + 1, 0),
|
||||
]
|
||||
run = analyse.Run(csv(copies))
|
||||
minutes = run.minutes()
|
||||
self.assertEqual(analyse.speeds(run, minutes[0]), {0: 0, 1: 0, 2: 2000})
|
||||
# Kept (0, 1): 0. At random: (0, 1) 0, (0, 2) 0, (1, 2) 1000.
|
||||
picked, _, random, _ = analyse.racing(run, minutes, pair=2)
|
||||
self.assertEqual((picked, random), ((0, 0), (1000 / 3, 1000 / 3)))
|
||||
|
||||
def test_p99_is_not_the_maximum(self):
|
||||
self.assertEqual(analyse.quantile(range(200), 0.99), 198)
|
||||
|
||||
def test_the_report_of_the_hand_worked_run(self):
|
||||
report = analyse.report(self.run)
|
||||
# Connection 2's speeds, and the change it missed.
|
||||
self.assertIn("| 2 | A | 3.00 4.50 | 1 |", report)
|
||||
self.assertIn("rank correlation minute to minute 0.50, mean 0.50", report)
|
||||
# Three connections: no 4 fastest against the others.
|
||||
self.assertIn("The 4 fastest of minute 1 against the others: too few connections", report)
|
||||
# Kept pair p99 0, pairs at random 1000 on average: 100% lower.
|
||||
self.assertIn("a pair at random, 0.67 ms, 1.00 ms, 0.0 missed; p99 100% lower", report)
|
||||
|
||||
def test_racing_counts_what_a_pair_missed(self):
|
||||
# Minute 1 ranks 0, 1, 2; after it, one change only connection 2
|
||||
# delivers: missed by the kept pair (0, 1), by one pair in three.
|
||||
run = analyse.Run(
|
||||
csv(
|
||||
[
|
||||
(0, "a", S, 0),
|
||||
(1, "a", S + 1000, 0),
|
||||
(2, "a", S + 2000, 0),
|
||||
(2, "b", S + MIN, 0),
|
||||
(0, "c", S + MIN + 1000, 0),
|
||||
(1, "c", S + MIN + 1000, 0),
|
||||
(2, "c", S + MIN + 1000, 0),
|
||||
(0, "end", S + 2 * MIN + 1, 0),
|
||||
]
|
||||
)
|
||||
)
|
||||
_, picked_missed, _, random_missed = analyse.racing(run, run.minutes(), pair=2)
|
||||
self.assertEqual((picked_missed, random_missed), (1, 1 / 3))
|
||||
|
||||
def test_an_offset_the_probe_could_not_measure_is_left_out(self):
|
||||
run = analyse.Run(csv([], notes=["offset,start,,", "offset,end,600,3000"]))
|
||||
self.assertEqual(run.offsets, [600])
|
||||
|
||||
def test_thin_runs_are_reported_without_a_traceback(self):
|
||||
# One connection over two minutes: nothing to compare.
|
||||
alone = [(0, "a", S, 0), (0, "b", S + MIN, 0), (0, "end", S + 2 * MIN + 1, 0)]
|
||||
report = analyse.report(analyse.Run(csv(alone)))
|
||||
self.assertIn("Racing: too few connections deliver after minute 1", report)
|
||||
# The kept pair, and every other, silent after minute 1 but one.
|
||||
silent = [
|
||||
(0, "a", S, 0),
|
||||
(1, "a", S + 1000, 0),
|
||||
(2, "a", S + 2000, 0),
|
||||
(2, "end", S + 2 * MIN + 1, 0),
|
||||
]
|
||||
analyse.report(analyse.Run(csv(silent)))
|
||||
|
||||
def test_a_run_with_no_change_is_reported_as_such(self):
|
||||
self.assertEqual(
|
||||
analyse.report(analyse.Run(csv([]))), "0 connections, no change over a full minute"
|
||||
)
|
||||
|
||||
def test_a_connection_is_missing_only_while_up(self):
|
||||
run = analyse.Run(
|
||||
csv(
|
||||
[
|
||||
# c1 before connection 2's first copy, c3 after it went
|
||||
# down: neither is missed by it.
|
||||
(0, "c1", S, 0),
|
||||
(2, "c2", S + 1000, 0),
|
||||
(0, "c2", S + 1000, 0),
|
||||
(0, "c3", S + 3000, 0),
|
||||
(0, "c4", S + MIN + 1, 0),
|
||||
],
|
||||
notes=[f"down,2,{S + 2000}"],
|
||||
)
|
||||
)
|
||||
self.assertEqual(run.lateness(run.minutes()[0], [2])[1], 0)
|
||||
# Without the note, c3 is missed.
|
||||
run.down.clear()
|
||||
self.assertEqual(run.lateness(run.minutes()[0], [2])[1], 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user