[Numpy-discussion] __eq__ method for recarray returns recarray
Dan Yamins
dyamins@gmail....
Fri Jul 3 21:40:19 CDT 2009
If I have two recarrays with the same len and column headers, the __eq__
method returns the rich comparison, which is great. E.g.
In [20]: x =
np.rec.fromrecords([(1,2,'dd',.3),(33,2,'y',2.2),(2,3,'a',21.4),(3,4,'b',33.2)],names=['A','B','C','D'])
In [21]: y =
np.rec.fromrecords([(1,2,'dd',.3),(33,2,'y',2.2),(2,3,'a',21.4),(3,4,'b',33.2)],names=['A','B','C','D'])
In [22]: x == y
Out[22]: rec.array([ True, True, True, True], dtype=bool)
But notice that the returned object is a recarray, not an array of bools.
Why is this, and what is the purpose of having it this way?
Similarly, if I subclass recarray, and say, in my subclass attach some
attributes to x, then these attributes are attached to the result of the
rich comparison. E.g. suppose I have a subclass of recarray called
"NewRecarray" to which I attach an attribute .info. Then
x = NewRecarray(data)
y = NewRecarray(data)
z = x == y
Then z is a NewRecarray object and z.info = x.info.
Is this the expected / proper behavior? Is there something wrong with the
way I've subclassed recarray?
Thanks,
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090703/85cf9f34/attachment.html
More information about the NumPy-Discussion
mailing list