<s> from __future__ import absolute_import <EOL> __version__ = "<STR_LIT>" <EOL> try : <EOL> from __builtin__ import basestring <EOL> except ImportError : <EOL> basestring = str <EOL> class _ArrayType ( object ) : <EOL> is_array = True <EOL> subtypes = [ '<STR_LIT>' ] <EOL> def __init__ ( self , dtype , ndim , is_c_contig = False , is_f_contig = False , <EOL> inner_contig = False , broadcasting = None ) : <EOL> self . dtype = dtype <EOL> self . ndim = ndim <EOL> self . is_c_contig = is_c_contig <EOL> self . is_f_contig = is_f_contig <EOL> self . inner_contig = inner_contig or is_c_contig or is_f_contig <EOL> self . broadcasting = broadcasting <EOL> def __repr__ ( self ) : <EOL> axes = [ "<STR_LIT::>" ] * self . ndim <EOL> if self . is_c_contig : <EOL> axes [ - <NUM_LIT:1> ] = "<STR_LIT>" <EOL> elif self . is_f_contig : <EOL> axes [ <NUM_LIT:0> ] = "<STR_LIT>" <EOL> return "<STR_LIT>" % ( self . dtype , "<STR_LIT:U+002CU+0020>" . join ( axes ) ) <EOL> def index_type ( base_type , item ) : <EOL> """<STR_LIT>""" <EOL> class InvalidTypeSpecification ( Exception ) : <EOL> pass <EOL> def verify_slice ( s ) : <EOL> if s . start or s . stop or s . step not in ( None , <NUM_LIT:1> ) : <EOL> raise InvalidTypeSpecification ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if isinstance ( item , tuple ) : <EOL> step_idx = None <EOL> for idx , s in enumerate ( item ) : <EOL> verify_slice ( s ) <EOL> if s . step and ( step_idx or idx not in ( <NUM_LIT:0> , len ( item ) - <NUM_LIT:1> ) ) : <EOL> raise InvalidTypeSpecification ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if s . step == <NUM_LIT:1> : <EOL> step_idx = idx <EOL> return _ArrayType ( base_type , len ( item ) , <EOL> is_c_contig = step_idx == len ( item ) - <NUM_LIT:1> , <EOL> is_f_contig = step_idx == <NUM_LIT:0> ) <EOL> elif isinstance ( item , slice ) : <EOL> verify_slice ( item ) <EOL> return _ArrayType ( base_type , <NUM_LIT:1> , is_c_contig = bool ( item . step ) ) <EOL> else : <EOL> assert int ( item ) == item <EOL> array ( base_type , item ) <EOL> compiled = False <EOL> _Unspecified = object ( ) <EOL> def _empty_decorator ( x ) : <EOL> return x <EOL> def locals ( ** arg_types ) : <EOL> return _empty_decorator <EOL> def test_assert_path_exists ( * paths ) : <EOL> return _empty_decorator <EOL> def test_fail_if_path_exists ( * paths ) : <EOL> return _empty_decorator <EOL> class _EmptyDecoratorAndManager ( object ) : <EOL> def __call__ ( self , x ) : <EOL> return x <EOL> def __enter__ ( self ) : <EOL> pass <EOL> def __exit__ ( self , exc_type , exc_value , traceback ) : <EOL> pass <EOL> class _Optimization ( object ) : <EOL> pass <EOL> cclass = ccall = cfunc = _EmptyDecoratorAndManager ( ) <EOL> returns = wraparound = boundscheck = initializedcheck = nonecheck = overflowcheck = embedsignature = cdivision = cdivision_warnings = always_allows_keywords = profile = linetrace = infer_type = unraisable_tracebacks = freelist = lambda arg : _EmptyDecoratorAndManager ( ) <EOL> optimization = _Optimization ( ) <EOL> overflowcheck . fold = optimization . use_switch = optimization . unpack_method_calls = lambda arg : _EmptyDecoratorAndManager ( ) <EOL> final = internal = type_version_tag = no_gc_clear = _empty_decorator <EOL> def inline ( f , * args , ** kwds ) : <EOL> if isinstance ( f , basestring ) : <EOL> from Cython . Build . Inline import cython_inline <EOL> return cython_inline ( f , * args , ** kwds ) <EOL> else : <EOL> assert len ( args ) == len ( kwds ) == <NUM_LIT:0> <EOL> return f <EOL> def compile ( f ) : <EOL> from Cython . Build . Inline import RuntimeCompiledFunction <EOL> return RuntimeCompiledFunction ( f ) <EOL> def cdiv ( a , b ) : <EOL> q = a / b <EOL> if q < <NUM_LIT:0> : <EOL> q += <NUM_LIT:1> <EOL> def cmod ( a , b ) : <EOL> r = a % b <EOL> if ( a * b ) < <NUM_LIT:0> : <EOL> r -= b <EOL> return r <EOL> def cast ( type , * args , ** kwargs ) : <EOL> kwargs . pop ( '<STR_LIT>' , None ) <EOL> assert not kwargs <EOL> if hasattr ( type , '<STR_LIT>' ) : <EOL> return type ( * args ) <EOL> else : <EOL> return args [ <NUM_LIT:0> ] <EOL> def sizeof ( arg ) : <EOL> return <NUM_LIT:1> <EOL> def typeof ( arg ) : <EOL> return arg . __class__ . __name__ <EOL> def address ( arg ) : <EOL> return pointer ( type ( arg ) ) ( [ arg ] ) <EOL> def declare ( type = None , value = _Unspecified , ** kwds ) : <EOL> if type not in ( None , object ) and hasattr ( type , '<STR_LIT>' ) : <EOL> if value is not _Unspecified : <EOL> return type ( value ) <EOL> else : <EOL> return type ( ) <EOL> else : <EOL> return value <EOL> class _nogil ( object ) : <EOL> """<STR_LIT>""" <EOL> def __enter__ ( self ) : <EOL> pass <EOL> def __exit__ ( self , exc_class , exc , tb ) : <EOL> return exc_class is None <EOL> nogil = _nogil ( ) <EOL> gil = _nogil ( ) <EOL> del _nogil <EOL> class CythonMetaType ( type ) : <EOL> def __getitem__ ( type , ix ) : <EOL> return array ( type , ix ) <EOL> CythonTypeObject = CythonMetaType ( '<STR_LIT>' , ( object , ) , { } ) <EOL> class CythonType ( CythonTypeObject ) : <EOL> def _pointer ( self , n = <NUM_LIT:1> ) : <EOL> for i in range ( n ) : <EOL> self = pointer ( self ) <EOL> return self <EOL> class PointerType ( CythonType ) : <EOL> def __init__ ( self , value = None ) : <EOL> if isinstance ( value , ( ArrayType , PointerType ) ) : <EOL> self . _items = [ cast ( self . _basetype , a ) for a in value . _items ] <EOL> elif isinstance ( value , list ) : <EOL> self . _items = [ cast ( self . _basetype , a ) for a in value ] <EOL> elif value is None or value == <NUM_LIT:0> : <EOL> self . _items = [ ] <EOL> else : <EOL> raise ValueError <EOL> def __getitem__ ( self , ix ) : <EOL> if ix < <NUM_LIT:0> : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> return self . _items [ ix ] <EOL> def __setitem__ ( self , ix , value ) : <EOL> if ix < <NUM_LIT:0> : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> self . _items [ ix ] = cast ( self . _basetype , value ) <EOL> def __eq__ ( self , value ) : <EOL> if value is None and not self . _items : <EOL> return True <EOL> elif type ( self ) != type ( value ) : <EOL> return False <EOL> else : <EOL> return not self . _items and not value . _items <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . _basetype , ) <EOL> class ArrayType ( PointerType ) : <EOL> def __init__ ( self ) : <EOL> self . _items = [ None ] * self . _n <EOL> class StructType ( CythonType ) : <EOL> def __init__ ( self , cast_from = _Unspecified , ** data ) : <EOL> if cast_from is not _Unspecified : <EOL> if len ( data ) > <NUM_LIT:0> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if type ( cast_from ) is not type ( self ) : <EOL> raise ValueError ( '<STR_LIT>' % cast_from ) <EOL> for key , value in cast_from . __dict__ . items ( ) : <EOL> setattr ( self , key , value ) <EOL> else : <EOL> for key , value in data . items ( ) : <EOL> setattr ( self , key , value ) <EOL> def __setattr__ ( self , key , value ) : <EOL> if key in self . _members : <EOL> self . __dict__ [ key ] = cast ( self . _members [ key ] , value ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" % key ) <EOL> class UnionType ( CythonType ) : <EOL> def __init__ ( self , cast_from = _Unspecified , ** data ) : <EOL> if cast_from is not _Unspecified : <EOL> if len ( data ) > <NUM_LIT:0> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if isinstance ( cast_from , dict ) : <EOL> datadict = cast_from <EOL> elif type ( cast_from ) is type ( self ) : <EOL> datadict = cast_from . __dict__ <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' % cast_from ) <EOL> else : <EOL> datadict = data <EOL> if len ( datadict ) > <NUM_LIT:1> : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> for key , value in datadict . items ( ) : <EOL> setattr ( self , key , value ) <EOL> def __setattr__ ( self , key , value ) : <EOL> if key in '<STR_LIT>' : <EOL> CythonType . __setattr__ ( self , key , value ) <EOL> elif key in self . _members : <EOL> self . __dict__ = { key : cast ( self . _members [ key ] , value ) } <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" % key ) <EOL> def pointer ( basetype ) : <EOL> class PointerInstance ( PointerType ) : <EOL> _basetype = basetype <EOL> return PointerInstance <EOL> def array ( basetype , n ) : <EOL> class ArrayInstance ( ArrayType ) : <EOL> _basetype = basetype <EOL> _n = n <EOL> return ArrayInstance <EOL> def struct ( ** members ) : <EOL> class StructInstance ( StructType ) : <EOL> _members = members <EOL> for key in members : <EOL> setattr ( StructInstance , key , None ) <EOL> return StructInstance <EOL> def union ( ** members ) : <EOL> class UnionInstance ( UnionType ) : <EOL> _members = members <EOL> for key in members : <EOL> setattr ( UnionInstance , key , None ) <EOL> return UnionInstance <EOL> class typedef ( CythonType ) : <EOL> def __init__ ( self , type , name = None ) : <EOL> self . _basetype = type <EOL> self . name = name <EOL> def __call__ ( self , * arg ) : <EOL> value = cast ( self . _basetype , * arg ) <EOL> return value <EOL> def __repr__ ( self ) : <EOL> return self . name or str ( self . _basetype ) <EOL> __getitem__ = index_type <EOL> class _FusedType ( CythonType ) : <EOL> pass <EOL> def fused_type ( * args ) : <EOL> if not args : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> rank = - <NUM_LIT:1> <EOL> for type in args : <EOL> if type not in ( py_int , py_long , py_float , py_complex ) : <EOL> break <EOL> if type_ordering . index ( type ) > rank : <EOL> result_type = type <EOL> else : <EOL> return result_type <EOL> return _FusedType ( ) <EOL> def _specialized_from_args ( signatures , args , kwargs ) : <EOL> "<STR_LIT>" <EOL> raise Exception ( "<STR_LIT>" ) <EOL> py_int = typedef ( int , "<STR_LIT:int>" ) <EOL> try : <EOL> py_long = typedef ( long , "<STR_LIT>" ) <EOL> except NameError : <EOL> py_long = typedef ( int , "<STR_LIT>" ) <EOL> py_float = typedef ( float , "<STR_LIT:float>" ) <EOL> py_complex = typedef ( complex , "<STR_LIT>" ) <EOL> int_types = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:int>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> float_types = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:float>' ] <EOL> complex_types = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> other_types = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> to_repr = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } . get <EOL> gs = globals ( ) <EOL> try : <EOL> import __builtin__ as builtins <EOL> except ImportError : <EOL> import builtins <EOL> gs [ '<STR_LIT>' ] = typedef ( getattr ( builtins , '<STR_LIT>' , str ) , '<STR_LIT>' ) <EOL> del builtins <EOL> for name in int_types : <EOL> reprname = to_repr ( name , name ) <EOL> gs [ name ] = typedef ( py_int , reprname ) <EOL> if name not in ( '<STR_LIT>' , '<STR_LIT>' ) and not name . endswith ( '<STR_LIT>' ) : <EOL> gs [ '<STR_LIT:u>' + name ] = typedef ( py_int , "<STR_LIT>" + reprname ) <EOL> gs [ '<STR_LIT:s>' + name ] = typedef ( py_int , "<STR_LIT>" + reprname ) <EOL> for name in float_types : <EOL> gs [ name ] = typedef ( py_float , to_repr ( name , name ) ) <EOL> for name in complex_types : <EOL> gs [ name ] = typedef ( py_complex , to_repr ( name , name ) ) <EOL> bint = typedef ( bool , "<STR_LIT>" ) <EOL> void = typedef ( int , "<STR_LIT>" ) <EOL> for t in int_types + float_types + complex_types + other_types : <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:4> ) : <EOL> gs [ "<STR_LIT>" % ( '<STR_LIT:p>' * i , t ) ] = globals ( ) [ t ] . _pointer ( i ) <EOL> void = typedef ( None , "<STR_LIT>" ) <EOL> NULL = p_void ( <NUM_LIT:0> ) <EOL> integral = floating = numeric = _FusedType ( ) <EOL> type_ordering = [ py_int , py_long , py_float , py_complex ] <EOL> class CythonDotParallel ( object ) : <EOL> """<STR_LIT>""" <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def parallel ( self , num_threads = None ) : <EOL> return nogil <EOL> def prange ( self , start = <NUM_LIT:0> , stop = None , step = <NUM_LIT:1> , schedule = None , nogil = False ) : <EOL> if stop is None : <EOL> stop = start <EOL> start = <NUM_LIT:0> <EOL> return range ( start , stop , step ) <EOL> def threadid ( self ) : <EOL> return <NUM_LIT:0> <EOL> import sys <EOL> sys . modules [ '<STR_LIT>' ] = CythonDotParallel ( ) <EOL> del sys </s>
