Skip to content

Fix argument order in fisher_exact docstring example - #411

Merged
endrebak merged 2 commits into
pyranges:masterfrom
Mohit-Ak:fix/fisher-exact-doc-example
Oct 27, 2026
Merged

endrebak merged 2 commits into
pyranges:masterfrom
Mohit-Ak:fix/fisher-exact-doc-example

Conversation

@Mohit-Ak

Copy link
Copy Markdown
Contributor

The fisher_exact docstring example called pr.stats.fisher_exact(df.TP, df.FP, df.TN, df.FN), but the signature is fisher_exact(tp, fp, fn, tn), so the example passed TN and FN in each other's slots and showed the odds ratio and p-values for the wrong table.

This passes the columns in signature order and updates the expected output. The new values match scipy.stats.fisher_exact([[tp, fp], [fn, tn]]) for both rows (OR 34.8 / 0.0), and they line up with the odds-ratio formula in the Notes section.

Tested: pytest --doctest-modules pyranges/statistics.py and pytest tests/unit pass on pandas 3.1 and 2.3. isort, black and flake8 are clean, with the same settings as CI.

Fixes #391

The example passed TN and FN in swapped positions relative to the
signature fisher_exact(tp, fp, fn, tn). Fixes pyranges#391.
@Mohit-Ak
Mohit-Ak marked this pull request as ready for review October 24, 2026 21:52
@endrebak

Copy link
Copy Markdown
Collaborator

Thanks! 😳

@endrebak

Copy link
Copy Markdown
Collaborator

This also exists in v1 it seems. I'll get my clanker to fix it. Thanks for reporting. I'll have it go through and analyze all the math equations.

endrebak added a commit to pyranges/pyranges1 that referenced this pull request Oct 27, 2026
Bump the version and add the fisher_exact docstring fix to CHANGELOG.txt
and the README changelog. The fix was found and made by Mohit Arvind
Khakharia (@Mohit-Ak) in pyranges/pyranges0#411; this branch ports it.
The README changelog also gains the missing 1.5.1 entry.

Co-authored-by: Mohit Arvind Khakharia <6740115+Mohit-Ak@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
endrebak added a commit to pyranges/pyranges1 that referenced this pull request Oct 27, 2026
* Fix argument order in fisher_exact docstring example

The example passed TN before FN, but the signature is
fisher_exact(tp, fp, fn, tn). Port of pyranges/pyranges0#411.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YSQEBfFhfhK1o1XRsbHtcP

* Release 1.5.2, crediting @Mohit-Ak for the fisher_exact fix

Bump the version and add the fisher_exact docstring fix to CHANGELOG.txt
and the README changelog. The fix was found and made by Mohit Arvind
Khakharia (@Mohit-Ak) in pyranges/pyranges0#411; this branch ports it.
The README changelog also gains the missing 1.5.1 entry.

Co-authored-by: Mohit Arvind Khakharia <6740115+Mohit-Ak@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Mohit Arvind Khakharia <6740115+Mohit-Ak@users.noreply.github.com>
@endrebak
endrebak merged commit 7eba62d into pyranges:master Oct 27, 2026
11 checks passed
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.

Documentation error in fisher_exact

2 participants