diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 19be452e518f..f3add44630da 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -308,7 +308,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', elif issubclass(dtypeobj, _nt.datetime64): format_function = formatdict['datetime'] else: - format_function = formatdict['str'] + format_function = formatdict['numpystr'] # skip over "[" next_line_prefix = " " diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py index 0cd78c27e2e7..2a2a97336746 100644 --- a/numpy/core/tests/test_arrayprint.py +++ b/numpy/core/tests/test_arrayprint.py @@ -1,3 +1,5 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- import sys import numpy as np from numpy.testing import * @@ -147,6 +149,15 @@ def test_formatter_reset(self): np.set_printoptions(formatter={'float_kind':None}) assert_equal(repr(x), "array([ 0., 1., 2.])") +def test_unicode_object_array(): + import sys + if sys.version_info[0] >= 3: + expected = "array(['é'], dtype=object)" + else: + expected = "array([u'\\xe9'], dtype=object)" + x = np.array([u'\xe9'], dtype=object) + assert_equal(repr(x), expected) + if __name__ == "__main__":