On 2/4/07, Pierre GM <[EMAIL PROTECTED]> wrote:
> 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.
>
> Actually, yes:
> 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
> your 'edges'
>
> def __new__(cls,...)
>      ...
>     (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.

Thanks for clarifying that.  I didn't understand what the
__array_finalize__ did.

Jeremy
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to