Skip to content

Commit efd74d8

Browse files
Merge pull request #1704 from IntelPython/improve-test-sort-complex-fp-nan-performance
Improve performance of test_sort_complex_fp_nan
2 parents d6d1526 + 56f6276 commit efd74d8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

dpctl/tests/test_usm_ndarray_sorting.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,16 @@ def test_sort_complex_fp_nan(dtype):
275275

276276
assert np.allclose(dpt.asnumpy(s), expected, equal_nan=True)
277277

278+
pairs = []
278279
for i, j in itertools.permutations(range(inp.shape[0]), 2):
279-
r1 = dpt.asnumpy(dpt.sort(inp[dpt.asarray([i, j])]))
280-
r2 = np.sort(dpt.asnumpy(inp[dpt.asarray([i, j])]))
280+
pairs.append([i, j])
281+
sub_arrs = inp[dpt.asarray(pairs)]
282+
m1 = dpt.asnumpy(dpt.sort(sub_arrs, axis=1))
283+
m2 = np.sort(dpt.asnumpy(sub_arrs), axis=1)
284+
for k in range(len(pairs)):
285+
i, j = pairs[k]
286+
r1 = m1[k]
287+
r2 = m2[k]
281288
assert np.array_equal(
282289
r1.view(np.int64), r2.view(np.int64)
283290
), f"Failed for {i} and {j}"

0 commit comments

Comments
 (0)