Skip to content

Import SciMLBase in the OptimizationSystem test file - #5128

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/optimizationsystem-test-scimlbase-import
Sep 13, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/optimizationsystem-test-scimlbase-import

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Note: this PR should be ignored until reviewed by @ChrisRackauckas.

Follow-up to #5115. The ProblemTypeCtx testset there calls SciMLBase.problem_type, but the OptimizationSystem test file never imported SciMLBase. Under @safetestset the testset runs in a fresh module, so both assertions error. The fix adds SciMLBase to the file's using line, matching the other ModelingToolkitBase test files that use it directly.

Verification

Run in a scratch environment with SciMLBase dev'd at the problem_type branch (SciML/SciMLBase.jl#1600, unreleased, which is why the package's own test target cannot resolve yet), by including the whole test file with only Test loaded, as @safetestset does.

Before (file as on master):

`ProblemTypeCtx` is forwarded to `OptimizationProblem`: Error During Test at /home/crackauc/sandbox/tmp_20260912_031948_64225/ModelingToolkit.jl/lib/ModelingToolkitBase/test/optimization/optimizationsystem.jl:622
  Test threw exception
  Expression: SciMLBase.problem_type(prob) == "A"
  UndefVarError: `SciMLBase` not defined in `Main`
Test Summary:                                          | Error  Total  Time
`ProblemTypeCtx` is forwarded to `OptimizationProblem` |     2      2  2.5s

After (this PR): every testset in the file passes, including the two added on master today:

Test Summary:            | Pass  Total  Time
constraints_to_penalties |   20     20  5.8s
Test Summary:                                          | Pass  Total  Time
`ProblemTypeCtx` is forwarded to `OptimizationProblem` |    2      2  0.6s

Runic and typos pass on the file. Not verified: the full MTKBase CI groups, which cannot resolve until SciMLBase 3.54 is released.

🤖 Generated with Claude Code (model: claude-fable-5-1)

https://claude.ai/code/session_01WYPUXLxE9jVu2jXLFRd8ax

The `ProblemTypeCtx` testset added in SciML#5115 calls `SciMLBase.problem_type`,
but the file never imported `SciMLBase`, so under `@safetestset` the two
assertions error with `UndefVarError: SciMLBase not defined in Main`.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Agent-Harness: Claude Code 2.1.269
Agent-Model: claude-fable-5-1
Agent-Session: https://claude.ai/code/session_01WYPUXLxE9jVu2jXLFRd8ax
Claude-Session: https://claude.ai/code/session_01WYPUXLxE9jVu2jXLFRd8ax
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 13, 2026 07:59
@ChrisRackauckas
ChrisRackauckas merged commit 0bba967 into SciML:master Sep 13, 2026
104 of 109 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