Skip to content

v1: parameter table entries replace initial assignments - #643

Draft
dweindl wants to merge 2 commits into
PEtab-dev:mainfrom
dweindl:create-parameter-df-initial-assignments
Draft

dweindl wants to merge 2 commits into
PEtab-dev:mainfrom
dweindl:create-parameter-df-initial-assignments

Conversation

@dweindl

@dweindl dweindl commented Nov 27, 2026

Copy link
Copy Markdown
Member

In PEtab v1, a parameter table entry for a model parameter with a non-numeric initial assignment (e.g., k_derived = k_base + 1) was ignored for the model: the initial assignment still applied. Condition table and measurement table references to the same ID, however, resolved to the parameter table entry, so one ID could have two values. This PR makes the parameter table entry replace the initial assignment, as it already did for numeric initial assignments, and as specified in PEtab v2.

This changes the parameter mapping, and thus the results, for problems that list such parameters in the parameter table. Parameters with non-numeric initial assignments that are not listed in the parameter table are unaffected; their initial assignments still apply.

Changes:

  • Parameter mapping: model parameters with non-numeric initial assignments that are listed in the parameter table are now included in the mapping, so they are mapped to their parameter table entry. get_parameter_mapping_for_condition raises a ValueError if precomputed simulation_parameters lack such parameters, instead of silently ignoring their parameter table entries.
  • create_parameter_df(..., include_optional=True): since listing a parameter replaces its initial assignment, targets of initial assignments that are not closed-form are no longer included. An initial assignment is closed-form if it refers to no model entities, function definitions, or time, and can be evaluated (e.g., 2 * 3, but not k_base + 1); this is decided syntactically. Such parameters are still included if they are referenced in the measurement table (as observable or noise parameter overrides) or as values in the condition table, since these references require a parameter table entry: named measurement table overrides must be listed in the parameter table, and a condition table reference cannot be resolved from a non-closed-form initial assignment. In these cases, the parameter table entry also replaces the initial assignment in the model. For targets of closed-form initial assignments, the nominal value is now the value of the assignment instead of the SBML value attribute, which was often stale or NaN.

Since parameter table entries now replace initial assignments, a non-estimated entry without nominalValue would put NaN into the model. #640 makes lint reject such entries and should be merged before or together with this PR.

Fixes #638. Relates to #522.

🤖 Drafted with AI assistance (Claude Code)

dweindl and others added 2 commits November 27, 2026 15:54
…ments

Listing an initial assignment target in the parameter table replaces the
initial assignment. For a generated template, this is rarely intended if
the assignment expresses a dependency (`k_derived = k_base + 1`), and the
SBML `value` attribute used as nominal value is stale or `NaN`.

With `include_optional=True`, `create_parameter_df` now omits targets of
initial assignments that refer to model entities, function definitions,
or time. Such parameters are still included if they are referenced in the
measurement table (as observable or noise parameter overrides) or as
values in the condition table, since these references require a
parameter table entry: named measurement table overrides must be listed
in the parameter table, and a condition table reference cannot be
resolved from a non-closed-form initial assignment.

Targets of closed-form initial assignments (e.g., `2 * 3`) are kept, with
the evaluated assignment as nominal value. The closed-form check is
syntactic (`a - a` is not closed-form).

Closes PEtab-dev#638.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A parameter table entry for a model parameter with a non-numeric initial
assignment was ignored for the model, so the initial assignment applied.
Condition table and measurement table references to the same ID resolved
to the parameter table entry, so one ID could have two values.

Now, such entries replace the initial assignment, as for numeric initial
assignments and as in PEtab v2. Model parameters with non-numeric initial
assignments that are not listed in the parameter table are still not part
of the mapping.

This changes the mapping output for problems with such entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.15686% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.50%. Comparing base (bacc686) to head (78d830e).

Files with missing lines Patch % Lines
petab/v1/parameters.py 78.94% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #643      +/-   ##
==========================================
+ Coverage   80.34%   80.50%   +0.15%     
==========================================
  Files          70       70              
  Lines        8505     8554      +49     
  Branches     1561     1577      +16     
==========================================
+ Hits         6833     6886      +53     
+ Misses       1180     1177       -3     
+ Partials      492      491       -1     

☔ 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.

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.

create_parameter_df(include_optional=True) includes parameters that are initial assignment targets

2 participants