diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-08-04 11:39:25 -0500 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-27 07:26:51 -0600 |
commit | 2b05fadefd18f2206b11a548fc44d783898ec366 (patch) | |
tree | 652752c00465e830b6abedadab1586e9fedfb93b /numpy/core | |
parent | ecadc64f7ce5a8a683a84893d8aeb326f7a80fb8 (diff) | |
download | numpy-2b05fadefd18f2206b11a548fc44d783898ec366.tar.gz |
ENH: missingdata: Fix construction of maskna array with all NAs
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_maskna.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index e121345b1..16e912c95 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -612,7 +612,7 @@ setArrayFromSequence(PyArrayObject *a, PyObject *s, int dim, npy_intp offset, npy_intp maskoffset) { Py_ssize_t i, slen; - int res = -1; + int res = 0; int a_has_maskna = PyArray_HASMASKNA(a); /* diff --git a/numpy/core/tests/test_maskna.py b/numpy/core/tests/test_maskna.py index 61fb7918e..393edf74d 100644 --- a/numpy/core/tests/test_maskna.py +++ b/numpy/core/tests/test_maskna.py @@ -45,6 +45,12 @@ def test_array_maskna_construction(): assert_equal(type(a), np.ndarray) assert_(np.isna(a)) + # The data type defaults to the same as an empty array if all is NA + a = np.array([np.NA], maskna=True) + b = np.array([]) + assert_equal(a.dtype, b.dtype) + assert_(np.isna(a)) + a = np.zeros((3,)) assert_(not a.flags.maskna) a = np.zeros((3,), maskna=True) |