8000 TST: Test all dtypes for sort. · numpy/numpy@7f58678 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f58678

Browse files
committed
TST: Test all dtypes for sort.
Testing: - np.int8/np.uint8 - np.int16/np.uint16 - np.int32/np.uint32 - np.int64/np.uint64 - np.float32/np.float64 - np.float16/np.longdouble
1 parent 12fb101 commit 7f58678

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

numpy/core/tests/test_multiarray.py

Expand all lines: numpy/core/tests/test_multiarray.py
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,8 @@ def test_sort(self):
16161616
# of sorted items must be greater than ~50 to check the actual
16171617
# algorithm because quick and merge sort fall over to insertion
16181618
# sort for small arrays.
1619-
for dtype in [np.int32, np.uint32, np.float32]:
1619+
# Test unsigned dtypes and nonnegative numbers
1620+
for dtype in [np.uint8, np.uint16, np.uint32, np.uint64, np.float16, np.float32, np.float64, np.longdouble]:
16201621
a = np.arange(101, dtype=dtype)
16211622
b = a[::-1].copy()
16221623
for kind in self.sort_kinds:
@@ -1628,6 +1629,19 @@ def test_sort(self):
16281629
c.sort(kind=kind)
16291630
assert_equal(c, a, msg)
16301631

1632+
# Test signed dtypes and negative numbers as well
1633+
for dtype in [np.int8, np.int16, np.int32, np.int64, np.float16, np.float32, np.float64, np.longdouble]:
1634+
a = np.arange(-50, 51, dtype=dtype)
1635+
b = a[::-1].copy()
1636+
for kind in self.sort_kinds:
1637+
msg = "scalar sort, kind=%s, dtype=%s" % (kind, dtype)
1638+
c = a.copy()
1639+
c.sort(kind=kind)
1640+
assert_equal(c, a, msg)
1641+
c = b.copy()
1642+
c.sort(kind=kind)
1643+
assert_equal(c, a, msg)
1644+
16311645
# test complex sorts. These use the same code as the scalars
16321646
# but the compare function differs.
16331647
ai = a*1j + 1

0 commit comments

Comments
 (0)
0