Repository navigation
feat(eval): make the sink reachable from cafa_eval, not only from the kernels - #24
Merged
Merged
Conversation
… kernels #23 wired PerProteinSink into the two sparse kernels and compute_metrics and stopped there. Consumers do not call those. PROTEA calls cafa_eval, which calls evaluate_prediction, which calls compute_metrics, which calls a kernel. So the feature existed and could not be used from the only entry point that matters, which is worse than not existing because it reads as done. Threads per_protein_sink through evaluate_prediction and cafa_eval, and tags each record with its namespace and variant. Without those a caller holding six records cannot tell the weighted BPO arrays from the unweighted CCO ones, and the weighted variant is the one carrying the headline metric, so an untagged record cannot serve the purpose the sink exists for. Defaults stay None everywhere: with no sink passed nothing in this library behaves differently, and the tests still assert it.
frapercan
added a commit
that referenced
this pull request
Aug 19, 2026
Third and final piece of the per-protein sink. #23 emitted the arrays, #24 made them reachable from `cafa_eval`, and this makes them **usable**. ## The gap The arrays were anonymous, indexed by an opaque row number. Every axis the sink exists to support is keyed by protein: - sequence length - identity to the nearest donor - taxonomic relation to the nearest donor None can be joined to a row number, so the feature as shipped could not do the one thing it was built for. I found this while writing the consumer, at the point of asking which protein row 0 was. ## Two numberings, which is why this is not one line The NK/LK kernel receives every row, so array row `i` is matrix row `i`. The PK kernel can be handed a subset: ```python pred_sub = pred[proteins_has_gt, :] ``` after which the array numbering and the `ids` numbering disagree. `compute_metrics` is what performs that subsetting, so it is what records the mapping, rather than leaving each caller to reconstruct it from state it does not have. Getting this wrong would attribute one protein's score to another. That is exactly the failure the consuming project spent a week correcting in its neighbour search, where a positional misalignment produced plausible numbers for a fortnight. So there is a test asserting `row_index` has one entry per array row, rather than a comment saying it should. ## Also Identity is `None` when not supplied rather than guessed, and the id map is copied rather than aliased, with tests for both. `pytest tests -q`: 29 passed, 6 xfailed. `ruff` and `mypy` clean.
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.
Follow-up to #23, which stopped one level short.
What was wrong
#23 wired
PerProteinSinkinto the two sparse kernels andcompute_metrics.Nobody calls those. The consuming project calls
cafa_eval:So the feature existed and could not be reached from the only entry point that
uses this library. That is worse than not shipping it, because from outside it
reads as done.
I caught it while wiring the consumer, at the exact moment of writing the call
that would have silently collected nothing.
What this adds
per_protein_sinkonevaluate_predictionandcafa_eval, and a namespace andvariant tag on every record.
The tags are not cosmetic.
evaluate_predictioncallscompute_metricstwiceper namespace, once unweighted and once weighted, so a full run hands the sink
six records. Untagged, a caller cannot tell the weighted BPO arrays from the
unweighted CCO ones, and the weighted variant is the one carrying
f_micro_w. An untagged record cannot serve the purpose the sink exists for.Unchanged
Every default is still
None. With no sink passed, no signature, no return typeand no number this library produces is different, and the existing tests still
assert exactly that.
Tests
Three added: that both public entry points expose the parameter, that a record
reports its namespace and variant, and that the context defaults to
Noneratherthan to a guess.
pytest tests -q: 25 passed, 6 xfailed.ruffandmypyclean.