Validate that the matrix has equal number of rows and columns.

def validate_square(data, message=None, exception=MatrixError):
    """Validate that the matrix has equal number of rows and columns."""
    rows, columns = len(data), len(data[0]) if data else 0
    if message is None:
        message = 'Number of rows: %s != number of columns: %s in matrix' % (
            rows, columns)
    if rows != columns:
        raise exception(message)