[Numpy-discussion] draft enum NEP
David Gowers (kampu)
Fri Mar 9 16:48:42 CST 2012
On Sat, Mar 10, 2012 at 3:25 AM, Bryan Van de Ven <firstname.lastname@example.org> wrote:
> Hi all,
> I have started working on a NEP for adding an enumerated type to NumPy.
> It is on my GitHub:
> It is still very rough, and incomplete in places. But I would like to
> get feedback sooner rather than later in order to refine it. In
> particular there are a few questions inline in the document that I would
> like input on. Any comments, suggestions, questions, concerns, etc. are
> very welcome.
"t = np.dtype('enum', map=(n,v))"
^ Is this supposed to be indicating 'this is an enum with values
ranging between n and v'? It could be a bit more clear.
Is it possible to partially define an enum? That is, give the maximum
and minimum values, and only some of the enumeration value:name
For example, an enum where 0 means 'n/a', +n means 'Type A Object
#(n-1)' and -n means 'Type B Object #(abs(n) - 1)'. I just want to map
the non-scalar values, while having a way to avoid treating valid
scalar values (eg +64) as out-of-range.
Example of what I mean:
"t = np.dtype('enum[N_A:0]', range = (-127, 127))"
(defined values being printed as a string, undefined being printed as a number.)
More information about the NumPy-Discussion