Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4c169c

Browse files
author
Ralf Gommers
committed
Merge pull request #2842 from certik/backport459
Backport459
2 parents 28aab32 + 049ae4d commit c4c169c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

numpy/core/arrayprint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ',
308308
elif issubclass(dtypeobj, _nt.datetime64):
309309
format_function = formatdict['datetime']
310310
else:
311-
format_function = formatdict['str']
311+
format_function = formatdict['numpystr']
312312

313313
# skip over "["
314314
next_line_prefix = " "

numpy/core/tests/test_arrayprint.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
13
import sys
24
import numpy as np
35
from numpy.testing import *
@@ -147,6 +149,15 @@ def test_formatter_reset(self):
147149
np.set_printoptions(formatter={'float_kind':None})
148150
assert_equal(repr(x), "array([ 0., 1., 2.])")
149151

152+
def test_unicode_object_array():
153+
import sys
154+
if sys.version_info[0] >= 3:
155+
expected = "array(['é'], dtype=object)"
156+
else:
157+
expected = "array([u'\\xe9'], dtype=object)"
158+
x = np.array([u'\xe9'], dtype=object)
159+
assert_equal(repr(x), expected)
160+
150161

151162

152163
if __name__ == "__main__":

0 commit comments

Comments
 (0)