[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 =

In [21]: y =

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?

-------------- 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