Ejemplo n.º 1
0
def test_cubical_persistence_intervals_in_dimension():
    cub = CubicalComplex(
        dimensions=[3, 3],
        top_dimensional_cells=[1, 2, 3, 4, 5, 6, 7, 8, 9],
    )
    cub.compute_persistence()
    H0 = cub.persistence_intervals_in_dimension(0)
    assert np.array_equal(H0, np.array([[1., float("inf")]]))
    assert cub.persistence_intervals_in_dimension(1).shape == (0, 2)
Ejemplo n.º 2
0
def compute_cubical(data, hdim, finite_persistence = True):
    
    # compute filtration
    filtration_values = data.flatten()
    
    st = CubicalComplex(dimensions = data.shape, 
                        top_dimensional_cells = filtration_values)
    
    st.compute_persistence()
    
    # compute pd from filtration
    dgm = st.persistence_intervals_in_dimension(hdim)
    
    if finite_persistence:
        dgm = drop_inf_features(dgm)
        
    return dgm