Minor touches
authorDmitriy Morozov <dmitriy@mrzv.org>
Sun, 17 Jun 2012 12:14:23 -0700
changeset 4 3315b6204a33
parent 3 ef86268a3695
child 5 9acb920a945c
Minor touches
08-cycle-chain.py
08-extended-persistence.py
--- a/08-cycle-chain.py	Sat Jun 16 12:25:46 2012 -0700
+++ b/08-cycle-chain.py	Sun Jun 17 12:14:23 2012 -0700
@@ -10,5 +10,3 @@
     show_complex(elephant_points, subcomplex = chain)
     if pt[1] != float('inf'):
         show_complex(elephant_points, subcomplex = pair_cycle + pair_chain)
-    #show_complex(elephant_points, [s for s in f if s.dimension() != 1], subcomplex = cycle)
-
--- a/08-extended-persistence.py	Sat Jun 16 12:25:46 2012 -0700
+++ b/08-extended-persistence.py	Sun Jun 17 12:14:23 2012 -0700
@@ -1,6 +1,7 @@
 # Extended persistence
-cone = [Simplex([-1] + [v for v in s.vertices]) for s in elephant_complex]
-cone.append(Simplex([-1]))
+w = -1
+cone = [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):
@@ -11,23 +12,23 @@
 
 def ep_compare(values):
     def max_vertex(s):
-        return max(values(v) for v in s.vertices if v != -1)
+        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 != -1)
+        return min(values(v) for v in s.vertices if v != w)
 
     def compare(s1, s2):
-        if s1.dimension() == 0 and -1 in s1.vertices:
+        if s1.dimension() == 0 and w in s1.vertices:
             return -1
-        if s2.dimension() == 0 and -1 in s2.vertices:
+        if s2.dimension() == 0 and w 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):       # only one cone simplex
-            return 1 if -1 in s1.vertices else -1
-        elif -1 in s1.vertices:
+        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))
@@ -42,10 +43,10 @@
 
 def eval_ep(values):
     def eval(s):
-        if s.dimension() == 0 and -1 in s.vertices:
+        if s.dimension() == 0 and w in s.vertices:
             return float('inf')
-        if -1 in s.vertices:
-            return min(values(v) for v in s.vertices if v != -1)
+        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 eval