[Numpy-discussion] Subclassing ndarray

Fabrice Silva silva@lma.cnrs-mrs...
Fri Nov 18 10:34:14 CST 2011


Hi,
I wish I could subclass ndarray so that I can use the ufuncs, but that I
could ensure the array remains Fortran contiguous, and that the number
of dimension is always 3 (even if the dtype can be more complex than a
simple numerical type).

My intention is to deal with fields that can be scalar, vectorial or
even tensorial, but it must stay compatible with a library we are using
that assumes 3D problems with column-major order, and some more
attributes concerning spatial steps, strides and comments...

I have been looking at __array_{wrap, prepare, finalize}__ methods. I
would believe __array_prepare__ would be the good starting point to
impose the 'F'-ordered array and atleast_3d, but the point is that I
don't know at that time if the ufunc will transform the datatype (from
vector to scalar, from int to float, etc...)

Some thought?
Regards
-- 
Fabrice Silva



More information about the NumPy-Discussion mailing list