mrzv/dionysus

Expose cycle equivalence code to python

nhchristianson opened this issue · 6 comments

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

@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.

Seems to work well, thanks!

mrzv commented

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

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

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

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