#NEWLINE# @ classmethod #NEWLINE# def concat( cls , variables , dim = 'concat_dim' , positions = None , shortcut = False ) : #NEWLINE# #INDENT# 'Concatenate variables along a new or existing dimension.\n\n        Parameters\n        ----------\n        variables : iterable of Array\n            Arrays to stack together. Each variable is expected to have\n            matching dimensions and shape except for along the stacked\n            dimension.\n        dim : str or DataArray, optional\n            Name of the dimension to stack along. This can either be a new\n            dimension name, in which case it is added along axis=0, or an\n            existing dimension name, in which case the location of the\n            dimension is unchanged. Where to insert the new dimension is\n            determined by the first variable.\n        positions : None or list of integer arrays, optional\n            List of integer arrays which specifies the integer positions to which\n            to assign each dataset along the concatenated dimension. If not\n            supplied, objects are concatenated in the provided order.\n        shortcut : bool, optional\n            This option is used internally to speed-up groupby operations.\n            If `shortcut` is True, some checks of internal consistency between\n            arrays to concatenate are skipped.\n\n        Returns\n        -------\n        stacked : Variable\n            Concatenated Variable formed by stacking all the supplied variables\n            along the given dimension.\n        ' #NEWLINE# if ( not isinstance ( dim , basestring ) ) : #NEWLINE# #INDENT# ( dim , ) = dim . dims #NEWLINE# #UNINDENT# variables = list ( variables ) #NEWLINE# first_var = variables [ 0 ] #NEWLINE# arrays = [ v . data for v in variables ] #NEWLINE# if ( dim in first_var . dims ) : #NEWLINE# #INDENT# axis = first_var . get_axis_num ( dim ) #NEWLINE# dims = first_var . dims #NEWLINE# if ( positions is None ) : #NEWLINE# #INDENT# data = ops . concatenate ( arrays , axis = axis ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = ops . interleaved_concat ( attrs , positions , axis = axis ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# axis = 0 #NEWLINE# dims = ( ( dim , ) + first_var . dims ) #NEWLINE# data = ops . stack ( arrays , axis = axis ) #NEWLINE# #UNINDENT# attrs = OrderedDict ( first_var . attrs ) #NEWLINE# if ( not shortcut ) : #NEWLINE# #INDENT# for var in variables : #NEWLINE# #INDENT# if ( var . dims != first_var . dims ) : #NEWLINE# #INDENT# raise ValueError ( 'inconsistent dimensions' ) #NEWLINE# #UNINDENT# utils . remove_incompatible_items ( attrs , var . attrs ) #NEWLINE# #UNINDENT# #UNINDENT# return cls ( dims , data , attrs )