#NEWLINE# def __init__( self , input_broadcastable , new_order , inplace = False ) : #NEWLINE# #INDENT# input_broadcastable = tuple ( input_broadcastable ) #NEWLINE# self . input_broadcastable = input_broadcastable #NEWLINE# new_order = tuple ( new_order ) #NEWLINE# self . new_order = new_order #NEWLINE# self . inplace = inplace #NEWLINE# for ( i , j ) in enumerate ( new_order ) : #NEWLINE# #INDENT# if ( j != 'x' ) : #NEWLINE# #INDENT# if ( not isinstance ( j , ( int , numpy . integer ) ) ) : #NEWLINE# #INDENT# raise TypeError ( 'DimShuffle indices must be python ints.' ) #NEWLINE# #UNINDENT# if ( j >= len ( input_broadcastable ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'new_order[%d] is %d, but the input only has %d axes.' % ( i , j , len ( input_broadcastable ) ) ) ) #NEWLINE# #UNINDENT# if ( j in new_order [ ( i + 1 ) : ] ) : #NEWLINE# #INDENT# raise ValueError ( 'The same input dimension may not appear twice in the list of output dimensions' , new_order ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . drop = [ ] #NEWLINE# for ( i , b ) in enumerate ( input_broadcastable ) : #NEWLINE# #INDENT# if ( i not in new_order ) : #NEWLINE# #INDENT# if ( b == 1 ) : #NEWLINE# #INDENT# self . drop . append ( i ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'You cannot drop a non-broadcastable dimension.' , ( input_broadcastable , new_order ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . shuffle = [ x for x in new_order if ( x != 'x' ) ] #NEWLINE# self . augment = [ i for ( i , x ) in enumerate ( new_order ) if ( x == 'x' ) ] #NEWLINE# if self . inplace : #NEWLINE# #INDENT# self . view_map = { #NEWLINE# #INDENT# 0 : [ 0 ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# self . _rehash ( )