Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

This PR fixes issue #552 where using a Basis object obtained from DMD or SINDy as the ODE function in ODEProblem would throw an error about the 'observed' field not existing.

Changes

  • Added ModelingToolkit interface methods for Basis in new file src/basis/modelingtoolkit_interface.jl
  • Implemented required AbstractSystem interface methods:
    • equations
    • unknowns
    • parameters
    • get_observed
    • get_iv
    • nameof
  • Override getproperty to properly handle :observed field access
  • Override show method to fix display error related to namespacing flag
  • Added conditional definitions for namespacing-related methods to maintain compatibility across ModelingToolkit versions

Test plan

[x] Tested with the MRE from issue #552
[x] All existing package tests pass
[x] Both reported issues (ODEProblem creation and display) are fixed

Fixes #552

🤖 Generated with Claude Code

This commit fixes the issue where using a Basis object obtained from DMD
or SINDy as the ODE function in ODEProblem would throw an error about
the 'observed' field not existing.

Changes:
- Added ModelingToolkit interface methods directly to src/basis/type.jl
- Implemented required AbstractSystem interface methods: equations, unknowns,
  parameters, get_observed, get_iv, nameof
- Override getproperty to properly handle :observed field access (needed
  because ModelingToolkit's getproperty for AbstractSystem tries to use
  getvar which doesn't work for Basis)
- Override show method to fix display error related to namespacing flag

Fixes SciML#552

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas-Claude ChrisRackauckas-Claude force-pushed the fix-basis-odeproblem-issue-552 branch from 0b8f906 to a99979f Compare August 27, 2025 13:40
@ChrisRackauckas-Claude
Copy link
Author

Updated per feedback:

  • Moved interface methods directly to src/basis/type.jl instead of creating a separate file
  • Kept only the necessary overrides:
    • ModelingToolkit interface methods (equations, unknowns, parameters, get_observed, get_iv, nameof)
    • getproperty override for :observed field (required because ModelingToolkit's getproperty for AbstractSystem tries to use getvar which doesn't work for Basis)
    • show override to fix display issue

The getproperty override is necessary because SciMLBase tries to access sys.observed directly, which goes through ModelingToolkit's getproperty implementation that expects getvar to work.

@ChrisRackauckas ChrisRackauckas merged commit 8e5e547 into SciML:master Aug 27, 2025
15 of 19 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.

Using Basis in ODEProblem throws error

2 participants