#### Re: Computing extended persistence in dionysus2

cai.507@...

Thanks a lot for response. I tried to translate from your example to Dionysus2 and I almost get it but because API for init_diagrams in two versions are different, I fail on the last step.

I try to capture a simple cycle here. I expect the solution should be [3, 0.5] . If I understand coning strategy correctly, The filtration order seems to be right (
<-1> 0
<0> 0.5
<1> 1
<3> 2
<2> 3
<0,1> 1
<0,3> 2
<1,2> 3
<2,3> 3
<-1,2> 0
<-1,3> 0
<-1,1> 0
<-1,0> 0
<-1,2,3> 0
<-1,1,2> 0
<-1,0,1> 0
<-1,0,3> 0)
But the answer it gives is (3,0). I think it's due to I am lacking an analog of eval_ep function in your code. But I looked at the API for init_dionysus in Dionysus2,  and didn't find where to put this eval_ep(value) in.

Hopefully this makes sense to you. Thanks a lot for your time!

Your code (I am having trouble installing Dionysus1 so didn't run the code yet):
`# Extended persistencew = -1cone = [Simplex([w] + [v for v in s.vertices]) for s in elephant_complex]cone.append(Simplex([w]))def projection(points, axis = 1):    def value(v):        return points[v][axis]    return valuevalue = projection(elephant_points, 1)def ep_compare(values):    def max_vertex(s):        return max(values(v) for v in s.vertices if v != w)    def min_vertex(s):        return min(values(v) for v in s.vertices if v != w)    def compare(s1, s2):        if s1.dimension() == 0 and w in s1.vertices:            return -1        if s2.dimension() == 0 and w in s2.vertices:            return 1        if s1.dimension() != s2.dimension():            return cmp(s1.dimension(), s2.dimension())        if (w in s1.vertices) ^ (w in s2.vertices):       # only one cone simplex            return 1 if w in s1.vertices else -1        elif w in s1.vertices:            return -cmp(min_vertex(s1), min_vertex(s2))        else:            return cmp(max_vertex(s1), max_vertex(s2))    return comparef = Filtration(elephant_complex + cone)f.sort(ep_compare(value))persistence = StaticPersistence(f)persistence.pair_simplices()def eval_ep(values):    def eval(s):        if s.dimension() == 0 and w in s.vertices:            return float('inf')        if w in s.vertices:            return min(values(v) for v in s.vertices if v != w)        else:            return max(values(v) for v in s.vertices)    return evaldgms = init_diagrams(persistence, f, eval_ep(value), lambda i: i)print show_diagram(dgms)#print dgms#print len(dgms)`

My code:
`import numpy as npimport dionysus as dw = -1simplices = [(, 0.5), (, 1), (, 3),(,2), ([0,1], 1), ([0,3], 2), ([1,2],3), ([2,3],3)]def value(v):    for simplex in simplices:        if len(simplex) == 1 and simplex==v:            return simplexelephant_complex = d.Filtration()for vertices, time in simplices:    elephant_complex.append(d.Simplex(vertices, time))cone = [d.Simplex([w] + [v for v in s]) for s in elephant_complex]cone.append(d.Simplex([w]))def print_filtration(f):    for simplex in f:        print simplexdef ep_compare(values):    def max_vertex(s):        return max(values(v) for v in s if v != w)    def min_vertex(s):        return min(values(v) for v in s if v != w)    def compare(s1, s2):        if s1.dimension() == 0 and w in s1:            return -1        if s2.dimension() == 0 and w in s2:            return 1        if s1.dimension() != s2.dimension():            return cmp(s1.dimension(), s2.dimension())        if (w in s1) ^ (w in s2):       # only one cone simplex            return 1 if w in s1 else -1        elif w in s1:            return -cmp(min_vertex(s1), min_vertex(s2))        else:            return cmp(max_vertex(s1), max_vertex(s2))    return comparef = d.Filtration(elephant_complex)for simplex in cone:    f.append(simplex)f.sort(ep_compare(value))print_filtration(f)m = d.homology_persistence(f)dgms = d.init_diagrams(m, f)`

Join dionysus@groups.io to automatically receive all group messages.