Skip to content

Alias derivative_discontinuity field to u_modified for SciMLBase v3#101

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-derivative-discontinuity-field
Draft

Alias derivative_discontinuity field to u_modified for SciMLBase v3#101
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-derivative-discontinuity-field

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Problem

On the latest dependency resolution (SciMLBase v3, DiffEqBase that reads the new field name), Pkg.test() fails in the Callback Tests with:

type ODEInterfaceIntegrator has no field derivative_discontinuity
  [1] getproperty @ src/integrator_utils.jl:94
  [2] initialize! @ DiffEqBase/src/callbacks.jl:25
  ...
  [13] test/callbacks.jl:23  (ContinuousCallback solve with dopri5)

Root cause

SciMLBase v3 renamed the u_modified! API to derivative_discontinuity!, and DiffEqBase's callback machinery now reads and writes the integrator field derivative_discontinuity directly (callbacks.jl initialize!/finalize!/apply_discrete_callback!/apply_callback! all do integrator.derivative_discontinuity and integrator.derivative_discontinuity = ...).

ODEInterfaceIntegrator only has a u_modified field. The repo already added a derivative_discontinuity! method shim, but that does not help when the callback code touches the field. The getproperty override (which already aliases :dt) had no entry for :derivative_discontinuity, and there was no setproperty! override at all.

Fix

Alias derivative_discontinuity to the real u_modified field in both getproperty and a new setproperty!. The aliasing is version-agnostic: on SciMLBase v2 the field is accessed as u_modified directly (unaffected), and on v3 the derivative_discontinuity accesses now map to u_modified. The new setproperty! preserves the implicit convert(fieldtype(...), x) that Julia's default setproperty! performs, so the other (numeric) field assignments in handle_callbacks!/apply_callback! still convert correctly.

Only src/integrator_utils.jl is touched. No changes to Project.toml or CI config.

Testing

Full suite run locally at latest deps (SciMLBase v3.18.0), Julia 1.10:

Before:

Test Summary:  | Error  Total  Time
Callback Tests |     1      1  1.9s
ERROR: Package ODEInterfaceDiffEq errored during testing

After:

Test Summary:  | Pass  Total  Time
Callback Tests |    2      2  1.8s
...
     Testing ODEInterfaceDiffEq tests passed

Full suite run locally at latest deps: PASS.

Ignore until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code

SciMLBase v3 renamed the `u_modified!` API to `derivative_discontinuity!`
and its callback machinery now reads and writes the integrator field
`derivative_discontinuity` directly (DiffEqBase callbacks.jl initialize!/
finalize!/apply_callback!). `ODEInterfaceIntegrator` only has a `u_modified`
field, so callback initialization errored with `type ODEInterfaceIntegrator
has no field derivative_discontinuity`.

Alias `derivative_discontinuity` to the real `u_modified` field in both
`getproperty` and a new `setproperty!`. The aliasing is version-agnostic
(works on SciMLBase v2 where `u_modified` is accessed directly and v3 where
`derivative_discontinuity` is). `setproperty!` preserves the implicit
`convert` to the field type that Julia's default `setproperty!` performs,
so non-aliased numeric field assignments still convert correctly.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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