def sum_shapes(shapes):
 rows = max([shape[0] for shape in shapes])
 cols = max([shape[1] for shape in shapes])
 for shape in shapes:
  if ((not (shape == (1, 1))) and (shape != (rows, cols))):
   raise ValueError(('Incompatible dimensions' + ((len(shapes) * ' %s') % tuple(shapes))))
 return (rows, cols)

def sum_shapes ( shapes ) : rows = max ( [ shape [ 0 ] for shape in shapes ] ) cols = max ( [ shape [ 1 ] for shape in shapes ] ) for shape in shapes : if ( ( not ( shape == ( 1 , 1 ) ) ) and ( shape != ( rows , cols ) ) ) : raise ValueError ( ( 'Incompatible dimensions' + ( ( len ( shapes ) * ' %s' ) % tuple ( shapes ) ) ) ) return ( rows , cols )
give the shape resulting from summing a list of shapes .