Skip to content
Browse files

Merge pull request #2733 from astrofrog/fix-fill-value-python3

Fix setting of fill_value for string columns in Python 3
  • Loading branch information...
2 parents 069323d + 15d1aa3 commit 20224ea62ed42a3ebc0795f62b78309ff9ab1a8a @rgommers rgommers committed Nov 21, 2012
Showing with 6 additions and 1 deletion.
  1. +1 −1 numpy/ma/core.py
  2. +5 −0 numpy/ma/tests/test_regression.py
View
2 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...
View
5 numpy/ma/tests/test_regression.py
@@ -44,6 +44,11 @@ def test_atleast_2d(self):
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()

0 comments on commit 20224ea

Please sign in to comment.
Something went wrong with that request. Please try again.