summaryrefslogtreecommitdiff
path: root/numpy/ma/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/ma/tests')
-rw-r--r--numpy/ma/tests/test_core.py6
-rw-r--r--numpy/ma/tests/test_extras.py42
2 files changed, 33 insertions, 15 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index 4c6bb2b42..ff1e087b5 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -3200,6 +3200,12 @@ class TestMaskedArrayMethods(object):
assert_equal(sortedx._data, [1, 2, -2, -1, 0])
assert_equal(sortedx._mask, [1, 1, 0, 0, 0])
+ def test_stable_sort(self):
+ x = array([1, 2, 3, 1, 2, 3], dtype=np.uint8)
+ expected = array([0, 3, 1, 4, 2, 5])
+ computed = argsort(x, kind='stable')
+ assert_equal(computed, expected)
+
def test_argsort_matches_sort(self):
x = array([1, 4, 2, 3], mask=[0, 1, 0, 0], dtype=np.uint8)
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
index d1c1aa63e..95319eb65 100644
--- a/numpy/ma/tests/test_extras.py
+++ b/numpy/ma/tests/test_extras.py
@@ -128,7 +128,10 @@ class TestGeneric(object):
a = arange(10)
# No mask
test = flatnotmasked_contiguous(a)
- assert_equal(test, slice(0, a.size))
+ assert_equal(test, [slice(0, a.size)])
+ # mask of all false
+ a.mask = np.zeros(10, dtype=bool)
+ assert_equal(test, [slice(0, a.size)])
# Some mask
a[(a < 3) | (a > 8) | (a == 5)] = masked
test = flatnotmasked_contiguous(a)
@@ -136,7 +139,7 @@ class TestGeneric(object):
#
a[:] = masked
test = flatnotmasked_contiguous(a)
- assert_equal(test, None)
+ assert_equal(test, [])
class TestAverage(object):
@@ -368,23 +371,32 @@ class TestNotMasked(object):
a = masked_array(np.arange(24).reshape(3, 8),
mask=[[0, 0, 0, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1],
- [0, 0, 0, 0, 0, 0, 1, 0], ])
+ [0, 0, 0, 0, 0, 0, 1, 0]])
tmp = notmasked_contiguous(a, None)
- assert_equal(tmp[-1], slice(23, 24, None))
- assert_equal(tmp[-2], slice(16, 22, None))
- assert_equal(tmp[-3], slice(0, 4, None))
- #
+ assert_equal(tmp, [
+ slice(0, 4, None),
+ slice(16, 22, None),
+ slice(23, 24, None)
+ ])
+
tmp = notmasked_contiguous(a, 0)
- assert_(len(tmp[-1]) == 1)
- assert_(tmp[-2] is None)
- assert_equal(tmp[-3], tmp[-1])
- assert_(len(tmp[0]) == 2)
+ assert_equal(tmp, [
+ [slice(0, 1, None), slice(2, 3, None)],
+ [slice(0, 1, None), slice(2, 3, None)],
+ [slice(0, 1, None), slice(2, 3, None)],
+ [slice(0, 1, None), slice(2, 3, None)],
+ [slice(2, 3, None)],
+ [slice(2, 3, None)],
+ [],
+ [slice(2, 3, None)]
+ ])
#
tmp = notmasked_contiguous(a, 1)
- assert_equal(tmp[0][-1], slice(0, 4, None))
- assert_(tmp[1] is None)
- assert_equal(tmp[2][-1], slice(7, 8, None))
- assert_equal(tmp[2][-2], slice(0, 6, None))
+ assert_equal(tmp, [
+ [slice(0, 4, None)],
+ [],
+ [slice(0, 6, None), slice(7, 8, None)]
+ ])
class TestCompressFunctions(object):