Repository navigation
ExperimentsToSbmlConverter: write one flat initial assignment per target - #546
Open
FFroehlich wants to merge 1 commit into
Open
FFroehlich wants to merge 1 commit into
FFroehlich wants to merge 1 commit into
Conversation
The first-period changes were turned into initial assignments once per
experiment. Each experiment read the current initial assignment back as
the default and wrapped it in a new Piecewise, so the expression nested
one level deeper per experiment. With a few hundred experiments, reading
it back failed in lxml ("Excessive depth in document: 256"), e.g., for
Raimundez_PCB2020 upgraded to v2.
Now the first-period changes of all experiments are collected and
combined into a single flat Piecewise per target after all experiments
were converted. The default is the initial assignment or initial value
of the original model.
Closes #540
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #546 +/- ##
==========================================
+ Coverage 76.77% 77.80% +1.02%
==========================================
Files 67 67
Lines 7547 8230 +683
Branches 1346 1543 +197
==========================================
+ Hits 5794 6403 +609
- Misses 1259 1295 +36
- Partials 494 532 +38 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
FFroehlich
marked this pull request as ready for review
October 15, 2026 08:41
FFroehlich
enabled auto-merge (squash)
October 15, 2026 08:51
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ExperimentsToSbmlConverterbuilt the initial assignments for the first period once per experiment. Each experiment read the current initial assignment back as the default and wrapped it in a newPiecewise, so the expression nested one level deeper per experiment. With a few hundred experiments, reading it back (sbml_math_to_sympy) failed in lxml withExcessive depth in document: 256. This breaksRaimundez_PCB2020upgraded to v2.Change
convert()now collects the first-period changes of all experiments and writes them in one go (new_create_initial_assignments): one flatPiecewiseper target, with one(value, indicator_e > 0.5)pair per experiment that changes the target, and the original model's initial assignment or initial value as theotherwisebranch.This follows the second fix suggested in the issue rather than flattening while wrapping. It also means the default is always the original model's value, and the growing assignment is no longer serialized and re-parsed once per experiment.
Verification
test_initial_assignments_many_experiments(300 experiments; a species with an initial value and one with an initial assignment, plus one experiment that changes neither). It checks that the assignment is a flatPiecewisewith one pair per experiment and that it evaluates correctly for the first and last experiment and for the default. It fails onmainwith the lxml error from the issue.Ais 3 levels deep for 5, 50, 300 and 1000 conditions (before: 7, 52, lxml error).petab1to2): for every initial assignment and every experiment (and with all indicators at 0), the old and new converter give the same value. The maximum MathML depth drops, e.g., Alkan_SciSignal2018 75 → 4, Bachmann_MSB2011 38 → 4, Smith_BMCSystBiol2013 37 → 4. Raimundez_PCB2020 (170 experiments) fails with the old converter. With the new one, all 1360 first-period changes match the resulting initial assignments, at depth 4. Conversion takes ~2 s; the old converter took 22 s before failing.pytest tests/v2: 142 passed, 1 skipped (withbenchmark_models_petabinstalled).pre-commitis clean.Closes #540
🤖 Generated with Claude Code