[Numpy-discussion] my derived ndarray class object loses its attribute after a transpose()
Fri Nov 23 10:07:21 CST 2007
> First try seems to show that just changing my class def to:
> class ndarray_inMrcFile(N.memmap):
> def __array_finalize__(self,obj):
> self.Mrc = getattr(obj, 'Mrc', None)
> Seems to add the wanted attribute back into result of transpose().
Yep. Specific subclass attributes should be defined in __array_finalize__.
> However now I get (many!) exceptions like:
> Exception exceptions.AttributeError: "'ndarray_inMrcFile' object has no
> attribut e '_mmap'" in <bound method ndarray_inMrcFile.__del__ of
> ndarray_inMrcFile([ 6,....
> Do I need to call super.__array_finalize__(obj) first ?
Nope, you just need a __new__ that calls the __new__ of you parent class. Keep
More information about the Numpy-discussion