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

Keith Hughitt keith.hughitt@gmail....
Wed Aug 3 10:58:51 CDT 2011


Hello,

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. 
scipy.ndimage.* <http://www.scipy.org/SciPyPackages/Ndimage>) return an 
instance of the subclass instead of an ndarray.

After reading a discussion on the topic<http://stackoverflow.com/questions/6190859/some-numpy-functions-return-ndarray-instead-of-my-subclass>on StackOverflow, I looked into adding/modifying __array_finalize__ 
and __array_wrap__<http://docs.scipy.org/doc/numpy/reference/arrays.classes.html>. 
Neither of these appear to be called when I call a scipy.ndimage method such 
as median_filter<http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.filters.median_filter.html>
.

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.

Thanks,
Keith


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


More information about the SciPy-User mailing list