summaryrefslogtreecommitdiff
path: root/numpy/ma
diff options
context:
space:
mode:
authorserge-sans-paille <serge.guelton@telecom-bretagne.eu>2021-12-11 23:05:38 +0100
committerserge-sans-paille <serge.guelton@telecom-bretagne.eu>2021-12-12 00:59:00 +0100
commit8ca82f3fe41ec3f708d7d88cd360e77440d3ce59 (patch)
tree8204c8258b085d197d3f1198e966f615be047be3 /numpy/ma
parent93301a53aad8ddda15a25415e9af8f574cd758a8 (diff)
downloadnumpy-8ca82f3fe41ec3f708d7d88cd360e77440d3ce59.tar.gz
Fix sorting of int8/int16
radix sort operates on unsigned types, but the key extractor needs to know the original type. Fix #20567
Diffstat (limited to 'numpy/ma')
-rw-r--r--numpy/ma/tests/test_core.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index bf95c999a..c8f7f4269 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -3422,6 +3422,10 @@ class TestMaskedArrayMethods:
assert_equal(sortedx._data, [1, 2, -2, -1, 0])
assert_equal(sortedx._mask, [1, 1, 0, 0, 0])
+ x = array([0, -1], dtype=np.int8)
+ sortedx = sort(x, kind="stable")
+ assert_equal(sortedx, array([-1, 0], dtype=np.int8))
+
def test_stable_sort(self):
x = array([1, 2, 3, 1, 2, 3], dtype=np.uint8)
expected = array([0, 3, 1, 4, 2, 5])