Skip to content

Commit 35d333a

Browse files
authored
Merge pull request #358 from ev-br/argsort_followup
TST: add a test for torch.argsort defaulting to stable=True
2 parents fb31b6a + 7cf0b79 commit 35d333a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_torch.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,13 @@ def test_meshgrid():
130130
assert Y.shape == Y_ij.shape
131131
assert xp.all(Y == Y_ij)
132132

133+
134+
def test_argsort_stable():
135+
"""Verify that argsort defaults to a stable sort."""
136+
# Bare pytorch defaults to an unstable sort, and the array_api_compat wrapper
137+
# enforces the stable=True default.
138+
# cf https://github.com/data-apis/array-api-compat/pull/356 and
139+
# https://github.com/data-apis/array-api-tests/pull/390#issuecomment-3452868329
140+
141+
t = xp.zeros(50) # should be >16
142+
assert xp.all(xp.argsort(t) == xp.arange(50))

0 commit comments

Comments
 (0)