I think I see a bug in lib.user_array.container class. The __eq__ method is def __eq__(self,other): return self._rc(equal(self.array,other)) the expression equal(self.array,other) will return an ndarray of bools, which is then converted, by way of self._rc(), to whatever the derived class is. In my case, this does not make sense, because an array of bools is not a valid argument to the constructor (actually, the data buffer is accepted, but the results are not reliable). What I want, and it seem most people would want in this situation, is just the array of bools; i.e. don't apply the self._rc() method. Assuming there is agreement that this is the desirable behavior, the same would be true for __lt__, __le__, etc. I will probably override this behavior by defining my own __eq__, etc., in my derived class, just for safety. ** Bill Spotz ** ** Sandia National Laboratories Voice: (505)845-0170 ** ** P.O. Box 5800 Fax: (505)284-5451 ** ** Albuquerque, NM 87185-0370 Email: wfspotz@sandia.gov **
Bill Spotz wrote:
I think I see a bug in lib.user_array.container class. The __eq__ method is
def __eq__(self,other): return self._rc(equal(self.array,other))
the expression equal(self.array,other) will return an ndarray of bools, which is then converted, by way of self._rc(), to whatever the derived class is. In my case, this does not make sense, because an array of bools is not a valid argument to the constructor (actually, the data buffer is accepted, but the results are not reliable). What I want, and it seem most people would want in this situation, is just the array of bools; i.e. don't apply the self._rc() method.
No, it's not a bug. It's just the design of that class: always return the same class of object. Of course, since that class only exists to be subclassed, if you need different behavior from those methods, override them. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
participants (2)
-
Bill Spotz
-
Robert Kern