From 48f8c53690b50a88705aff273937eb5fd891b45e Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 30 Sep 2025 10:56:20 +0200 Subject: [PATCH] Do not use stable sort in nunique --- src/array_api_extra/_lib/_funcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/array_api_extra/_lib/_funcs.py b/src/array_api_extra/_lib/_funcs.py index cbcbe0ff..f61affe5 100644 --- a/src/array_api_extra/_lib/_funcs.py +++ b/src/array_api_extra/_lib/_funcs.py @@ -822,7 +822,7 @@ def nunique(x: Array, /, *, xp: ModuleType | None = None) -> Array: # xp does not have unique_counts; O(n*logn) complexity x = xp.reshape(x, (-1,)) - x = xp.sort(x) + x = xp.sort(x, stable=False) mask = x != xp.roll(x, -1) default_int = default_dtype(xp, "integral", device=_compat.device(x)) return xp.maximum(