diff options
author | Thomas Robitaille <thomas.robitaille@gmail.com> | 2012-11-13 15:51:08 +0100 |
---|---|---|
committer | Thomas Robitaille <thomas.robitaille@gmail.com> | 2012-11-13 17:05:04 +0100 |
commit | 4171e5093ff85391458da09342f32dec25822496 (patch) | |
tree | 9062e4788f583d1583604f3341cd2debf296f994 | |
parent | 780c1a6bb6d18bc21fed7fa251faffb9ea51e861 (diff) | |
download | numpy-4171e5093ff85391458da09342f32dec25822496.tar.gz |
Fix setting of fill_value for string columns in Python 3
-rw-r--r-- | numpy/ma/core.py | 2 | ||||
-rw-r--r-- | numpy/ma/tests/test_regression.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index a7e04cd13..bcd24d22b 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -414,7 +414,7 @@ def _check_fill_value(fill_value, ndtype): fill_value = np.array(_recursive_set_fill_value(fill_value, descr), dtype=ndtype) else: - if isinstance(fill_value, basestring) and (ndtype.char not in 'SV'): + if isinstance(fill_value, basestring) and (ndtype.char not in 'SVU'): fill_value = default_fill_value(ndtype) else: # In case we want to convert 1e+20 to int... diff --git a/numpy/ma/tests/test_regression.py b/numpy/ma/tests/test_regression.py index 62e4ee0ae..8cb8a2661 100644 --- a/numpy/ma/tests/test_regression.py +++ b/numpy/ma/tests/test_regression.py @@ -44,6 +44,11 @@ class TestRegression(TestCase): assert_(a.mask.ndim == 1) assert_(b.mask.ndim == 2) + def test_set_fill_value_unicode_py3(self): + """Ticket #2733""" + a = np.ma.masked_array(['a', 'b', 'c'], mask=[1, 0, 0]) + a.fill_value = 'X' + assert a.fill_value == 'X' if __name__ == "__main__": run_module_suite() |