Repository navigation
Make flattened PEtab v2 observable IDs independent of libpetab serialization - #3398
Closed
FFroehlich wants to merge 2 commits into
Closed
FFroehlich wants to merge 2 commits into
FFroehlich wants to merge 2 commits into
Conversation
…ization `flatten_timepoint_specific_output_overrides` and `unflatten_simulation_df` derived the IDs of the replicated observables from libpetab's measurement table serialization. Since libpetab-python#545, numbers are written without truncation, which changed the IDs (`1.0` -> `1` instead of `1_00000000000000`) and broke `test_flatten_timepoint_specific_output_overrides`. The IDs are now built directly from the measurements' override values: parameter IDs as they are, numbers in their shortest representation that round-trips, with `p` for the decimal point and `m` for minus signs. This also fixes collisions of numbers that differ only beyond the 15th significant digit, and invalid IDs for negative numbers and numbers in exponential notation. An error is raised if different overrides would still result in the same ID (e.g. parameter IDs with underscores). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FFroehlich
marked this pull request as draft
October 15, 2026 11:28
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3398 +/- ##
=======================================
Coverage 79.98% 79.98%
=======================================
Files 320 320
Lines 22674 22707 +33
Branches 1531 1531
=======================================
+ Hits 18135 18162 +27
- Misses 4531 4537 +6
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Member
Author
|
Closing: the failing test was already fixed by #3394. |
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.
mainhas been red on PEtab Testsuite since libpetab-python's #545 ("Fix invalid and lossy output ofpetab_math_str") was merged:python/tests/petab_/test_petab_v2.py::test_flatten_timepoint_specific_output_overridesfails.Cause:
flatten_timepoint_specific_output_overridesandunflatten_simulation_dfbuilt the IDs of the replicated observables from libpetab's measurement table serialization (MeasurementTable.to_df()→petab.v1.core.get_observable_replacement_id). Before #545, overrides were written with sympy'sstr, i.e. truncated to 15 significant digits (1.0→1.00000000000000, givingobs1__obsParOverride1_1_00000000000000__noiseParOverride1). The test encoded those IDs. Since #545, numbers are written exactly and integer-valued floats as integers, so the ID is nowobs1__obsParOverride1_1__noiseParOverride1.Fix: The IDs are now built directly from the
Measurementobjects' override values, so they no longer depend on how libpetab writes tables:repr(float)), withpfor the decimal point,mfor minus signs, and integer-valued numbers without a decimal point. For example,1.0→1,0.1→0p1,-1.5e-07→m1p5em07. Distinct doubles get distinct IDs, and1and1.0get the same ID.{observableId}__{observableParameters joined by _}__{noiseParameters joined by _}.RuntimeErroris raised. This can happen with parameter IDs that contain underscores, e.g.a_b;cvs.a;b_c. Previously such observables were merged silently, which left timepoint-specific overrides in place.groupbyon the serialized strings.The old serialization-based IDs had further problems, with either libpetab version:
-1_5,1e-20), so flattening failed with a pydanticValidationError..→_makes, e.g.,1.5;2and1;5.2collide.Why not just update the expected IDs or pin libpetab: The expected IDs in the test do change, from the truncated
1_00000000000000to1. Any exact, compact number format gives1here, and the new IDs match what libpetab main produces for this case. But updating only the test would keep the IDs tied to libpetab's table writer, along with the problems above. Pinning libpetab would only postpone the failure.Tests:
test_flatten_timepoint_specific_output_overrides.test_flatten_timepoint_specific_output_overrides_numeric. It covers adjacent doubles (0.1vs.nextafter(0.1, 1)), negative numbers, exponents,2vs.2.0, and anunflatten_simulation_dfround-trip.test_flatten_timepoint_specific_output_overrides_ambiguous, which checks the collision error.main, under both libpetab versions.Verified locally (Python 3.14, macOS), with libpetab main (663b383, includes #545) and with the previous main (539333b):
python/tests/petab_/test_petab_v2.pypass with both versions.0006(SBML), which goes through flatten andunflatten_simulation_df, passes with both versions.0006was not run locally because BioNetGen isn't installed here.🤖 Generated with Claude Code