[Numpy-discussion] Please help with subclassing numpy.ndarray
Sun Feb 4 19:33:01 CST 2007
On Sunday 04 February 2007 20:22:44 Jeremy Conlin wrote:
> I have subclassed the numpy.ndarray object, but need some help setting
> some attributes. I have read http://scipy.org/Subclasses but it
> doesn't provide the answer I am looking for.
In the example given in http://scipy.org/Subclasses an attribute 'info' is
defined from a class-generic one '__defaultinfo'. Just do the same thing with
(H, edges) = numpy.histogramdd(..)
cls.__defaultedges = edges
def __array_finalize__(self, obj):
if not hasattr(self, 'edges'):
self.edges = self.__defaultedges
That should the trick.
More information about the Numpy-discussion