From 30bdc6c86e71800b264cef6cadae6f3c81ad448c Mon Sep 17 00:00:00 2001 From: Ryan James Date: Fri, 27 Nov 2026 22:22:20 -0700 Subject: [PATCH] Test the expired deadlines with a deadline strictly in the past Before Python 3.13, time.monotonic() on Windows ticks every 15.6 ms, so a deadline of time.monotonic() usually still equals the clock at the first check, and targeted_line_split_seeds ran its first start: the test failed on main on Windows with Python 3.11 and 3.12. --- tests/test_coupled_generators.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_coupled_generators.py b/tests/test_coupled_generators.py index e27fee4..d58d009 100644 --- a/tests/test_coupled_generators.py +++ b/tests/test_coupled_generators.py @@ -465,10 +465,12 @@ def test_coupled_memory_and_targeted_searches_stop_at_an_expired_deadline() -> N # separating_optima takes no deadline; keep it out of the timed region (slow CI runners) _best, optima = cg.separating_optima(problem, starts=10, rng=np.random.default_rng(0)) start = time.monotonic() - results = cg.coupled_search(bidir, 3, starts=50, deadline=time.monotonic(), rng=np.random.default_rng(0)) + # strictly in the past: before Python 3.13, time.monotonic() on Windows ticks every 15.6 ms + expired = start - 1.0 + results = cg.coupled_search(bidir, 3, starts=50, deadline=expired, rng=np.random.default_rng(0)) assert results and all(r.residual <= 1e-6 for r in results) - lifts = cg.memory_lift_search(bidir, 2, starts=50, deadline=time.monotonic(), rng=np.random.default_rng(0)) + lifts = cg.memory_lift_search(bidir, 2, starts=50, deadline=expired, rng=np.random.default_rng(0)) assert len(lifts) == 1 - seeds = cg.targeted_line_split_seeds(problem, optima, deadline=time.monotonic(), rng=np.random.default_rng(0)) + seeds = cg.targeted_line_split_seeds(problem, optima, deadline=expired, rng=np.random.default_rng(0)) assert seeds == [] assert time.monotonic() - start < 120