Repository navigation
Fix spurious index column in v2 table round-trips - #542
Merged
Merged
Conversation
`from_df` of the v2 parameter, measurement, observable and mapping tables unconditionally called `reset_index()`, which turned an unnamed index into an extra `index` column that was kept and written out. Now only named index levels are moved to columns. Also: * accept empty `observableParameters` / `noiseParameters` strings, so `MeasurementTable.from_df(table.to_df())` works * don't modify the input DataFrame in `ObservableTable.from_df` Fixes PEtab-dev#541. Relates to PEtab-dev#523. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #542 +/- ##
==========================================
+ Coverage 77.43% 77.58% +0.15%
==========================================
Files 67 67
Lines 7670 7673 +3
Branches 1374 1374
==========================================
+ Hits 5939 5953 +14
+ Misses 1242 1231 -11
Partials 489 489 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dweindl
marked this pull request as ready for review
October 14, 2026 18:12
This was referenced Oct 14, 2026
dilpath
approved these changes
Oct 14, 2026
Comment on lines
+116
to
+119
| df.index = [5, 7] | ||
| df_orig = df.copy() | ||
| table = table_cls.from_df(df) | ||
| assert_frame_equal(df, df_orig) |
Member
There was a problem hiding this comment.
What does this assert do? It looks like this must be equal because one is a copy of the other?
Member
Author
There was a problem hiding this comment.
This is related to the df = get_observable_df(df.copy()) line in petab/v2/core.py. Previously, from_df would mutated the input via get_observable_df.
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.
from_dfof the v2 parameter, measurement, observable and mapping tables unconditionally calledreset_index(), which turned an unnamed index (e.g. the defaultRangeIndexfromfrom_tsv) into an extraindexcolumn. That column was kept due toextra="allow"and written out again, adding another column on each load/save cycle. Now only named index levels are moved to columns.Also:
observableParameters/noiseParametersstrings, so thatMeasurementTable.from_df(table.to_df())worksObservableTable.from_df(get_observable_dfoperates in place)Fixes #541. Relates to #523.
🤖 Generated with Claude Code