Skip to content

Fix candidate indexing when breaking ties in closest - #244

Open
DylanCosto wants to merge 1 commit into
open2c:mainfrom
DylanCosto:fix-closest-ties
Open

DylanCosto wants to merge 1 commit into
open2c:mainfrom
DylanCosto:fix-closest-ties

Conversation

@DylanCosto

Copy link
Copy Markdown

In closest_intervals, tie_arr holds one priority per candidate interval, but it is passed to np.lexsort alongside the candidate pairs. The sort key therefore isn't aligned with the rows being sorted. When the lengths differ, closest(..., tie_breaking_col=...) raises; when they happen to match, it can silently pick the wrong interval.

This indexes it as tie_arr[events2], so each pair is ranked by its own candidate's priority.

I added tests in test_ops.py covering k > 1, a callable tie_breaking_col, reordered candidates, overlaps and multiple chromosomes. They fail on main and pass with this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant