def betti(index: int, xs: Complex, subspace: Optional[Complex] = None) -> int: def lists_from_complex(immutable: Complex) -> List[List[int]]: return list([list(y for y in x) for x in immutable]) if subspace is not None: return simplicialHomology(index, lists_from_complex(xs), lists_from_complex(subspace), rankOnly=True) else: return simplicialHomology(index, lists_from_complex(xs), rankOnly=True)
H1=sh.localHomology(1,toplexes,[[1]]) H2=sh.localHomology(2,toplexes,[[1]]) if H0.shape[1] != 0 or H1.shape[1] != 0 or H2.shape[1] != 0: print "Test 2b failed" print "H0="+ H0.__repr__() print "H1="+ H1.__repr__() print "H2="+ H2.__repr__() else: print "Test 2b passed" # Test 3: line segment localized to the star over a vertex # (using relative homology, "by hand") toplexes=[[1,2]] H0=sh.simplicialHomology(0,toplexes,[[1]],True) H1=sh.simplicialHomology(1,toplexes,[[1]],True) H2=sh.simplicialHomology(2,toplexes,[[1]],True) if H0 != 0 or H1 != 0 or H2 != 0: print "Test 3a failed" print "H0="+ str(H0) print "H1="+ str(H1) print "H2="+ str(H2) else: print "Test 3a passed" H0=sh.simplicialHomology(0,toplexes,[[1]]) H1=sh.simplicialHomology(1,toplexes,[[1]]) H2=sh.simplicialHomology(2,toplexes,[[1]])
H1 = sh.localHomology(1, toplexes, [[1]]) H2 = sh.localHomology(2, toplexes, [[1]]) if H0.shape[1] != 0 or H1.shape[1] != 0 or H2.shape[1] != 0: print "Test 2b failed" print "H0=" + H0.__repr__() print "H1=" + H1.__repr__() print "H2=" + H2.__repr__() else: print "Test 2b passed" # Test 3: line segment localized to the star over a vertex # (using relative homology, "by hand") toplexes = [[1, 2]] H0 = sh.simplicialHomology(0, toplexes, [[1]], True) H1 = sh.simplicialHomology(1, toplexes, [[1]], True) H2 = sh.simplicialHomology(2, toplexes, [[1]], True) if H0 != 0 or H1 != 0 or H2 != 0: print "Test 3a failed" print "H0=" + str(H0) print "H1=" + str(H1) print "H2=" + str(H2) else: print "Test 3a passed" H0 = sh.simplicialHomology(0, toplexes, [[1]]) H1 = sh.simplicialHomology(1, toplexes, [[1]]) H2 = sh.simplicialHomology(2, toplexes, [[1]])
H1=sh.localHomology(toplexes,1,[[1]]) H2=sh.localHomology(toplexes,2,[[1]]) if H0.shape[1] != 0 or H1.shape[1] != 0 or H2.shape[1] != 0: print "Test 2 failed" print "H0="+ H0.__repr__() print "H1="+ H1.__repr__() print "H2="+ H2.__repr__() else: print "Test 2 passed" # Test 3: line segment localized to the star over a vertex # (using relative homology, "by hand") toplexes=[[1,2]] H0=sh.simplicialHomology(toplexes,0,[[1]]) H1=sh.simplicialHomology(toplexes,1,[[1]]) H2=sh.simplicialHomology(toplexes,2,[[1]]) if H0.shape[1] != 0 or H1.shape[1] != 0 or H2.shape[1] != 0: print "Test 3 failed" print "H0="+ H0.__repr__() print "H1="+ H1.__repr__() print "H2="+ H2.__repr__() else: print "Test 3 passed" # Test 4: empty triangle localized to an edge toplexes=[[1,2],[1,3],[2,3]] H0=sh.localHomology(toplexes,0,[[1,2]])