Skip to content

Commit

Permalink
Merge pull request numpy#2733 from astrofrog/fix-fill-value-python3
Browse files Browse the repository at this point in the history
Fix setting of fill_value for string columns in Python 3
  • Loading branch information
rgommers committed Nov 21, 2012
2 parents 069323d + 15d1aa3 commit 20224ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/ma/core.py
Expand Up @@ -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...
Expand Down
5 changes: 5 additions & 0 deletions numpy/ma/tests/test_regression.py
Expand Up @@ -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.