Skip to content

Respect inclusive position window endpoints - #459

Open
antonsoo wants to merge 2 commits into
cggh:masterfrom
antonsoo:fix/363-inclusive-position-windows
Open

antonsoo wants to merge 2 commits into
cggh:masterfrom
antonsoo:fix/363-inclusive-position-windows

Conversation

@antonsoo

@antonsoo antonsoo commented Oct 22, 2026 •

Copy link
Copy Markdown

Closes #363.

windowed_count([1, 2, 3, 4], size=1) currently returns windows [1, 1], [2, 2], [3, 4] with counts [1, 1, 2]. The final window can exceed the requested size, which also changes diversity/divergence denominators. A region containing one position raises an indexing error.

Use start + size - 1 for the inclusive right endpoint, and include a window beginning at the requested stop. Normalize NumPy integer scalars before inclusive arithmetic to avoid overflow at their dtype limits. Clip and stop at the first window that reaches that endpoint, preserving the existing overlapping-window stopping convention. Twenty tests cover these boundaries, integer limits, gaps and accessibility masks; four existing expectations are updated for the separate terminal window.

An independent simulated-cohort replay writes and reads a VCF containing 128 haplotypes and 2,024 variant sites. Physical windows and diversity agree with explicit base enumeration and tskit's C engine in all 72 workflows, versus 50 incorrect or failing workflows before. All 22 previously passing records and the explicit-window controls remain identical.

Full suites pass 901 tests versus 881 on unchanged master, on Python 3.12/NumPy 1.26 and Python 3.10/NumPy 2.2. Correctness Flake8 passes. These runs use Pandas 2.3 and native tabix; Pandas 3 has separate baseline string-dtype test failures.

The installed Python 3.12 wheel also reproduces all 72 workflows exactly, with its imported code and native extension paths checked.

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.

windowing: weird(?) behavior with the last window

1 participant