mrzv / dionysus

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

Expose cycle equivalence code to python #32

Closed nhchristianson closed 5 years ago

nhchristianson commented 5 years ago

As mentioned on the mailing list: would it be possible to add the functionality of judging equivalence of two cycles (i.e., whether they are in the same homology class) to the python bindings?

mrzv commented 5 years ago

@nhchristianson I've pushed a new branch, homologous-cycles. It's added a function homologous to ReducedMatrix, plus a constructor for Chain. A sample usage is:

>>> import dionysus as d
>>> simplices = [[0], [1], [0,1], [2]]
>>> f = d.Filtration()
>>> for s in simplices: f.append(d.Simplex(s))
>>> f.sort()
>>> for s in f:
...     print(s)
<0> 0
<1> 0
<2> 0
<0,1> 0

>>> m = d.homology_persistence(f)
>>> for i,c in enumerate(m):
...     print(i,c)
0 
1 
2 
3 1*0 + 1*1

>>> m.homologous(d.Chain([(1,0)]), d.Chain([(1,1)]))
True

>>> m.homologous(d.Chain([(1,0)]), d.Chain([(1,2)]))
False

Give it a shot. If it works for you, I'll merge it into master.

nhchristianson commented 5 years ago

Seems to work well, thanks!

mrzv commented 5 years ago

Perfect. I'll add some docs and merge into master.

anvarava commented 4 years ago

Hi! seems like it is still not available (I am using 2.0.6 installed through pip) -- could you please add it? Thanks!

mrzv commented 4 years ago

Is your question specifically about the PyPI release? I need to dig up the instruction on how to post a new update there, but I'll try to do so soon. Meanwhile, you could install through pip directly from GitHub.

mrzv commented 4 years ago

@anvarava I think I managed to make a 2.0.7 release on PyPI. Try and see if it works for you.