Skip to content

Better interface for reparametrize_global - #583

Open
sumiya11 wants to merge 11 commits into
masterfrom
param-interface
Open

sumiya11 wants to merge 11 commits into
masterfrom
param-interface

Conversation

@sumiya11

@sumiya11 sumiya11 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Including

  • Remove internal variable names from logging
  • Always print reparametrization on the screen, in addition to returning it
  • Better (?) naming for new variables (x becomes x, a*x becomes \tilde{x}, f(x1,..,xn) becomes X)
image

sumiya11 and others added 7 commits November 4, 2026 22:00
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@sumiya11

sumiya11 commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Covid1 :

image

@sumiya11

sumiya11 commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Transfection (naming is hard!!):

image

@sumiya11

sumiya11 commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Goodwin, perhaps not ideal; maybe use Zi instead of Xi for new generic names?

image

Comment thread src/parametrizations.jl
function suggest_names(ode, new_states, new_params)
unorm(s) = Unicode.normalize(s; chartransform = Unicode.julia_chartransform)
original_names = unorm.(string.(gens(parent(ode))))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Runic] reported by reviewdog 🐶

Suggested change

Comment thread src/parametrizations.jl
for (i, def) in enumerate(new_states)
num, den = unpack_fraction(def)
name = nothing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Runic] reported by reviewdog 🐶

Suggested change

Comment thread src/parametrizations.jl
push!(used, unorm(names[i]))
end

names

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Runic] reported by reviewdog 🐶

Suggested change
names
return names

Comment thread src/parametrizations.jl
println(out, "• These variables are not independent:\n $(join(map(string, participants), ", "))", "\n")
end

println(out, "• For more info, run\n\njulia> @doc reparametrize_global\n")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Runic] reported by reviewdog 🐶

Suggested change
println(out, "• For more info, run\n\njulia> @doc reparametrize_global\n")
return println(out, "• For more info, run\n\njulia> @doc reparametrize_global\n")

Comment thread test/bodies/ode.jl
)
@test suggest_names(ode, ode.x_vars, ode.parameters) ==
string.(vcat(ode.x_vars, ode.parameters, ode.u_vars, ode.y_vars))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Runic] reported by reviewdog 🐶

Suggested change

Comment thread src/parametrizations.jl
new_ode = ODE{P}(new_x_vars, new_y_vars, new_vector_field, new_outputs, new_inputs)
reparam = (new_ode = new_ode, new_vars = new_vars, implicit_relations = implicit_relations)
@info (show_reparametrization(stdout, reparam); "Done!")
reparam

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Runic] reported by reviewdog 🐶

Suggested change
reparam
return reparam

@pogudingleb

Copy link
Copy Markdown
Collaborator

Thanks for new examples! I just have a couple of observations:

  • Yes, maybe X_i should be Z_i !

  • For Goodwin, I would suggest to look at different comparators, they may give more "nameable" variables. With lie or pushka one gets:

ode = @ODEmodel(
  x1'(t) = (-x1(t)*x4(t)*b - x1(t)*c*b + 1)//(x4(t) + c),
  X2'(t) = x1(t) - x̃3(t)*a5,
  x̃3'(t) = X2(t) - x̃3(t)*a4,
  x4'(t) = (X2(t)*x4(t)*sigma - x̃3(t)*x4(t)*sigma*a4)//x̃3(t),
  y(t) = x1(t)
)

• Variable definitions (4 new):

  x1(t) := x1(t)
  X2(t) := (x2(t)*gama + x3(t)*beta)//(alpha*gama)  (new)
  x̃3(t) := x3(t)//(alpha*gama)  (new)
  x4(t) := x4(t)
  sigma := sigma
  c := c
  b := b
  a4 := beta + delta  (new)
  a5 := beta*delta  (new)
  y(t) := y(t)

Here X2 could be something like x23...

  • In Transfection, it would be natural to call a4 tilde_d2. I guess we can get this name by the "sponsors-first" same logic, d2 appears only here.

  • In Covid1, a9 could be like delta_gir (although it is longish, I agree; maybe dg?)

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #583

