def _check_dimensionality(matrix):
    """
    Checks whether the input is a 2D array (matrix) and square.
    By @t-kimber.

    Parameters
    ----------
    matrix : np.array
        The matrix for which the condition should be checked.

    Returns
    -------
    bool :
        True if the condition is met, False otherwise.
    """
    if len(matrix.shape) != 2:
        raise ValueError(f"The input is not a matrix, but an array of shape {matrix.shape}.")
    elif matrix.shape[0] != matrix.shape[1]:
        raise ValueError("The input is not a square matrix. Failing.")
    else:
        return True