#NEWLINE# @ patch ( 'nideep.datasets.nyudv2_to_lmdb.to_lmdb.caffe' ) #NEWLINE# @ patch ( 'nideep.datasets.nyudv2_to_lmdb.to_lmdb.caffe.proto.caffe_pb2.Datum' ) #NEWLINE# def test_nyudv2_to_lmdb_info( self , mock_dat , mock_caffe ) : #NEWLINE# #INDENT# mock_dat . return_value . SerializeToString . return_value = 'x' #NEWLINE# mock_caffe . io . array_to_datum . return_value = caffe . proto . caffe_pb2 . Datum ( ) #NEWLINE# x = np . array ( [ [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ] , [ [ 7 , 8 , 9 ] , [ 10 , 11 , 12 ] ] , [ [ 13 , 14 , 15 ] , [ 16 , 17 , 18 ] ] , [ [ 19 , 20 , 21 ] , [ 22 , 23 , 24 ] ] ] ) #NEWLINE# imgs = np . expand_dims ( x , axis = 1 ) . astype ( float ) #NEWLINE# imgs = np . tile ( imgs , ( 3 , 1 , 1 ) ) #NEWLINE# dat = { #NEWLINE# #INDENT# n2l . NYUDV2DataType . IMAGES : imgs , #NEWLINE# n2l . NYUDV2DataType . LABELS : ( x . astype ( int ) + 1 ) , #NEWLINE# n2l . NYUDV2DataType . DEPTHS : ( x . astype ( float ) + 2 ) , #NEWLINE# #UNINDENT# } #NEWLINE# p = os . path . join ( self . dir_tmp , 'foo.mat' ) #NEWLINE# io . savemat ( p , dat ) #NEWLINE# prefix = 'xyz_' #NEWLINE# lmdb_info = n2l . nyudv2_to_lmdb ( p , prefix , self . dir_tmp ) #NEWLINE# assert_is_instance ( lmdb_info , list ) #NEWLINE# for info_ in lmdb_info : #NEWLINE# #INDENT# n = info_ [ 0 ] #NEWLINE# plmdb = info_ [ ( - 1 ) ] #NEWLINE# assert_true ( os . path . isdir ( plmdb ) ) #NEWLINE# if ( 'val' in os . path . basename ( plmdb ) ) : #NEWLINE# #INDENT# assert_equal ( prefix , 0 )