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