Closed
Description
For a structured masked array, when accessing a field with a character dtype, the fill_value
is evidently not correctly set. When X
is a structured masked array with a structured dtype such that field A
is a character array, accessing X['A'].fill_value
gives TypeError: byte indices must be integers or slices, not tuple
. The offending line of code is:
return self._fill_value[()]
with a full example shown below.
$ ipython3 --pylab
Python 3.5.0 (default, Nov 20 2015, 16:20:41)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg
Python are go!
In [1]: print(numpy.version.version)
1.12.0.dev0+0de1234
In [2]: X = numpy.ma.empty(shape=1, dtype=[("A", "S1", 2)])
In [3]: Xa = X["A"]
In [5]: Xa.fill_value
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-d077d77d307b> in <module>()
----> 1 Xa.fill_value
/home/users/gholl/venv/stable-3.5/lib/python3.5/site-packages/numpy/ma/core.py in get_fill_value(self)
3528 if self._fill_value is None:
3529 self._fill_value = _check_fill_value(None, self.dtype)
-> 3530 return self._fill_value[()]
3531
3532 def set_fill_value(self, value=None):
TypeError: byte indices must be integers or slices, not tuple
This problem is triggered, among other locations, upon calling repr(Xa)
, so it has a rather high impact in practice.
Metadata
Metadata
Assignees
Labels
No labels