Skip to content

Require a moments-popgen with the corrected pi2 term - #186

Merged
andrewkern merged 1 commit into
nsp-multiallelic-trunkfrom
fix/moments-popgen-pin
Aug 17, 2026
Merged

Require a moments-popgen with the corrected pi2 term#186
andrewkern merged 1 commit into
nsp-multiallelic-trunkfrom
fix/moments-popgen-pin

Conversation

@andrewkern

Copy link
Copy Markdown
Member

Problem

Two unphased parity cases in tests/test_moments_ld.py fail on the current
trunk:

  • TestFourPopLD::test_ld_sums_match[geno]
  • TestAltCodedSiteParity::test_agree_on_plain_disagree_on_alt_coded[geno]

Both mismatch only on pi2_0_0_0_0 and pi2_1_1_1_1, the single-population
pi2 terms. Below moments-popgen 1.5.3 the cython genotype kernel carries a
sign error in the pi2(i,i;i,i) correction polynomial, so those tests were
comparing against wrong reference values. pg_gpu's kernel has the correct
term, so the failures were never a defect on our side. The environment was
resolving 1.5.0 because the dependency was unconstrained.

Fix

Pin moments-popgen >= 1.5.3.

The pin alone does not solve. moments-popgen also caps mpmath < 1.4 and
scipy < 1.17, and for both the conda solve takes precedence over the pypi
one, so the solve fails outright unless the caps are restated as conda
dependencies on the feature. They are scoped to feature.moments, so only
the parity-comparison environment is held back; the default environment is
unchanged.

Verification

Local GPU run, since CI has no GPU:

  • pytest tests/test_moments_ld.py (moments env): was 34 passed / 2 failed,
    now 36 passed, 6 skipped, 3 xfailed, 0 failed
  • pytest tests/ -n 10 (default env): 1253 passed, unchanged
  • ruff check pg_gpu/ tests/ examples/: clean

Resolved versions in the moments environment: moments-popgen 1.6.0,
scipy 1.16.3, mpmath 1.3.0.

Below 1.5.3 the cython genotype kernel carries a sign error in the
single-population pi2 correction, so the unphased parity cases in
test_moments_ld.py compared against wrong reference values and failed
while pg_gpu was right.

moments-popgen also caps mpmath and scipy, and for these the conda solve
takes precedence over the pypi one, so the caps are restated on the
feature. Without them the environment quietly resolves to an older
moments instead of reporting the conflict.
@andrewkern
andrewkern merged commit 8c4e04e into nsp-multiallelic-trunk Aug 17, 2026
@andrewkern
andrewkern deleted the fix/moments-popgen-pin branch August 17, 2026 20:00
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