Skip to content

Conversation

sterrettm2
Copy link
Contributor

I identified two bugs related to the handling of nans in the kvsort/kvselect logic.

  1. kvselect (and thus kvpartialsort) would produce incorrect results when using descending order on arrays with nans
  2. kvsort would produce invalid results when given arrays containing both infinity and nan

This patch should fix both of these issues, and it adds a test with mixed inf/nan arrays for all of the qsort/kvsort tests. From my testing, it seems to have a negligible performance impact.

Copy link
Member

@r-devulap r-devulap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wow, this was quite a miss in the review earlier :) Thanks for fixing!

}

// Handle the remainders once we have less than 1 vector worth
while (ii < jj) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could have combined this in the main loop with a masked load, but this is fine too.

@r-devulap r-devulap merged commit b27f82b into numpy:main Feb 20, 2025
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.

2 participants