A couple of errors in numpy/records.py
![](https://secure.gravatar.com/avatar/5c7407de6b47afcd3b3e2164ff5bcd45.jpg?s=120&d=mm&r=g)
Hi, I've detected a couple of issues in records.py. For the first one, the next should fix it: Index: numpy/core/records.py =================================================================== --- numpy/core/records.py (revision 2033) +++ numpy/core/records.py (working copy) @@ -410,7 +410,8 @@ offset=offset) elif isinstance(obj, sb.ndarray): res = obj.view(recarray) - if issubclass(res.dtype, nt.void): + if issubclass(res.dtype.type, nt.void): res.dtype = sb.dtype((record, res.dtype)) + return res else: raise ValueError("Unknown input type") Now, another curious thing (sorry, no patch this time): In [6]: for i in numpy.rec.array([(1,2)], formats='u4,u4'): print i ...: (1L, 2L) [No problem with this] In [7]: for i in numpy.rec.array([(1,2)], formats='u4,u4')[0]: print i ...: --------------------------------------------------------------------------- exceptions.KeyError Traceback (most recent call last) /home/faltet/computacio.nobackup/hdf5-1.7.51/test/<console> /usr/lib/python2.3/site-packages/numpy/core/records.py in __getitem__(self, obj) 126 127 def __getitem__(self, obj): --> 128 return self.getfield(*(self.dtype.fields[obj][:2])) 129 130 def __setitem__(self, obj, val): KeyError: 0 I'd expect something like 1L 2L Cheers, --
participants (2)
-
Francesc Altet
-
Travis Oliphant