author Dmitriy Morozov Sat, 16 Jun 2012 12:25:46 -0700 changeset 3 ef86268a3695 parent 2 4b3728f0d920 child 4 3315b6204a33
Fixed bugs in 08-extended-persistence.py
 07-ls-filtration.py file | annotate | diff | comparison | revisions 08-extended-persistence.py file | annotate | diff | comparison | revisions
```--- a/07-ls-filtration.py	Sat Jun 16 12:13:53 2012 -0700
+++ b/07-ls-filtration.py	Sat Jun 16 12:25:46 2012 -0700
@@ -4,13 +4,13 @@
elephant_complex = closure(elephant_complex, 2)
show_complex(elephant_points, elephant_complex)

-def axis(points, axis = 1):
+def projection(points, axis = 1):
def value(v):
return points[v][axis]

return value

-value = axis(elephant_points, 1)
+value = projection(elephant_points, 1)

def max_vertex_compare(values):```
```--- a/08-extended-persistence.py	Sat Jun 16 12:13:53 2012 -0700
+++ b/08-extended-persistence.py	Sat Jun 16 12:25:46 2012 -0700
@@ -2,12 +2,12 @@
cone = [Simplex([-1] + [v for v in s.vertices]) for s in elephant_complex]
cone.append(Simplex([-1]))

-def axis(points, axis = 1):
+def projection(points, axis = 1):
def value(v):
return points[v][axis]

return value
-value = axis(elephant_points, 1)
+value = projection(elephant_points, 1)

def ep_compare(values):
def max_vertex(s):
@@ -17,13 +17,18 @@
return min(values(v) for v in s.vertices if v != -1)

def compare(s1, s2):
+        if s1.dimension() == 0 and -1 in s1.vertices:
+            return -1
+        if s2.dimension() == 0 and -1 in s2.vertices:
+            return 1
+
if s1.dimension() != s2.dimension():
return cmp(s1.dimension(), s2.dimension())

-        if (-1 in s1.vertices) ^ (-1 in s2.vertices):
+        if (-1 in s1.vertices) ^ (-1 in s2.vertices):       # only one cone simplex
return 1 if -1 in s1.vertices else -1
elif -1 in s1.vertices:
-            return cmp(min_vertex(s1), min_vertex(s2))
+            return -cmp(min_vertex(s1), min_vertex(s2))
else:
return cmp(max_vertex(s1), max_vertex(s2))

@@ -47,6 +52,6 @@

dgms = init_diagrams(persistence, f, eval_ep(value), lambda i: i)

-show_diagram(dgms)
+print show_diagram(dgms)
#print dgms
#print len(dgms)```