def _check_square(matrix):
    """Raise a ValueError if the input matrix is square.

    Parameters
    ----------
    matrix : numpy.ndarray
        Input array.
    """
    if matrix.ndim != 2 or matrix.shape[0] != matrix.shape[-1]:
        raise ValueError('Expected a square matrix, got array of shape {0}.'
            .format(matrix.shape))
