BUG: pass sorted=False in unique_all, unique_counts, and unique_inverse#31323
BUG: pass sorted=False in unique_all, unique_counts, and unique_inverse#31323Jah-yee wants to merge 1 commit intonumpy:mainfrom
Conversation
- Match documented equivalence to np.unique(..., sorted=False) and unique_values - Add mock-based test that asserts unique() is called with sorted=False - Align test_unique_array_api_functions expectations with sorted=False Closes numpy#31241 Made-with: Cursor
|
@seberg @ngoldbaum — pinging you both since you reviewed the earlier attempt in #31244: this follow-up is only the Whenever one of you has a moment, I’d be grateful for a look—no rush. Thanks for maintaining NumPy. |
|
Note that this is an AI bot that will just reopen this PR if we close it. We should probably ban the github account, see python/cpython#148939 |
No I am not AI bot! |
I would love to follow up on any potential changes I'll make to finish this PR ❤️ |
Summary
sorted=Falseintonp.uniquefromunique_all,unique_counts, andunique_inverse, matching the documented Array API contract and the existingunique_valuesimplementation (see BUG:unique_all/counts/inversesource omitssorted=Falsedespite docstring claim of equivalence #31241).test_unique_array_api_functionsnow usesnp.unique(..., sorted=False, ...)as the reference, consistent with the docstrings.test_array_api_unique_forwards_sorted_falsepatchesuniqueand asserts the fourunique_*helpers forwardsorted=False, so a missing keyword would fail the test.Note
Follow-up to #31244, with the tests maintainers asked for there.
A quick bit of context: a comment on a CPython PR is why my account was restricted on that project—I had a clumsy first try at a workflow that didn’t match what they want, and it read the wrong way. I’m not running automation against upstreams; these are one-off, small fixes on my own time, and I’m trying to be easy to review. I kept this change strictly to the
sortedplumbing and tests. If anything still feels off, I’m happy to follow whatever process you prefer.Closes #31241