Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qsort and qsortvec inconsistent with BAD values #252

Closed
d-lamb opened this issue Oct 5, 2018 · 3 comments
Closed

qsort and qsortvec inconsistent with BAD values #252

d-lamb opened this issue Oct 5, 2018 · 3 comments

Comments

@d-lamb
Copy link
Member

d-lamb commented Oct 5, 2018

The docs for qsort state that 'Bad values are moved to the end of the array:'

The docs for qsortvec state nearly the same thing: 'Vectors with bad components should be moved to the end of the array:'

However this does not seem to be borne out in practice in qsortvec.

pdl> p $p = pdl("[0 0] [-100 0] [BAD 0] [100 0]")

[
 [   0    0]
 [-100    0]
 [ BAD    0]
 [ 100    0]
]

pdl> p $p->qsortvec

[
 [ BAD    0]
 [-100    0]
 [   0    0]
 [ 100    0]
]

pdl> p $p->((0))->qsort
[-100 0 100 BAD]

My expectation is that the output of qsortvec (given the documentation, and the output of the qsort expression) should be:

[
 [-100    0]
 [   0    0]
 [ 100    0]
 [ BAD    0]
]
@mohawk2
Copy link
Member

mohawk2 commented Dec 27, 2021

That is also my expectation! qsortvec confidently has HandleBad => 1 and the docs that you note, but doesn't have BadCode (or, as you rightly note, correct handling of bad values).

@mohawk2
Copy link
Member

mohawk2 commented Dec 27, 2021

...and now it (and qsortveci) do. Thanks for the report!

@mohawk2 mohawk2 closed this as completed Dec 27, 2021
mohawk2 added a commit that referenced this issue Nov 1, 2024
@mohawk2
Copy link
Member

mohawk2 commented Nov 1, 2024

qsort inplace with bad values was pretty underfunctional too, now fixed by the above commit. That was masked by the qsort testing code largely checking its work with all($pdl1 == $pdl2), and that does not do what you think if either ndarray has badvalues, including in different places from each other, but at least one matching non-bad value. Bad values are a bit like NaN, but not entirely.

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

No branches or pull requests

2 participants