Skip to content

BUG: preserve exact int64 comparisons in rankdata and nanrankdata - #618

Open
vera-rubin wants to merge 2 commits into
pydata:masterfrom
vera-rubin:fix/int64-rank-ties
Open

vera-rubin wants to merge 2 commits into
pydata:masterfrom
vera-rubin:fix/int64-rank-ties

Conversation

@vera-rubin

Copy link
Copy Markdown

rankdata and nanrankdata at 4053596 give [1.5, 1.5] for int64 values 2**53 and 2**53 + 1. The tie rule averages ranks for equal values, so both should return [1.0, 2.0].

import bottleneck as bn
import numpy as np

a = np.array([2**53, 2**53 + 1], dtype=np.int64)
bn.rankdata(a)
bn.nanrankdata(a)

We keep values used for tie comparisons in the input dtype, while rank calculations and output stay float64.

We added a regression test for both functions and ran the existing test suite.

— ChipLab

@vera-rubin

Copy link
Copy Markdown
Author

The only red check is pre-commit.ci: zizmor flags three self-repository references in .github/workflows/ci.yml, which this PR does not touch and which 86094a9 fixed on master. Could pre-commit.ci be rerun?

@vera-rubin

Copy link
Copy Markdown
Author

Merged master into the branch, which brings in 86094a9, so the pre-commit.ci zizmor findings in .github/workflows/ci.yml (a file this PR does not touch) should clear on the new run.
The full test suite passes on the merge (240 passed, 1 xfailed).

This branch has not been deployed

No deployments
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