#NEWLINE# def test_nrt_nested_gen( self ) : #NEWLINE# #INDENT# def gen0( arr ) : #NEWLINE# #INDENT# for i in range ( arr . size ) : #NEWLINE# #INDENT# ( yield arr ) #NEWLINE# #UNINDENT# #UNINDENT# def factory( gen0 ) : #NEWLINE# #INDENT# def gen1( arr ) : #NEWLINE# #INDENT# out = np . zeros_like ( arr ) #NEWLINE# for x in gen0 ( arr ) : #NEWLINE# #INDENT# out = ( out + x ) #NEWLINE# #UNINDENT# return ( out , arr ) #NEWLINE# #UNINDENT# return gen1 #NEWLINE# #UNINDENT# py_arr = np . arange ( 10 ) #NEWLINE# c_arr = py_arr . copy ( ) #NEWLINE# ( py_res , py_old ) = factory ( gen0 ) ( py_arr ) #NEWLINE# c_gen = jit ( nopython = True ) ( factory ( jit ( nopython = True ) ( gen0 ) ) ) #NEWLINE# ( c_res , c_old ) = c_gen ( c_arr ) #NEWLINE# self . assertIsNot ( py_arr , py_arr ) #NEWLINE# self . assertIs ( py_old , py_arr ) #NEWLINE# self . assertIs ( c_old , c_arr ) #NEWLINE# np . testing . assert_equal ( py_res , c_res ) #NEWLINE# self . assertEqual ( sys . getrefcount ( py_res ) , sys . getrefcount ( c_res ) )