summaryrefslogtreecommitdiff
path: root/numpy/ma/tests/test_extras.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-02-16 22:39:29 -0800
committerEric Wieser <wieser.eric@gmail.com>2018-03-25 12:19:33 -0700
commit093c308fcc4249d8a0f1336827d8eb9ad1e7d274 (patch)
treeba3612fbbd3ea2890d2c8c231e244bf8928ba434 /numpy/ma/tests/test_extras.py
parente2c71688e765a2c0eba4958891b0637754575f18 (diff)
downloadpython-numpy-093c308fcc4249d8a0f1336827d8eb9ad1e7d274.tar.gz
python-numpy-093c308fcc4249d8a0f1336827d8eb9ad1e7d274.tar.bz2
python-numpy-093c308fcc4249d8a0f1336827d8eb9ad1e7d274.zip
BUG: Always return a list from np.ma.flatnotmasked_contiguous
Depending on the input, this would return: * A single slice, if mask=nomask * A list of slices, if mask is an array * None, if mask is fully masked The documented return value is a list, and all downstream callers of this function end up having to correct for it not being one. This affects the result of np.ma.notmasked_contiguous, which also did not document these unusual return values.
Diffstat (limited to 'numpy/ma/tests/test_extras.py')
-rw-r--r--numpy/ma/tests/test_extras.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
index 9bebd6145..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):
@@ -384,14 +387,14 @@ class TestNotMasked(object):
[slice(0, 1, None), slice(2, 3, None)],
[slice(2, 3, None)],
[slice(2, 3, None)],
- None,
+ [],
[slice(2, 3, None)]
])
#
tmp = notmasked_contiguous(a, 1)
assert_equal(tmp, [
[slice(0, 4, None)],
- None,
+ [],
[slice(0, 6, None), slice(7, 8, None)]
])