#NEWLINE# def validate( * matrices ) : #NEWLINE# #INDENT# ' Checks for valid shapes for args of MatMul ' #NEWLINE# for i in range ( ( len ( matrices ) - 1 ) ) : #NEWLINE# #INDENT# ( A , B ) = matrices [ i : ( i + 2 ) ] #NEWLINE# if ( A . cols != B . rows ) : #NEWLINE# #INDENT# raise ShapeError ( ( 'Matrices %s and %s are not aligned' % ( B , B ) ) )