[Numpy-discussion] draft enum NEP

Stéfan van der Walt stefan@sun.ac...
Thu Mar 15 20:02:23 CDT 2012


On Thu, Mar 15, 2012 at 4:02 PM, Nathaniel Smith <njs@pobox.com> wrote:
> I'm not sure what it would even mean to treat this kind of data as
> "flags", since you can't take the bitwise-or of two strings...

This makes a more sense outside of ndarrays, where you would do something like:

enum FLAG0 = 1, FLAG1 = 2, FLAG2 = 4
do_something(data, mode=FLAG0 & FLAG2)

The enum is therefore just a handle for its numerical value.  While it
may not be that useful in an array, I think Mark was just pointing out
that there may be other similar use cases, such as enumerating from 0
to N-1, or in reverse from N-1 down to 0, or in steps of 2, or in
powers of 2, etc.

Stéfan


More information about the NumPy-Discussion mailing list