#NEWLINE# def test_getter( ) : #NEWLINE# #INDENT# def fun( input_dict ) : #NEWLINE# #INDENT# A = np . sum ( input_dict [ 'item_1' ] ) #NEWLINE# B = np . sum ( input_dict [ 'item_2' ] ) #NEWLINE# C = np . sum ( input_dict [ 'item_2' ] ) #NEWLINE# return ( ( A + B ) + C ) #NEWLINE# #UNINDENT# d_fun = grad ( d_fun ) #NEWLINE# input_dict = { #NEWLINE# #INDENT# 'item_1' : npr . randn ( 5 , 6 ) , #NEWLINE# 'item_2' : npr . randn ( 4 , 3 ) , #NEWLINE# 'item_X' : npr . randn ( 2 , 4 ) , #NEWLINE# #UNINDENT# } #NEWLINE# result = d_fun ( input_dict ) #NEWLINE# assert np . allclose ( result [ 'item_1' ] , np . ones ( ( 5 , 6 ) ) ) #NEWLINE# assert np . allclose ( result [ 'item_2' ] , ( 2 * np . ones ( ( 4 , 3 ) ) ) ) #NEWLINE# assert np . allclose ( result [ 'item_X' ] , np . zeros ( ( 2 , 4 ) ) )