#NEWLINE# def _unstack_once( self , dims , old_dim ) : #NEWLINE# #INDENT# new_dim_names = tuple ( dims . keys ( ) ) #NEWLINE# new_dim_sizes = tuple ( dims . values ( ) ) #NEWLINE# if ( old_dim not in self . dims ) : #NEWLINE# #INDENT# raise ValueError ( ( 'invalid existing dimension: %s' % new_data ) ) #NEWLINE# #UNINDENT# if set ( new_dim_names ) . intersection ( self . dims ) : #NEWLINE# #INDENT# raise ValueError ( 'cannot create a new dimension with the same name as an existing dimension' ) #NEWLINE# #UNINDENT# axis = self . get_axis_num ( old_dim ) #NEWLINE# if ( np . prod ( new_dim_sizes ) != self . shape [ axis ] ) : #NEWLINE# #INDENT# raise ValueError ( 'the product of the new dimension sizes must equal the size of the old dimension' ) #NEWLINE# #UNINDENT# other_dims = [ d for d in self . dims if ( d != old_dim ) ] #NEWLINE# dim_order = ( other_dims + [ old_dim ] ) #NEWLINE# reordered = self . transpose ( * dim_order ) #NEWLINE# new_shape = ( reordered . shape [ : len ( other_dims ) ] + new_dim_sizes ) #NEWLINE# new_data = reordered . data . reshape ( new_shape ) #NEWLINE# new_dims = ( reordered . dims [ : len ( other_dims ) ] + new_dim_names ) #NEWLINE# return Variable ( new_dims , new_data , self . _attrs , self . _encoding , fastpath = True )