Skip to content

Generator: computeVariables() recomputes what computeRates() has just computed - #1482

Open
agarny wants to merge 8 commits into
cellml:mainfrom
agarny:issue1481
Open

agarny wants to merge 8 commits into
cellml:mainfrom
agarny:issue1481

Conversation

@agarny

@agarny agarny commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1481.

Note: this relies on PR #1473.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 01:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The public call-order documentation omits the requirement to reuse the output buffers and unchanged inputs populated by computeRates().

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR prevents generated computeVariables() methods from repeating work already performed by computeRates(), while improving rate-dependency analysis and regression coverage.

Changes:

  • Tracks equations that compute referenced state rates.
  • Reuses computeRates() results in computeVariables().
  • Adds and updates C/Python generator fixtures for ODE, DAE, NLA, external-variable, and untracked-variable cases.
File Description
tests/​resources/​generator/​robertson_model_1966/​model.dae.py Removes repeated Python root solving.
tests/​resources/​generator/​robertson_model_1966/​model.dae.c Removes repeated C root solving.
tests/​resources/​generator/​ode_untracked_dependency_used_by_algebraic_eqn/​model.py Adds Python untracked-dependency fixture.
tests/​resources/​generator/​ode_untracked_dependency_used_by_algebraic_eqn/​model.h Adds generated C interface.
tests/​resources/​generator/​ode_untracked_dependency_used_by_algebraic_eqn/​model.cellml Adds regression model.
tests/​resources/​generator/​ode_untracked_dependency_used_by_algebraic_eqn/​model.c Adds generated C implementation.
tests/​resources/​generator/​ode_state_var_on_rhs/​model.py Adds Python state/rate fixture.
tests/​resources/​generator/​ode_state_var_on_rhs/​model.h Adds generated C interface.
tests/​resources/​generator/​ode_state_var_on_rhs/​model.cellml Adds state/rate regression model.
tests/​resources/​generator/​ode_state_var_on_rhs/​model.c Adds generated C implementation.
tests/​resources/​generator/​ode_state_var_on_lhs/​model.py Adds Python NLA-rate fixture.
tests/​resources/​generator/​ode_state_var_on_lhs/​model.h Adds generated C interface.
tests/​resources/​generator/​ode_state_var_on_lhs/​model.cellml Adds NLA-rate regression model.
tests/​resources/​generator/​ode_state_var_on_lhs/​model.c Adds generated C implementation.
tests/​resources/​generator/​ode_derivative_on_rhs/​model.py Adds Python derivative dependency fixture.
tests/​resources/​generator/​ode_derivative_on_rhs/​model.h Adds generated C interface.
tests/​resources/​generator/​ode_derivative_on_rhs/​model.cellml Adds derivative dependency model.
tests/​resources/​generator/​ode_derivative_on_rhs/​model.c Adds generated C implementation.
tests/​resources/​generator/​noble_model_1962/​model.py Removes duplicate Python calculations.
tests/​resources/​generator/​noble_model_1962/​model.c Removes duplicate C calculations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.variables.with.externals.py Updates Python external-variable output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.variables.with.externals.c Updates C external-variable output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.constants.with.externals.py Removes repeated Python rate dependencies.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.constants.with.externals.c Removes repeated C rate dependencies.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.constants.py Updates Python untracked-constant output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.constants.c Updates C untracked-constant output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.computed.constants.with.externals.py Updates Python computed-constant output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.computed.constants.with.externals.c Updates C computed-constant output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.computed.constants.py Removes duplicate Python computations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.computed.constants.c Removes duplicate C computations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.algebraic.variables.with.externals.py Updates Python algebraic tracking output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.untracked.algebraic.variables.with.externals.c Updates C algebraic tracking output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.state.py Retains only remaining Python calculations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.state.c Retains only remaining C calculations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.py Removes repeated Python HH computations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.external.py Reuses external values from rate computation.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.external.c Reuses external values in C output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dependent.state.py Reuses state-dependent external value.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dependent.state.c Updates corresponding C output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dependent.constant.py Removes repeated dependent calculations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dependent.constant.c Updates corresponding C output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dependent.computed.constant.py Removes repeated Python dependencies.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dependent.computed.constant.c Removes repeated C dependencies.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dependent.algebraic.py Updates dependent algebraic output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dependent.algebraic.c Updates corresponding C output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.py Moves required NLA solves into rates.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.variables.with.externals.py Splits Python NLA work by method.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.variables.with.externals.c Splits C NLA work by method.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.variables.py Moves rate dependencies into rates.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.variables.c Updates corresponding C output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.constants.with.externals.py Updates Python tracked DAE output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.constants.with.externals.c Updates C tracked DAE output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.constants.py Moves Python dependencies into rates.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.constants.c Moves C dependencies into rates.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.computed.constants.with.externals.py Updates Python computed-constant DAE output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.computed.constants.with.externals.c Updates C computed-constant DAE output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.computed.constants.py Removes duplicate Python NLA work.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.computed.constants.c Removes duplicate C NLA work.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.algebraic.variables.with.externals.py Updates Python algebraic DAE output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.algebraic.variables.with.externals.c Updates C algebraic DAE output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.algebraic.variables.py Moves Python rate-path NLA solves.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.untracked.algebraic.variables.c Moves C rate-path NLA solves.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.control.with.externals.py Updates Python tracking-control output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.control.with.externals.c Updates C tracking-control output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.control.py Removes duplicate Python control work.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.for.tracking.control.c Removes duplicate C control work.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.external.py Reuses rate-computed external values.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.external.c Updates corresponding C output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.dae.c Moves required C NLA solves into rates.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.constant.py Removes duplicate Python calculations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.constant.c Removes duplicate C calculations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.computed.constant.py Updates Python computed-constant output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.computed.constant.c Updates C computed-constant output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.c Removes repeated C HH computations.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.algebraic.py Updates Python algebraic-variable output.
tests/​resources/​generator/​hodgkin_huxley_squid_axon_model_1952/​model.algebraic.c Updates C algebraic-variable output.
tests/​resources/​generator/​dae_cellml_1_1_model/​model.py Removes duplicate Python DAE work.
tests/​resources/​generator/​dae_cellml_1_1_model/​model.c Removes duplicate C DAE work.
tests/​resources/​generator/​cellml_equivalent_variables_with_different_names/​model.py Adds equivalent-variable Python fixture.
tests/​resources/​generator/​cellml_equivalent_variables_with_different_names/​model.h Adds generated C interface.
tests/​resources/​generator/​cellml_equivalent_variables_with_different_names/​model.cellml Adds equivalent-variable model.
tests/​resources/​generator/​cellml_equivalent_variables_in_the_same_component/​model.py Adds same-component equivalence fixture.
tests/​resources/​generator/​cellml_equivalent_variables_in_the_same_component/​model.h Adds generated C interface.
tests/​resources/​generator/​cellml_equivalent_variables_in_the_same_component/​model.cellml Adds equivalence regression model.
tests/​resources/​generator/​cellml_equivalent_variables_in_the_same_component/​model.c Adds generated C implementation.
tests/​resources/​generator/​algebraic_system_with_untracked_dependencies/​model.untracked.py Adds untracked Python expected output.
tests/​resources/​generator/​algebraic_system_with_untracked_dependencies/​model.untracked.h Adds untracked C interface.
tests/​resources/​generator/​algebraic_system_with_untracked_dependencies/​model.h Updates generated base interface.
tests/​resources/​generator/​algebraic_system_with_derivative_on_rhs/​model.py Adds derivative-dependent NLA fixture.
tests/​resources/​generator/​algebraic_system_with_derivative_on_rhs/​model.h Adds generated C interface.
tests/​resources/​generator/​algebraic_system_with_derivative_on_rhs/​model.cellml Adds derivative-dependent NLA model.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_untracked_dependencies/​model.untracked.k.p.u.py Adds fully untracked Python fixture.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_untracked_dependencies/​model.untracked.k.p.u.h Adds corresponding C interface.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_untracked_dependencies/​model.untracked.k.p.py Adds partially untracked Python fixture.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_untracked_dependencies/​model.untracked.k.p.h Adds corresponding C interface.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_untracked_dependencies/​model.cellml Adds untracked NLA dependency model.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_derivative_dependency/​model.untracked.py Adds untracked derivative NLA fixture.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_derivative_dependency/​model.untracked.h Adds corresponding C interface.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_derivative_dependency/​model.py Adds tracked derivative NLA fixture.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_derivative_dependency/​model.h Adds generated C interface.
tests/​resources/​generator/​algebraic_eqn_with_one_non_isolated_unknown_and_derivative_dependency/​model.cellml Adds derivative NLA model.
tests/​resources/​generator/​algebraic_eqn_state_var_on_rhs_initialised_in_another_component/​model.py Adds cross-component state fixture.
tests/​resources/​generator/​algebraic_eqn_state_var_on_rhs_initialised_in_another_component/​model.h Adds generated C interface.
tests/​resources/​generator/​algebraic_eqn_state_var_on_rhs_initialised_in_another_component/​model.external.py Adds external-variable Python fixture.
tests/​resources/​generator/​algebraic_eqn_state_var_on_rhs_initialised_in_another_component/​model.external.h Adds external-variable C interface.
tests/​resources/​generator/​algebraic_eqn_state_var_on_rhs_initialised_in_another_component/​model.external.c Adds external-variable C implementation.
tests/​resources/​generator/​algebraic_eqn_state_var_on_rhs_initialised_in_another_component/​model.cellml Adds cross-component regression model.
tests/​resources/​generator/​algebraic_eqn_state_var_on_rhs_initialised_in_another_component/​model.c Adds generated C implementation.
tests/​resources/​generator/​algebraic_eqn_derivative_only_on_rhs_used_by_ode/​model.py Adds derivative-only Python fixture.
tests/​resources/​generator/​algebraic_eqn_derivative_only_on_rhs_used_by_ode/​model.h Adds generated C interface.
tests/​resources/​generator/​algebraic_eqn_derivative_only_on_rhs_used_by_ode/​model.cellml Adds derivative-only model.
tests/​resources/​generator/​algebraic_eqn_derivative_only_on_rhs_used_by_ode/​model.c Adds generated C implementation.
tests/​resources/​generator/​algebraic_eqn_derivative_on_rhs_used_by_ode/​model.py Adds chained derivative Python fixture.
tests/​resources/​generator/​algebraic_eqn_derivative_on_rhs_used_by_ode/​model.h Adds generated C interface.
tests/​resources/​generator/​algebraic_eqn_derivative_on_rhs_used_by_ode/​model.cellml Adds chained derivative model.
tests/​resources/​generator/​algebraic_eqn_derivative_on_rhs_used_by_ode/​model.c Adds generated C implementation.
tests/​coverage/​coverage.cpp Updates dependency API coverage.
tests/​bindings/​python/​test_analyser.py Updates Python dependency expectation.
src/​generator_p.h Adds rate-generation target and NLA dependency helper.
src/​api/​libcellml/​generator.h Documents the new call-order contract.
src/​api/​libcellml/​analyserequation.h Clarifies rate dependency semantics.
src/​analyser_p.h Separates variable and rate dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/api/libcellml/generator.h Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It is stacked on the still-open PR #1473 and changes analyser dependency semantics across 139 files.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (1)

Comment thread src/api/libcellml/generator.h Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It combines a broad analyser dependency rewrite with generator behavior changes across 139 files and still relies on the separate PR #1473.

Review effort: Balanced
Findings: None

Resolved since last review (1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator: computeVariables() recomputes what computeRates() has just computed

3 participants