summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@googlemail.com>2012-11-21 12:07:10 -0800
committerRalf Gommers <ralf.gommers@googlemail.com>2012-11-21 12:07:10 -0800
commit20224ea62ed42a3ebc0795f62b78309ff9ab1a8a (patch)
treea18e91035c3a85ca51a68f44d9c2daf59982cf62 /numpy
parent069323db3d7863d7d777a8329eb76ac07002870e (diff)
parent15d1aa3b50f22eeb74d27ba7f5ad75b5777b2d87 (diff)
downloadnumpy-20224ea62ed42a3ebc0795f62b78309ff9ab1a8a.tar.gz
Merge pull request #2733 from astrofrog/fix-fill-value-python3
Fix setting of fill_value for string columns in Python 3
Diffstat (limited to 'numpy')
-rw-r--r--numpy/ma/core.py2
-rw-r--r--numpy/ma/tests/test_regression.py5
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..e3a5d9613 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()