#NEWLINE# @ patch ( 'nideep.eval.inference.caffe.Net' ) #NEWLINE# def test_infer_to_lmdb_fixed_dims( self , mock_net ) : #NEWLINE# #INDENT# b = { k : Bunch ( data = np . random . rand ( 1 , 1 , 3 , 2 ) ) for k in [ 'x' , 'y' , 'z' ] } #NEWLINE# mock_net . return_value . forward . return_value = np . zeros ( 1 ) #NEWLINE# type ( mock_net . return_value ) . blobs = PropertyMock ( return_value = b ) #NEWLINE# net = mock_net ( ) #NEWLINE# dst_prefix = os . path . join ( self . dir_tmp , 'test_infer_to_lmdb_fixed_dims_%s_lmdb' ) #NEWLINE# for k in b . keys ( ) : #NEWLINE# #INDENT# assert_false ( os . path . isdir ( ( dst_prefix % k ) ) ) #NEWLINE# #UNINDENT# out = infr . infer_to_lmdb ( net , [ 'x' , 'z' ] , 1 , dst_prefix ) #NEWLINE# assert_equal ( net . forward . call_count , 1 ) #NEWLINE# assert_list_equal ( out , [ 1 , 1 ] ) #NEWLINE# for k in b . keys ( ) : #NEWLINE# #INDENT# if ( k in [ 'x' , 'z' ] ) : #NEWLINE# #INDENT# assert_true ( os . path . isdir ( ( dst_prefix % out ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert_false ( os . path . isdir ( ( dst_prefix % k ) ) )