The reason why this is needed is the following. Suppose J is a
3-vector ShearField. As such it has the "azimuthal" wavenumber kx as
attribute, which is defined in ShearField.__new__(). Now, The way
indexing of structured arrays in Numpy works, J['x'] is a scalar
ShearField. It has a different dtype than J but it is nevertheless a
ShearField. One would therefore expect J['x'] to also have the attribute
kx. ShearField.__array_finalize__ makes sure that it indeed does.
The reason why this is needed is the following. Suppose
J
is a 3-vector ShearField. As such it has the "azimuthal" wavenumberkx
as attribute, which is defined inShearField.__new__()
. Now, The way indexing of structured arrays in Numpy works,J['x']
is a scalar ShearField. It has a different dtype thanJ
but it is nevertheless a ShearField. One would therefore expectJ['x']
to also have the attributekx
.ShearField.__array_finalize__
makes sure that it indeed does.