diff options
author | Julian Taylor <juliantaylor108@gmail.com> | 2014-08-27 01:06:59 +0200 |
---|---|---|
committer | Julian Taylor <juliantaylor108@gmail.com> | 2014-08-27 01:06:59 +0200 |
commit | ad42ea6f614b7f9369a2a5756fea1dc66bc555d6 (patch) | |
tree | d5643ff361cb3c952245ade238be130e55330e46 | |
parent | 64c89327355d6154ef854dfee1be6c264125ccaa (diff) | |
parent | 007b186a853c8ab37db62042376a9b2d66c18dcf (diff) | |
download | numpy-ad42ea6f614b7f9369a2a5756fea1dc66bc555d6.tar.gz |
Merge pull request #4997 from juliantaylor/unicode-init
BUG: set needs-init flag for unicode dtype
-rw-r--r-- | numpy/core/src/multiarray/arraytypes.c.src | 5 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index 8a0b1826b..876529a1f 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -3696,6 +3696,7 @@ static int * #align = char, char, npy_ucs4# * #NAME = Void, String, Unicode# * #endian = |, |, =# + * #flags = 0, 0, NPY_NEEDS_INIT# */ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = { { @@ -3775,8 +3776,8 @@ static PyArray_Descr @from@_Descr = { NPY_@from@LTR, /* byteorder */ '@endian@', - /* flags */ - 0, + /* flags, unicode needs init as py3.3 does not like printing garbage */ + @flags@, /* type_num */ NPY_@from@, /* elsize */ diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index ade95fb7b..96db8cde3 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -586,6 +586,12 @@ class TestCreation(TestCase): assert_array_equal(zeros_like(d), d) assert_equal(zeros_like(d).dtype, d.dtype) + def test_empty_unicode(self): + # don't throw decode errors on garbage memory + for i in range(5, 100, 5): + d = np.empty(i, dtype='U') + str(d) + def test_sequence_non_homogenous(self): assert_equal(np.array([4, 2**80]).dtype, np.object) assert_equal(np.array([4, 2**80, 4]).dtype, np.object) |