Skip to content

Migrate community callback test off removed VectorContinuousCallback 4-arg form - #3943

Merged
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix-vectorcontinuouscallback-v3-api
Aug 3, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix-vectorcontinuouscallback-v3-api

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Note

This PR should be ignored until reviewed by @ChrisRackauckas.

Problem

lib/DiffEqBase's [Downstream2] test group fails on master in test/downstream/community_callback_tests.jl:

MethodError: no method matching VectorContinuousCallback(::typeof(cond!), ::typeof(terminate_affect!), ::Nothing, ::Int64)

Root cause

The test still used the SciMLBase v2 4-positional-arg form VectorContinuousCallback(condition, affect!, affect_neg!, len). SciMLBase intentionally removed that form (and the affect_neg! keyword) in v3.10.0 — commit SciML/SciMLBase.jl@ba118ad ("Remove affect_neg! from VectorContinuousCallback constructor") — because VectorContinuousCallback never honored affect_neg!: its apply_callback! dispatch always invokes affect!(integrator, event_idx) and ignored the field, so accepting it was a silent footgun (see #3613). The current SciMLBase docstring states "VectorContinuousCallback intentionally does not have an affect_neg! callback."

The downstream env only recently started resolving a SciMLBase new enough to drop the method (3.36.0 today), which is why this surfaced now (registry drift, first seen on #3692's CI, reproduces on unmodified master).

Fix

Update the test to the supported 3-arg form VectorContinuousCallback(cond!, terminate_affect!, 1), and update the expected termination time from 3pi/2 to pi/2:

  • Under the removed v2 API, affect_neg! = nothing made event detection skip downcrossings, so the condition u[3] = cos(t) first triggered at the upcrossing 3pi/2.
  • Under the current intentional semantics, affect! fires on every crossing (the struct's affect_neg! field is always affect! and DiffEqBase v7's apply_callback! for VectorContinuousCallback never calls affect_neg!), so the solve terminates at the first zero of cos(t), i.e. pi/2. Observed locally: soln.t[end] = 1.5707927986 with the same atol = 1e-4 as before.

The point of this #1528 regression test — callback handling must not error when one condition element is constantly zero — is preserved; only the API form and the crossing-direction expectation change, matching the documented upstream behavior.

Verified locally: lib/DiffEqBase/test/downstream/community_callback_tests.jl passes with SciMLBase 3.36.0 (output in the PR conversation).

This resolves the red lib/DiffEqBase [Downstream2] lane seen on #3692 (which merely surfaced the pre-existing master failure).

🤖 Generated with Claude Code

…4-arg form

SciMLBase v3.10.0 (SciML/SciMLBase.jl@ba118add) intentionally removed
the 4-positional-arg VectorContinuousCallback(condition, affect!,
affect_neg!, len) constructor: affect_neg! was a silent footgun since
DiffEqBase v7's apply_callback! for VectorContinuousCallback never calls
it (SciML#3613). The Downstream2 community_callback_tests.jl still used the
removed form, so the group fails with a MethodError once the downstream
env resolves SciMLBase >= 3.10 (3.36.0 today).

Use the supported 3-arg form and update the expected termination time
from 3pi/2 to pi/2: affect! now fires on every crossing of
u[3] = cos(t), while the old affect_neg! = nothing suppressed the
downcrossing at pi/2 during event detection. The point of this SciML#1528
regression test -- callback handling must not error when a condition
element is constantly zero -- is preserved.

Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Local verification (Julia 1.12, SciMLBase 3.36.0, monorepo libs dev'd at this branch):

Before: MethodError: no method matching VectorContinuousCallback(::typeof(cond!), ::typeof(terminate_affect!), ::Nothing, ::Int64), and with only the signature migrated the old expectation fails as

Expression: ≈(soln.t[end], 4.712347213360699, atol = 0.0001)
 Evaluated: 1.5707927986456003 ≈ 4.712347213360699 (atol=0.0001)

confirming affect! now fires at the first (down)crossing pi/2 under the intentional SciMLBase v3.10 semantics.

After this PR, the full previously-failing file passes:

Test Summary:            | Pass  Total     Time
Community Callback Tests |   16     16  7m03.3s

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review August 3, 2026 10:11
@ChrisRackauckas
ChrisRackauckas merged commit a351aa2 into SciML:master Aug 3, 2026
16 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants