summaryrefslogtreecommitdiff
path: root/numpy/ma
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-06-18 11:06:35 -0500
committerSebastian Berg <sebastian@sipsolutions.net>2020-07-08 18:13:06 -0500
commit56c63d8660ba75d6947c6c5f16abc93affbaf793 (patch)
treedd6af223f96a69581c9aab69494bfdbbdc81a59c /numpy/ma
parente30cbfbe3811818c4878b90579704ed332468dea (diff)
downloadnumpy-56c63d8660ba75d6947c6c5f16abc93affbaf793.tar.gz
MAINT: Undo change of how 0-D array-likes are handled as scalars
Diffstat (limited to 'numpy/ma')
-rw-r--r--numpy/ma/tests/test_core.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index 76a92f5ca..27f14a5e7 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -215,6 +215,17 @@ class TestMaskedArray:
y = array([1, 2, 3], mask=x._mask, copy=True)
assert_(not np.may_share_memory(x.mask, y.mask))
+ def test_masked_singleton_array_creation_warns(self):
+ # The first works, but should not (ideally), there may be no way
+ # to solve this, however, as long as `np.ma.masked` is an ndarray.
+ np.array(np.ma.masked)
+ with pytest.warns(UserWarning):
+ # Tries to create a float array, using `float(np.ma.masked)`.
+ # We may want to define this is invalid behaviour in the future!
+ # (requiring np.ma.masked to be a known NumPy scalar probably
+ # with a DType.)
+ np.array([3., np.ma.masked])
+
def test_creation_with_list_of_maskedarrays(self):
# Tests creating a masked array from a list of masked arrays.
x = array(np.arange(5), mask=[1, 0, 0, 0, 0])