Skip to content

assignments_to_experiments: keep the period that starts an experiment - #559

Draft
FFroehlich wants to merge 1 commit into
claude/assignments-to-experiments-rampsfrom
claude/assignments-to-experiments-start-time
Draft

FFroehlich wants to merge 1 commit into
claude/assignments-to-experiments-rampsfrom
claude/assignments-to-experiments-start-time

Conversation

@FFroehlich

@FFroehlich FFroehlich commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

A v2 period's time overrides the model's initial time, so an experiment starts at its first period after pre-equilibration. assignments_to_experiments dropped that period whenever nothing changed there. Either it was redundant, because the model already holds the value before the switch, or its condition only set symbols that the conversion replaced, so the condition was emptied and removed. The experiment then started at its first switch, and measurements before the switch were simulated from the wrong start.

For example, k1 := piecewise(1, time < 5, 2) converted to default_experiment with a single period at t = 5. The existing test_assignments_to_experiments asserted that shape: one period at t = 10, beside a measurement at t = 0.

Changes

  • Every converted experiment keeps the period that starts it, without conditions if none are left. For default_experiment, and for an experiment that only pre-equilibrates, that is the period at t = 0 the converter already adds. The or experiment.periods[:1] fallback goes, since the start period is never dropped.
  • A switch therefore never becomes an experiment's first period, and CheckInitialChangeSymbols only checks the first period. A start value that equals the model's value is no longer set just because a switch refers to symbols outside the parameter table. For level * piecewise(0, time < 10, 1), the experiment now has an empty period at 0 and k1 = level at 10, where it had k1 = 0 at 0 and k1 = level at 10. A start value that refers to parameter table symbols is still set at the start (as since assignments_to_experiments: convert assignments that switch more than once #556), since the model only holds a number for it.

Tests

  • test_assignments_to_experiments, _nested, _condition_specific, _several_switches and _fixed_switching_time now expect the empty period at t = 0.
  • New test_assignments_to_experiments_simulate_before_switch covers both cases: no experiment, and a condition at t = 0 that only sets the switching time. It converts the problem, turns both the original and the converted problem into SBML events with ExperimentsToSbmlConverter, simulates them in BasiCO at t = 0, 1, 2, 4, 6 and 10, and compares the results. They match to 3e-11 relative (the test asserts 1e-6). Without this fix, the converted problem is off by up to 45% before the switch.
  • The benchmark problems that convert (Brannmark_JBC2010, Fujita_SciSignal2010, Isensee_JCB2018, Raimundez_PCB2020) give the same experiment table, condition table and SBML with and without this change.

Relation to #557

Stacked on #557; #556 is merged. The bug has been on main since #527. On main the change merges cleanly as text, but main's test_assignments_to_experiments_several_switches and _fixed_switching_time assert the old shape, with no period at t = 0, and #557 reworks the redundant block that this change simplifies. This PR's base moves to main once #557 merges.

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.13%. Comparing base (422e254) to head (d61c2d0).

Additional details and impacted files
@@                           Coverage Diff                            @@
##           claude/assignments-to-experiments-ramps     #559   +/-   ##
========================================================================
  Coverage                                    78.12%   78.13%           
========================================================================
  Files                                           68       68           
  Lines                                         7846     7847    +1     
  Branches                                      1403     1403           
========================================================================
+ Hits                                          6130     6131    +1     
  Misses                                        1228     1228           
  Partials                                       488      488           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@FFroehlich
FFroehlich added this pull request to stack #558 October 19, 2026 13:29
@FFroehlich
FFroehlich force-pushed the claude/assignments-to-experiments-start-time branch from 590c2bc to 26ed6ec Compare October 19, 2026 13:32
A period's time overrides the model's initial time, so an experiment starts
at its first period after preequilibration. The converter dropped that
period when nothing changed there, either as redundant, since the model
already holds the value before the switch, or because its condition only
set symbols that the conversion replaced. The experiment then started at
its first switch, and measurements before the switch were simulated from
the wrong start.

The period that starts each experiment now stays, without conditions if
none are left. A switch therefore never becomes an experiment's first
period, and a start value that equals the model's no longer needs to be
set when a switch refers to symbols outside the parameter table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FFroehlich
FFroehlich force-pushed the claude/assignments-to-experiments-start-time branch from 26ed6ec to d61c2d0 Compare October 19, 2026 18:33

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.

2 participants