#NEWLINE# def stack_view( shape , * views ) : #NEWLINE# #INDENT# shp = tuple ( ( slice ( 0 , s , 1 ) for s in shape ) ) #NEWLINE# result = np . broadcast_arrays ( * np . ogrid [ shp ] ) #NEWLINE# for v in views : #NEWLINE# #INDENT# if ( isinstance ( v , string_types ) and ( v == 'transpose' ) ) : #NEWLINE# #INDENT# result = [ r . T for r in result ] #NEWLINE# continue #NEWLINE# #UNINDENT# result = [ r [ v ] for r in result ] #NEWLINE# #UNINDENT# return tuple ( result )