[Numpy-discussion] bug ? in Records arrays in numarray
Sebastian Haase
haase at msg.ucsf.edu
Tue Jun 29 09:44:46 EDT 2004
Hi,
I have two record arrays. I was trying to assign one item from one recarray to
the other:
>>> omx.zext[0] = main.ring4ext[0,0]
Traceback (most recent call last):
File "<input>", line 1, in ?
File "X:/PrWin\numarray\records.py", line 744, in _setitem
self.field(self._names[i])[row] = value.field(self._names[i])
File "C:\Python22\Lib\site-packages\numarray\numarraycore.py", line 619, in
__tonumtype__
ValueError: Can't use non-rank-0 array as a scalar.
>>> `omx.zext[0]`
'<numarray.records.Record instance at 0x042AFC78>'
>>> `main.ring4ext[0,0]`
'<numarray.records.Record instance at 0x042AFC78>'
>>> q = omx.zext[0]
>>> w = main.ring4ext[0,0]
>>> q
(2097152107, -595656700, 91141, 1.0634608642000868e+037, -1.14841804241843e
+018, 1.2771574333702815e-040)
>>> w
(array([428]), array([75]), array([124]), array([ 1.08846451e+09],
type=Float32), array([ 99.25], type=Float32), array([ 1996.82995605],
type=Float32))
>>> omx.zext._formats
['1Int32', '1Int32', '1Int32', '1Float32', '1Float32', '1Float32']
>>> main.ring4ext._formats
['1Int32', '1Int32', '1Int32', '1Float32', '1Float32', '1Float32']
I can't track down why one (q) contains scalars and the other (w) constains
arrays (is array([428]) a 'rank-0 array'? ) !
This is how I generate them:
main.ring4ext = rec.RecArray(main._extHdrRingBuffer, "i4,i4,i4,f4,f4,f4",
shape=(ts,nc), names=("num","min","max","time","mean","darkVal"), aligned=1)
omx.zext = rec.array(formats="i4,i4,i4,f4,f4,f4",
names=("num","min","max","time","mean","darkVal"),shape=tuple(shapeZ),aligned=1 )
[[BTW: (shapeZ is a list, if I say: ...,shape=shapeZ I get
NameError, "Illegal shape %s" % `shape` from "records.py" in line 462 --
usually type(shape) == types.ListType should be OK, right ?)
]]
Any ideas?
Thanks,
Sebastian Haase
More information about the NumPy-Discussion
mailing list