#NEWLINE# def test_np_format_as_vector2conv2d( ) : #NEWLINE# #INDENT# vector_space = VectorSpace ( dim = ( ( 8 * 8 ) * 3 ) , sparse = False ) #NEWLINE# conv2d_space = Conv2DSpace ( shape = ( 8 , 8 ) , num_channels = 3 , axes = ( 'b' , 'c' , 0 , 1 ) ) #NEWLINE# data = np . arange ( ( ( ( 5 * 8 ) * 8 ) * 3 ) ) . reshape ( 5 , ( ( 8 * 8 ) * 3 ) ) #NEWLINE# rval = vector_space . np_format_as ( data , conv2d_space ) #NEWLINE# new_axes = conv2d_space . default_axes #NEWLINE# axis_to_shape = { #NEWLINE# #INDENT# 'b' : 5 , #NEWLINE# 'c' : 3 , #NEWLINE# 0 : 8 , #NEWLINE# 1 : 8 , #NEWLINE# #UNINDENT# } #NEWLINE# new_shape = tuple ( [ axis_to_shape [ ax ] for ax in new_axes ] ) #NEWLINE# nval = data . reshape ( new_shape ) #NEWLINE# nval = nval . transpose ( * [ new_axes . index ( ax ) for ax in conv2d_space . axes ] ) #NEWLINE# assert np . all ( ( rval == nval ) )