Giter Club home page Giter Club logo

Comments (4)

ulupo avatar ulupo commented on May 20, 2024

A preliminary approach is in ulupo#1

from giotto-ph.

MonkeyBreaker avatar MonkeyBreaker commented on May 20, 2024

Maybe we could add the diamond example and the output when running in sparse and dense, where we can observe an unexpected difference ?

from giotto-ph.

ulupo avatar ulupo commented on May 20, 2024

@MonkeyBreaker indeed. Here goes:

import numpy as np
from gph.python import ripser_parallel

diamond_dm = np.array(
    [[0,      1,      np.inf, 1,      1,      1],
     [0,      0,      1,      np.inf, 1,      1],
     [0,      0,      0,      1,      1,      1],
     [0,      0,      0,      0,      1,      1],
     [0,      0,      0,      0,      0,      np.inf],
     [0,      0,      0,      0,      0,      0]],
    dtype=np.float64
)
diamond_dm += diamond_dm.T

res = ripser_parallel(diamond_dm, metric="precomputed", maxdim=2, return_generators=True)

yields the correct barcode

[array([[ 0.,  1.],
        [ 0.,  1.],
        [ 0.,  1.],
        [ 0.,  1.],
        [ 0.,  1.],
        [ 0., inf]]),
 array([], shape=(0, 2), dtype=float64),
 array([[ 1., inf]])]

but the incorrect generators

(array([[5, 5, 3],
       [3, 5, 2],
       [2, 5, 1],
       [1, 5, 0],
       [4, 4, 3]], dtype=int64),
 [array([], shape=(0, 4), dtype=int64), array([[1, 0, 5, 4]], dtype=int64)],
 array([0], dtype=int64),
 [array([], shape=(0, 2), dtype=int64), array([], shape=(0, 2), dtype=int64)])

The sparse version

from scipy.sparse import coo_matrix

diamond_dm = np.where(diamond_dm == np.inf, 0, diamond_dm)
diamond_dm = coo_matrix(diamond_dm)

gives the correct

(array([[5, 5, 3],
       [3, 5, 2],
       [2, 5, 1],
       [1, 5, 0],
       [4, 4, 3]], dtype=int64),
 [array([], shape=(0, 4), dtype=int64), array([], shape=(0, 4), dtype=int64)],
 array([0], dtype=int64),
 [array([], shape=(0, 2), dtype=int64), array([[1, 0]], dtype=int64)])

from giotto-ph.

MonkeyBreaker avatar MonkeyBreaker commented on May 20, 2024

Perfect, I will just edit your comment to add the python language highlight

from giotto-ph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.