def have_same_shape(array1, array2, nd_to_check=None):
shape1 = array1.shape<EOL>shape2 = array2.shape<EOL>if nd_to_check is not None:<EOL><INDENT>if len(shape1) < nd_to_check:<EOL><INDENT>msg = '<STR_LIT>'.format(shape1)<EOL>raise ValueError(msg)<EOL><DEDENT>elif len(shape2) < nd_to_check:<EOL><INDENT>msg = '<STR_LIT>'.format(shape2)<EOL>raise ValueError(msg)<EOL><DEDENT>shape1 = shape1[:nd_to_check]<EOL>shape2 = shape2[:nd_to_check]<EOL><DEDENT>return shape1 == shape2<EOL>
Returns true if array1 and array2 have the same shapes, false
otherwise.

Parameters
----------
array1: numpy.ndarray

array2: numpy.ndarray

nd_to_check: int
    Number of the dimensions to check, i.e., if == 3 then will check only the 3 first numbers of array.shape.
Returns
-------
bool