(X, copy=False)
return X_array
Input validation for collections of persistence diagrams.

    Basic type and sanity checks are run on the input collection and the
    array is converted to float type before returning. In particular,
    the input is checked to be an ndarray of shape ``(n_samples, n_points,
    3)``.

    Parameters
    ----------
    X : object
        Input object to check/convert.

    copy : bool, optional, default: ``False``
        Whether a forced copy should be triggered.

    Returns
    -------
    X_validated : ndarray of shape (n_samples, n_points, 3)
        The converted and validated array of persistence diagrams.
Input validation for collections of persistence diagrams.
Input validation for collections of persistence diagrams .
def check_diagrams(X, copy=False):
    """Input validation for collections of persistence diagrams.

    Basic type and sanity checks are run on the input collection and the
    array is converted to float type before returning. In particular,
    the input is checked to be an ndarray of shape ``(n_samples, n_points,
    3)``.

    Parameters
    ----------
    X : object
        Input object to check/convert.

    copy : bool, optional, default: ``False``
        Whether a forced copy should be triggered.

    Returns
    -------
    X_validated : ndarray of shape (n_samples, n_points, 3)
        The converted and validated array of persistence diagrams.

    """
    X_array = _check_array_mod(X, ensure_2d=False, allow_nd=True,
                               force_all_finite=False, copy=copy)
    if X_array.ndim != 3:
        raise ValueError(
            f"Input should be a 3D ndarray, the shape is {X_array.shape}."
            )
    if X_array.shape[2] != 3:
        raise ValueError(
            f"Input should be a 3D ndarray with a 3rd dimension of 3 "
            f"components, but there are {X_array.shape[2]} components."
            )

    homology_dimensions = sorted(np.unique(X_array[0, :, 2]))
    for dim in homology_dimensions:
        if dim == np.inf:
            if len(homology_dimensions) != 1:
                raise ValueError(
                    f"numpy.inf is a valid homology dimension for a stacked "
                    f"diagram but it should be the only one: "
                    f"homology_dimensions = {homology_dimensions}."
                    )
        else:
            if (dim != int(dim)) or (dim < 0):
                raise ValueError(
                    f"Homology dimensions should be positive integers or "
                    f"numpy.inf: {dim} can't be cast to an int of the same "
                    f"value."
                    )

    n_points_below_diag = np.sum(X_array[:, :, 1] < X_array[:, :, 0])
    if n_points_below_diag:
        raise ValueError(
            f"All points of all persistence diagrams should be above the "
            f"diagonal, i.e. X[:, :, 1] >= X[:, :, 0]. {n_points_below_diag} "
            f"points are below the diagonal."
            )

    return X_array
def check_diagrams ( X , copy = False ) : X_array = _check_array_mod ( X , ensure_2d = False , allow_nd = True , force_all_finite = False , copy = copy ) if X_array . ndim != 3 : raise ValueError ( f"Input should be a 3D ndarray, the shape is {X_array.shape}." ) if X_array . shape [ 2 ] != 3 : raise ValueError ( f"Input should be a 3D ndarray with a 3rd dimension of 3 " f"components, but there are {X_array.shape[2]} components." ) homology_dimensions = sorted ( np . unique ( X_array [ 0 , : , 2 ] ) ) for dim in homology_dimensions : if dim == np . inf : if len ( homology_dimensions ) != 1 : raise ValueError ( f"numpy.inf is a valid homology dimension for a stacked " f"diagram but it should be the only one: " f"homology_dimensions = {homology_dimensions}." ) else : if ( dim != int ( dim ) ) or ( dim < 0 ) : raise ValueError ( f"Homology dimensions should be positive integers or " f"numpy.inf: {dim} can't be cast to an int of the same " f"value." ) n_points_below_diag = np . sum ( X_array [ : , : , 1 ] < X_array [ : , : , 0 ] ) if n_points_below_diag : raise ValueError ( f"All points of all persistence diagrams should be above the " f"diagonal, i.e. X[:, :, 1] >= X[:, :, 0]. {n_points_below_diag} " f"points are below the diagonal." ) return X_array