<s> from ctypes import ( <EOL> Structure , <EOL> c_ubyte , <EOL> c_uint , <EOL> c_ulong , <EOL> c_ulonglong , <EOL> c_ushort , <EOL> sizeof , <EOL> ) <EOL> import numpy as np <EOL> import pandas as pd <EOL> from six . moves import range <EOL> _inttypes_map = { <EOL> sizeof ( t ) - <NUM_LIT:1> : t for t in { <EOL> c_ubyte , <EOL> c_uint , <EOL> c_ulong , <EOL> c_ulonglong , <EOL> c_ushort <EOL> } <EOL> } <EOL> _inttypes = list ( <EOL> pd . Series ( _inttypes_map ) . reindex ( <EOL> range ( max ( _inttypes_map . keys ( ) ) ) , <EOL> method = '<STR_LIT>' , <EOL> ) , <EOL> ) <EOL> def enum ( option , * options ) : <EOL> """<STR_LIT>""" <EOL> options = ( option , ) + options <EOL> rangeob = range ( len ( options ) ) <EOL> try : <EOL> inttype = _inttypes [ int ( np . log2 ( len ( options ) - <NUM_LIT:1> ) ) // <NUM_LIT:8> ] <EOL> except IndexError : <EOL> raise OverflowError ( <EOL> '<STR_LIT>' % <EOL> len ( options ) , <EOL> ) <EOL> class _enum ( Structure ) : <EOL> _fields_ = [ ( o , inttype ) for o in options ] <EOL> def __iter__ ( self ) : <EOL> return iter ( rangeob ) <EOL> def __contains__ ( self , value ) : <EOL> return <NUM_LIT:0> <= value < len ( options ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( <EOL> ( '<STR_LIT>' % len ( options ) ) <EOL> if len ( options ) > <NUM_LIT:10> else <EOL> repr ( options ) <EOL> ) <EOL> return _enum ( * rangeob ) </s>
