#NEWLINE# def _auto_concat( datasets , dim = None ) : #NEWLINE# #INDENT# if ( len ( datasets ) == 1 ) : #NEWLINE# #INDENT# return datasets [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( d is None ) : #NEWLINE# #INDENT# ds0 = datasets [ 0 ] #NEWLINE# ds1 = datasets [ 1 ] #NEWLINE# concat_dims = set ( ds0 . dims ) #NEWLINE# if ( ds0 . dims != ds1 . dims ) : #NEWLINE# #INDENT# dim_tuples = ( set ( ds0 . dims . items ( ) ) - set ( ds1 . dims . items ( ) ) ) #NEWLINE# concat_dims = set ( ( i for ( i , _ ) in dim_tuples ) ) #NEWLINE# #UNINDENT# if ( len ( concat_dims ) > 1 ) : #NEWLINE# #INDENT# concat_dims = set ( ( d for d in concat_dims if ( not ds0 [ d ] . equals ( ds1 [ d ] ) ) ) ) #NEWLINE# #UNINDENT# if ( len ( concat_dims ) > 1 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'too many different dimensions to concatenate: %s' % concat_dims ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( concat_dims ) == 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'cannot infer dimension to concatenate: supply the ``concat_dim`` argument explicitly' ) #NEWLINE# #UNINDENT# #UNINDENT# ( dim , ) = concat_dims #NEWLINE# #UNINDENT# return concat ( datasets , dim = dim )