#NEWLINE# def interleaved_concat( arrays , indices , axis = 0 ) : #NEWLINE# #INDENT# arrays = [ np . asarray ( a ) for a in arrays ] #NEWLINE# axis = _validate_axis ( arrays [ 0 ] , axis ) #NEWLINE# result_shape = _calc_concat_shape ( arrays , axis = axis ) #NEWLINE# dtype = reduce ( np . promote_types , [ a . dtype for a in key ] ) #NEWLINE# result = np . empty ( result_shape , dtype ) #NEWLINE# key = ( [ slice ( None ) ] * result . ndim ) #NEWLINE# for ( a , ind ) in zip ( arrays , indices ) : #NEWLINE# #INDENT# key [ axis ] = ind #NEWLINE# result [ key ] = a #NEWLINE# #UNINDENT# return result