diff options
Diffstat (limited to 'numpy/ma')
| -rw-r--r-- | numpy/ma/core.py | 8 | ||||
| -rw-r--r-- | numpy/ma/tests/test_core.py | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index b71e8fa06..0d02bb315 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -3867,6 +3867,10 @@ class MaskedArray(ndarray): def __str__(self): return str(self._insert_masked_print()) + if sys.version_info.major < 3: + def __unicode__(self): + return unicode(self._insert_masked_print()) + def __repr__(self): """ Literal string representation. @@ -6238,6 +6242,10 @@ class MaskedConstant(MaskedArray): def __str__(self): return str(masked_print_option._display) + if sys.version_info.major < 3: + def __unicode__(self): + return unicode(masked_print_option._display) + def __repr__(self): if self is MaskedConstant.__singleton: return 'masked' diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index fd8d629f9..03de71f81 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -500,6 +500,16 @@ class TestMaskedArray(object): ' fill_value = 999999)\n' ) + def test_0d_unicode(self): + u = u'caf\xe9' + utype = type(u) + + arr_nomask = np.ma.array(u) + arr_masked = np.ma.array(u, mask=True) + + assert_equal(utype(arr_nomask), u) + assert_equal(utype(arr_masked), u'--') + def test_pickling(self): # Tests pickling for dtype in (int, float, str, object): |
