mrzv / dionysus

Library for computing persistent homology
http://mrzv.org/software/dionysus2
Other
146 stars 31 forks source link

Plotting fails on diagram with no finite points #47

Closed dlm closed 3 years ago

dlm commented 3 years ago

One of my students ran into a bug with plotting a diagram with no finite points. Here is a minimal example that produces the error. I am putting together a PR with a proposed solution and will send it over in a few min.

import dionysus

# init the complex/filtration
# any filtration that produces a diagram of only infinite points will work
simplicies = [
    ([0], 0),
    ([1], 1),
]

# create the filtration
filtr = dionysus.Filtration()
for verts, idx in simplicies:
    simplex = dionysus.Simplex(verts, idx)
    filtr.append(simplex)
filtr.sort()

# create the diagram
m = dionysus.homology_persistence(filtr)
dgm = dionysus.init_diagrams(m, filtr)
dgm0 = dgm[0]
for pt in dgm0:
    print(pt.birth, pt.death)

# trigger error
dionysus.plot.plot_diagram(dgm0)