[Numpy-discussion] subclassing ndaray
Colin J. Williams
cjw at sympatico.ca
Fri Feb 24 07:56:12 CST 2006
I have a subclass Bar, a 1-dim array which has some methods and some
attributes. One of the attributes is a view of the Bar to permit
different shaping.
Suppose that 'a' is an instance of 'Bar', which has a method 'show' and
a view attribute 'v'.
a ^ 15 returns a Bar instance, with its methods but without the attributes.
I am attempt to change this, Bar has a method __xor__, see below:
def __xor__(self, other):
''' Exclusive or: __xor__(x, y) => x ^ y . '''
z=
1
<< this loops to the recursion limit
result= ArrayType.__xor__(self, other)
n= self.n
result.n= n
result.rowSize= self.rowSize
result.show= self.show
result.v= _n.reshape(result.view(), (n*n, n*n))
return result
Could anyone suggest a workaround please?
Colin W.
More information about the Numpy-discussion
mailing list