Repository navigation
Conversation
Adding a row to MOD_DF upcast unimod_id to float64, so translated libraries wrote every modification as e.g. [UniMod:4.0]. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…for exports add_new_modifications accepts an optional unimod_id. Added modifications default to -1 (no UniMod id) instead of 0, which was exported as the invalid accession UniMod:0. mod_to_unimod_dict was built once at import, so modifications added later were missing from TSV/parquet exports, and whether a user mod was exported depended on import order. It is now a read-only mapping over the current MOD_DF (cached until the table changes) that pickles to a plain dict. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mo-sameh
requested review from
GeorgWa and
mschwoer
and removed request for
mschwoer
October 11, 2026 23:41
mschwoer
approved these changes
Oct 14, 2026
| # MOD_DF is replaced by load_mod_df() and grown by add_new_modifications(), | ||
| # so rebuild whenever the table object or its length changes. | ||
| mod_df = modification.MOD_DF | ||
| cache_key = (id(mod_df), len(mod_df)) |
Contributor
There was a problem hiding this comment.
isn't len a bit of a weak hash? If I remove a mod, and add one, it stays the same
Collaborator
Author
There was a problem hiding this comment.
True, good catch! Instead of a better hash on every lookup, I dropped building a cache and went with rebuilding the dict in update_all_by_MOD_DF(), which should be called after every change to MOD_DF anyway.
The cached lookup keyed on (id, len) of MOD_DF and missed changes that keep the row count, e.g. removing one mod and adding another. Build MOD_TO_UNIMOD alongside the other mod dicts instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
load_mod_df() in other tests rebinds MOD_DF, so a module-level import pointed the tests at a stale table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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.
Fixes exporting libraries that contain modifications added with
add_new_modifications:unimod_idstayed float after adding a modification, so TSV/parquet exportwrote
UniMod:4.0instead ofUniMod:4for every modification.add_new_modificationsnow accepts an optionalunimod_id.mod_to_unimod_dict) now includes modifications addedafter import. It is rebuilt in
update_all_by_MOD_DF()together with theother modification dicts. A custom modification without an id is left out
(so it raises a
KeyError) instead of being exported asUniMod:0.To-do list (outside contributers only)