Skip to content

Add expression variable collector#4714

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:add-expression-var-collector
Draft

Add expression variable collector#4714
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:add-expression-var-collector

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

Please ignore until reviewed by @ChrisRackauckas.

Summary

  • add ModelingToolkitBase.collect_expression_vars! as a public helper for collecting variables from arbitrary symbolic expressions
  • delegate classification to MTKBase's existing collect_var! logic so downstream packages do not need to duplicate parameter/unknown handling
  • document the helper and cover parameter, unknown, independent-variable, and default-expression collection behavior

Motivation

Catalyst needs to collect variables from expression leaves while preserving MTKBase's parameter/unknown classification behavior. Exposing this helper keeps that classification logic in MTKBase instead of copying it downstream.

Validation

  • julia +1.10 --project=lib/ModelingToolkitBase -e 'cd("lib/ModelingToolkitBase/test"); include("variable_utils.jl")' passed\n- julia +1.10 --project=lib/ModelingToolkitBase -e 'using ModelingToolkitBase; @assert isdefined(ModelingToolkitBase, :collect_expression_vars!); println(ModelingToolkitBase.collect_expression_vars!)' passed\n- Runic check passed on edited Julia files\n- git diff --check passed\n- GROUP=ModelingToolkitBase_InterfaceII julia +1.10 --project=lib/ModelingToolkitBase -e 'using Pkg; Pkg.test()' did not pass: InterfaceII reported 7153 passed, 2 errored, 4 broken, with both errors in Optimal Control + Constraints Tests BVP cases (Lotka-Volterra and Cost function compilation). The targeted Variable Utils Test section in that run passed with 139 tests.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor Author

CI triage note from local follow-up:

  • Runic / Runic Format Check fails on untouched files (lib/ModelingToolkitBase/src/systems/codegen.jl, index_cache.jl, src/initialization.jl, test/initialization_jacobian_analysis.jl). The edited Julia files passed Runic locally.
  • Spell Check with Typos reports existing Lamba/lambda annotations in untouched files.
  • docs build fails during dependency resolution before docs build (Optim/OptimizationOptimJL conflict).
  • Downgrade / Downgrade Tests - InterfaceI fails during dependency resolution on OrdinaryDiffEqCore.
  • The Catalyst checks relevant to the original LTS modeling issue were still pending at this point.

Local targeted validation remains:

  • julia +1.10 --project=lib/ModelingToolkitBase -e 'cd("lib/ModelingToolkitBase/test"); include("variable_utils.jl")' passed.\n- ModelingToolkitBase.collect_expression_vars! is defined and reachable in the MTKBase environment.

@AayushSabharwal

Copy link
Copy Markdown
Member

Why is this necessary when collect_vars! exists?

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.

3 participants