Skip to content

ExperimentsToSbmlConverter drops array-data condition ids (experiments indistinguishable since #579) #630

Backlog

Description

@dweindl

ExperimentsToSbmlConverter drops the condition ids of periods whose conditions only select array data (PEtab SciML network inputs), although the arrays are keyed by these ids. Before #579, each converted experiment still had its own indicator condition _petab_experiment_condition_<id>, so experiments remained distinguishable. Since #579, that condition is only created if an experiment has changes encoded in the model. For such problems, all converted periods now reference only _petab_preequilibration_off, and the experiments become indistinguishable.

Example: PEtab SciML test suite case sciml_problem_import/015 (experiments e1 → cond1, e2 → cond2, no condition table, network input input0 from net3_input2.hdf5, keyed by condition id). Run from a clone of the test suite:

from petab.v2 import Problem
from petab.v2.converters import ExperimentsToSbmlConverter

problem = Problem.from_yaml(
    "test_cases/sciml_problem_import/015/petab/problem.yaml"
)
converted = ExperimentsToSbmlConverter(problem).convert()
for exp in converted.experiments:
    print(exp.id, [p.condition_ids for p in exp.periods])

With bd71513 (before #579):

e1 [['_petab_experiment_condition_e1', '_petab_preequilibration_off']]
e2 [['_petab_experiment_condition_e2', '_petab_preequilibration_off']]

With main (bacc686):

e1 [['_petab_preequilibration_off']]
e2 [['_petab_preequilibration_off']]

convert() itself logs:

ERROR: Array data input `input0` does not define arrays for all initial PEtab conditions. Missing: {'_petab_preequilibration_off'}. [CheckArrayDataFiles]

(before #579: Missing: {'_petab_experiment_condition_e1', '_petab_experiment_condition_e2', '_petab_preequilibration_off'}). The original problem validates without errors.

In _convert_experiment, the preequilibration period and the first non-preequilibration period are always kept. Periods whose conditions only select array data are not converted (if self._array_data_condition_ids and set(period.condition_ids).issubset(self._array_data_condition_ids): continue); later such periods are dropped entirely. The kept periods' condition ids are then overwritten with [*experiment_condition_ids, PREEQ_ON/OFF], which drops the array-data condition ids.

Suggested fix: keep the array-data condition ids in the kept periods (they are not encoded in the model and are still needed to look up the arrays), e.g. period.condition_ids = [*experiment_condition_ids, *array_data_condition_ids, preeq_on/off]. With this change, the output above becomes e1 [['cond1', '_petab_preequilibration_off']], e2 [['cond2', '_petab_preequilibration_off']], and the CheckArrayDataFiles error disappears. Separately, CheckInitialChangeSymbols (petab/v2/lint.py) then raises UnboundLocalError: cannot access local variable 'condition', because its except KeyError branch lacks a continue. Array-data condition ids of later, skipped periods are lost as well; that may be fine if array inputs can only be set at the start.

Related: it would help consumers to document that converted experiments keep the ids and order of the original experiments, so that converted and original periods can be matched by experiment id instead of by condition ids.

This was found via AMICI's JAX backend, which mapped converted periods back to the original ones by their condition ids. For 015, it used cond1's inputs for both experiments, giving a wrong likelihood (only the CheckArrayDataFiles error above was logged). AMICI will match by experiment id (AMICI-dev/AMICI#3623), but the array-data association should be preserved in the converted problem regardless.

🤖 Drafted with AI assistance (Claude Code)

Activity

  1. added
    v2
    conversion
    on Nov 25, 2026
  2. added theissue type on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    conversionv2

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions