[Numpy-discussion] User-defined metadata in dtype
Lluís
xscript at gmx.net
Wed Jul 7 15:09:23 EDT 2010
I've been trying to embed extra information into dtype, such that whether I have
structured arrays or not, I can alwas have access to:
* A name of the field.
This is already present on structured arrays, but lost whenever you access a
field.
* A description of the field.
Tried to build a dtype with 'titles', but there can be no repeated titles,
which is not always possible.
* Units of the field.
By using __array_wrap__ I could always carry along the current units of the
information on every field of the structured array (or the units of the
array if it's a plain ndarray) with a package like 'units'.
My current implementation uses __array_wrap__, __getitem__ and __setitem__ to
maintain these fields, but I'm still not sure if that information should better
reside inside dtype itself (I've tried to subclass and monkeypatch dtype from
python with no success).
My intent is to maintain all that information for later retrieval when plotting
it into figures.
Read you,
Lluis
--
"And it's much the same thing with knowledge, for whenever you learn
something new, the whole world becomes that much richer."
-- The Princess of Pure Reason, as told by Norton Juster in The Phantom
Tollbooth
More information about the NumPy-Discussion
mailing list