<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import numpy <EOL> import numba . unittest_support as unittest <EOL> from numba . compiler import compile_isolated , Flags <EOL> from numba import utils , jit <EOL> from . support import TestCase <EOL> def complex_constant ( n ) : <EOL> tmp = n + <NUM_LIT:4> <EOL> return tmp + <NUM_LIT> <EOL> def long_constant ( n ) : <EOL> return n + <NUM_LIT> <EOL> forceobj = Flags ( ) <EOL> forceobj . set ( "<STR_LIT>" ) <EOL> def loop_nest_3 ( x , y ) : <EOL> n = <NUM_LIT:0> <EOL> for i in range ( x ) : <EOL> for j in range ( y ) : <EOL> for k in range ( x + y ) : <EOL> n += i * j <EOL> return n <EOL> def array_of_object ( x ) : <EOL> return x <EOL> class TestObjectMode ( TestCase ) : <EOL> def test_complex_constant ( self ) : <EOL> pyfunc = complex_constant <EOL> cres = compile_isolated ( pyfunc , ( ) , flags = forceobj ) <EOL> cfunc = cres . entry_point <EOL> self . assertPreciseEqual ( pyfunc ( <NUM_LIT:12> ) , cfunc ( <NUM_LIT:12> ) ) <EOL> def test_long_constant ( self ) : <EOL> pyfunc = long_constant <EOL> cres = compile_isolated ( pyfunc , ( ) , flags = forceobj ) <EOL> cfunc = cres . entry_point <EOL> self . assertPreciseEqual ( pyfunc ( <NUM_LIT:12> ) , cfunc ( <NUM_LIT:12> ) ) <EOL> def test_loop_nest ( self ) : <EOL> """<STR_LIT>""" <EOL> pyfunc = loop_nest_3 <EOL> cres = compile_isolated ( pyfunc , ( ) , flags = forceobj ) <EOL> cfunc = cres . entry_point <EOL> self . assertEqual ( pyfunc ( <NUM_LIT:5> , <NUM_LIT:5> ) , cfunc ( <NUM_LIT:5> , <NUM_LIT:5> ) ) <EOL> def bm_pyfunc ( ) : <EOL> pyfunc ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> def bm_cfunc ( ) : <EOL> cfunc ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> print ( utils . benchmark ( bm_pyfunc ) ) <EOL> print ( utils . benchmark ( bm_cfunc ) ) <EOL> def test_array_of_object ( self ) : <EOL> cfunc = jit ( array_of_object ) <EOL> objarr = numpy . array ( [ object ( ) ] * <NUM_LIT:10> ) <EOL> self . assertIs ( cfunc ( objarr ) , objarr ) <EOL> def test_sequence_contains ( self ) : <EOL> """<STR_LIT>""" <EOL> @ jit ( forceobj = True ) <EOL> def foo ( x , y ) : <EOL> return x in y <EOL> self . assertTrue ( foo ( <NUM_LIT:1> , [ <NUM_LIT:0> , <NUM_LIT:1> ] ) ) <EOL> self . assertTrue ( foo ( <NUM_LIT:0> , [ <NUM_LIT:0> , <NUM_LIT:1> ] ) ) <EOL> self . assertFalse ( foo ( <NUM_LIT:2> , [ <NUM_LIT:0> , <NUM_LIT:1> ] ) ) <EOL> with self . assertRaises ( TypeError ) as raises : <EOL> foo ( None , None ) <EOL> self . assertIn ( "<STR_LIT>" , str ( raises . exception ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
