[SciPy-User] Having scipy.ndimage, etc. methods return ndarray subclass instances?

Keith Hughitt keith.hughitt@gmail....
Wed Aug 3 11:37:29 CDT 2011


I'm currently working on creating a subclass of numpy.ndarray, and would 
like to ensure that other methods that work with ndarrays (e.g. 
http://docs.scipy.org/doc/scipy/reference/ndimage.html) return an instance 
of the subclass instead of an ndarray. After reading a discussion on the 
topic on Stack Overflow (
http://stackoverflow.com/questions/6190859/some-numpy-functions-return-ndarray-instead-of-my-subclass), I 
looked into adding/modifying __array_finalize__ and __array_wrap__ but 
neither of these appear to be called when I call a scipy.ndimage method such 
as median_filter.

Is there a way I can extend my subclass so that I can ensure that a new 
subclass instance or view is returned instead of an ndarray?

Any suggestions would be greatly appreciated.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20110803/ed3f40b0/attachment.html 

More information about the SciPy-User mailing list