Reviewed head: 80dec24
Raw SHA-256: 01758e40fa1d18169348496bc27a2df38713f80734e48385a689f0ea26448b29
Source SHA-256: 1f3d13bdaa912239b2f388d6f8a352570adcf32e67665949b0b6c19d559f268d
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1ffb0-e383-7813-82e7-a0385c1bf4ff
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H1)
  • Verdict: CHANGES
  • Reviewed head: 80dec24

Review report

VERDICT: CHANGES
Round: 1
Head: 80dec24
Slot: 1
CI: formatter or lint is not green
Session: 01a1ffb0-e383-7813-82e7-a0385c1bf4ff
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H1: the public function rejects an ODE accepted on the merge base and changes the documented mapping type.)

Blocking findings

  • Blocking priorities: P1, P1, P1, P2, P2

  • [P1] src/parametrizations.jl:237 prints @ODEmodel code that can silently turn an input into a parameter. I built x'(t) = a*x(t) + u(t) with output y(t) = x(t) and used rename_variables to rename only "u(t)" to "u". The returned model had input u and parameter a. Evaluating the printed code produced zero inputs and parameters a and u. Renaming the state and output to bare names also produced code that failed with cannot extract the single function name from x'. The ModelingToolkit conversion strips (t) from ring names at ext/ModelingToolkitSIExt.jl:348. Render time dependence from the ODE's state, input, and output lists and test reconstruction of the printed model.

  • [P1] src/parametrizations.jl:217 returns an OrderedDict where callers received a Dict. The existing implicit-relation checks at test/bodies/paradigm_shift.jl:87 threw four MethodErrors because eval_at_dict requires a Dict. The same checks passed on the merge base. The public example at src/parametrizations.jl:307 still shows a Dict. Keep the public mapping as a Dict and iterate over the ring generators to order the report.

  • [P1] src/parametrizations.jl:23 rejects distinct polynomial generators whose names normalize to the same Julia identifier. Using rename_variables, I assigned two states the spellings "\u00f1(t)" and "n\u0303(t)". reparametrize_global returned a result on the merge base and threw AssertionError: allunique(original_names) on the head. Use normalization to disambiguate the suggested names while preserving the distinct generators, and cover this case through the public entry point.

  • [P2] src/identifiable_functions.jl:43 and src/parametrizations.jl:295 fail doctests. Documenter captured Computing specializations.. progress output in both blocks, which expect empty output. The merge-base doctests passed. Restore loglevel = Logging.Error on both calls so the examples run quietly.

  • [P2] src/parametrizations.jl:22 and test/bodies/ode.jl:42 fail the repository's formatting checks. Runic also reports missing explicit returns in the changed parametrization functions. Format the changed files and rerun git diff --check.

Non-blocking findings

  • src/parametrizations.jl:352 writes the report directly to stdout while constructing an info log message. The two-output probe captured 369 stdout bytes at the default setting and zero with loglevel = Logging.Error. The merge base emitted zero at the default setting. Route the report through the logger or an explicit output stream so the default call can be used in scripts that reserve stdout for results.

What I ran

  • Julia 1.10.12 via juliaup. I used the test environment resolved by Pkg.test() to run the existing test/ode.jl and test/paradigm_shift.jl wrappers with --check-bounds=yes. The merge base passed 123/123. The head passed 176/180, including 35/35 ODE tests, with four errors at test/bodies/paradigm_shift.jl:87.
  • Ran probes-v2.jl and doc-example.jl against the merge base and head, and replay-edges.jl against the head, using Julia 1.10.12 and the repository's resolved package environment. The head preserved the two exact positional output values [4//5, 3//4]. Renaming χ(t) through the key "χ" raised StringIndexError on the merge base and returned "x(t)" on the head. The probes also reproduced the model replay, mapping type, and Unicode collision findings above.
  • Ran Documenter.doctest(StructuralIdentifiability; manual=false) with Documenter 1.20.0. The merge base reported one passing doctest testset. The head reported one failed testset and identified the two changed blocks above.
  • Runic 1.10.0 --check --diff on the six changed Julia files exited 1. git diff --check origin/master...HEAD reported three added lines with trailing whitespace. typos on the added diff lines exited 0.
  • uv run --locked python --version returned Python 3.13.13. UV reported that --locked had no effect outside a project. The checkout has no Python lockfile.

