[Numpy-discussion] ndarray newbie question
pgmdevlist at gmail.com
Thu Jan 4 15:33:39 EST 2007
> > However, even record
> > arrays don't have a keys() method.
You can access the attributes of a recarray by
which is yet another dictproxy.
> Some context: the type of introspection I'm often wishing I could do
> in a single, easy command usually has to do w/getting to know the
> software better.
> Regarding numpy ndarrays, if I were to write my own viewer, what
> internal variables make the most sense to show? Are .ndim, .size,
> and .shape the only ones I should care about?
shape and dtype at minimum, I'd say.
ndim is just the length of the shape tuple, size the product of the terms in
the shape tuple, so you don't really need them for displaying results.
That's basically how you define a ndarray: give it a shape and a dtype, and
that's enough to allocate the corresponding memory. Your array might be
empty, but you can always fill it later.
More information about the NumPy-Discussion