[SciPy-User] Telling the difference between new from template and view casting in __array_finalize__

Kiyoshi Masui kiyo at cita.utoronto.ca
Tue Apr 5 12:10:29 EDT 2011


Hi all,

When sub classing an array, how do you tell the difference between 'view 
casting' and 'new from template' in `__array_finalize__`?  The document 
here: http://docs.scipy.org/doc/numpy/user/basics.subclassing.html 
states that the second argument to `__array_finalize__` is always an 
instance of my subclass for 'new from template' but for
operations like `A = NewArrayClass(sp.zeros(5)).view(NewArrayClass)`, 
this second argument will also be an instance of my subclass for view 
casting.  Is there a way to tell these apart?

Thanks,
Kiyo



More information about the SciPy-User mailing list