What I did not verify

  • I interrupted the broader GROUP=Core Pkg.test() run after 68 minutes while it was still running identifiable-function tests. The two affected test files completed in the separate run reported above.
  • I did not run the full HTML docs build, the ModelingToolkit extension suite, runtime tests on other Julia versions or architectures, or external CI.

AUTHOR_GRADE: {"task":"feature","score":2,"difficulty":3,"rounds":1,"author_harness":"unknown","author_model":"unknown","note":"The Unicode rename fix and exact positional output checks passed. The new mapping type breaks four existing assertions, the printed code can change input semantics, and both edited doctests fail."}

Head link: 80dec24


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a1ffb0-e383-7813-82e7-a0385c1bf4ff (no session URL)

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Devin <noreply@cognition.ai>
Agent-Harness: Devin CLI 3000.14.30821
Agent-Model: swe-2-1-high
Agent-Job: SciML__StructuralIdentifiability.jl__583--20261125T171433Z-devin-swe-2-1-high
Agent-Session: local session devin-list:calm-petroleum (no session URL)
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #583

Reviewed head: 3330409
Raw SHA-256: 874d38877a0bd0715bb0bca163597b5de8b4838ccca61ec205ad1085e4db2549
Source SHA-256: 5b975d152e00e4858cfaa938a78b2e49863883214398f16a5b47454063f642e3
Source: standard-review-v1 (harness-log)
Reviewer session: 01a21773-a2f5-7d40-b5b5-84f175e79794
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H1)
  • Verdict: CHANGES
  • Reviewed head: 3330409

Review report

VERDICT: CHANGES
Round: 2
Head: 3330409
Slot: 1
CI: formatter or lint is not green
Session: 01a21773-a2f5-7d40-b5b5-84f175e79794
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H1: the public reparametrization changes the documented mapping type and rejects a model the base accepts.)

Blocking findings

  • Blocking priorities: P1, P1, P1, P2, P2

  • [P1] src/parametrizations.jl:237 prints @ODEmodel code that silently changes a bare-named input into a parameter. For x'(t) = a*x(t) + u(t), I renamed u(t) to u and ran reparametrize_global. The returned model had one input u and one parameter a. Evaluating the printed code produced zero inputs and two parameters, a and u. Renaming the state and output to bare names also made the emitted code fail with cannot extract the single function name from x'.

    Implementation fix. In show_reparametrization, build the macro text from an ODE in a display ring whose states, inputs, and outputs have valid, unique Julia identifiers followed by (t). Derive roles from the ODE lists and transfer equations by generator index so the returned model keeps its original names. Add replay tests to test/bodies/paradigm_shift.jl for the bare-input and bare-state/output models. Evaluate the emitted block and check the variable roles and exact equations after aligning the rings.

  • [P1] src/parametrizations.jl:217 changes the public variable map from Dict to OrderedDict. All four existing implicit-relation assertions at test/bodies/paradigm_shift.jl:87 threw MethodError from eval_at_dict on this head. Those assertions passed on the base in the same resolved dependency environment. The public example at src/parametrizations.jl:307 shows Dict.

    Implementation fix. Restore the Dict constructor in reparametrize_with_respect_to. In show_reparametrization, iterate gens(parent(reparam.new_ode)) and look up each definition in the map to keep the display ordered. Add @test var_mapping isa Dict to test_reparametrization in test/bodies/paradigm_shift.jl and keep the exact zero checks for the implicit relations.

  • [P1] src/parametrizations.jl:23 aborts on distinct generators that Julia normalizes to the same spelling. I used rename_variables to create two states spelled "\u00f1(t)" and "n\u0303(t)". The public reparametrize_global call returned two states on the base and threw AssertionError: allunique(original_names) on this head.

    Implementation fix. In suggest_names, reserve normalized original names in a set and use the collision loop to assign distinct normalized candidates. Track unchanged definitions by their exact original generator and give any second use of the same normalized spelling a free suffix. Add a public-entry-point test in test/bodies/paradigm_shift.jl that checks both states survive with distinct normalized names and each output equation maps back to its own original state.

  • [P2] src/identifiable_functions.jl:43 and src/parametrizations.jl:295 fail their doctests. Documenter captured Computing specializations.. from both calls where it expected empty output.

    Implementation fix. Set up using Logging in both doctests and pass loglevel = Logging.Error on each call. Remove the global Logging.disable_logging calls from the example setup. Keep the quiet-output assertions and add a doctest check that length(new_ode.parameters) is 3, alongside the existing check for two identifiable functions in the other example.

  • [P2] src/parametrizations.jl:22 and test/bodies/ode.jl:42 fail formatting. Runic also flags the final expressions of suggest_names, show_reparametrization, and _reparametrize_global for missing explicit returns.

    Implementation fix. Apply Runic to src/parametrizations.jl and test/bodies/ode.jl. The existing regression checks are Runic --check --diff over the changed Julia files and git diff --check origin/master...HEAD. Both must exit zero.

Non-blocking findings

  • src/parametrizations.jl:352 writes the report directly to stdout while evaluating the info log message. The bare-input probe captured 224 stdout bytes on the head and zero on the base at the default log level.

    Implementation fix. In _reparametrize_global, use @info sprint(io -> show_reparametrization(io, reparam)) to send the report through the logger. Add a test in test/bodies/paradigm_shift.jl that routes the logging sink and stdout to separate buffers and asserts the report appears once in the logging sink and stdout is empty.

What I ran

  • Verified that delta.diff matches the Git diff from the prior reviewed head, and that the merge preserves the authored patch. Both base-to-head patches returned stable patch ID 9c17324b24b0c8ec539b594e86cee3d7f683bcdf. Inspected all seven PR paths for H6. The benchmark workflow changes in the prior-head delta, including the removal of explicit pull-request write permission in .github/workflows/benchmark.yml, are inherited from origin/master. Both benchmark workflow paths match the base tree.
  • Ran test/ode.jl and test/paradigm_shift.jl with GROUP=Core and --check-bounds=yes on Julia 1.10.12. The scratch test environments resolved dependencies from the repository project and used the same manifest versions on base and head. Base passed 123/123. Head passed 176/180, including 35/35 ODE assertions, with four reparametrization errors at test/bodies/paradigm_shift.jl:87.
  • Ran recheck.jl with --check-bounds=yes on base and head. It reproduced the role, mapping type, and Unicode results above. The head also returned ["left(t)", "right(t)"] in the original output order and both substituted output equations equaled their source equations exactly. Renaming χ(t) back through the key "χ" threw StringIndexError on the base and returned ["x(t)"] on the head.
  • Ran Documenter.doctest(StructuralIdentifiability; manual=false) with Documenter 1.20.0. It exited 1 on the head and reported the two changed doctest blocks.
  • Runic 1.13.0 --check --diff over the six changed Julia files exited 1. git diff --check origin/master...HEAD reported three lines with trailing whitespace. typos on added diff lines exited 0.
  • uv run --locked python --version returned Python 3.13.13. The checkout has no Python project or uv.lock, and uv reported that --locked had no effect outside a project.

What I did not verify

  • Verification covered the affected ODE and reparametrization test files and package doctests. The remaining Core and ModelingToolkit suites, full documentation build, other Julia versions and architectures, and hosted CI were outside the executed checks.

AUTHOR_GRADE: {"task":"feature","score":2,"difficulty":3,"rounds":2,"author_harness":"Devin CLI 3000.14.30821","author_model":"swe-2-1-high","note":"The Unicode suffix fix and exact positional output checks passed. The upstream merge leaves the three runtime blockers, two failing doctest blocks, and formatter failure in place."}

Head link: 3330409


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a21773-a2f5-7d40-b5b5-84f175e79794 (no session URL)

This branch has not been deployed

No deployments
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.

4 participants