def testIdentityDiagram(self): pmc_to_test = [splitPMC(1), splitPMC(2), linearPMC(2), antipodalPMC(2)] pmc_to_test.append(PMC([(0, 2), (1, 6), (3, 5), (4, 7)])) pmc_to_test += [splitPMC(3), antipodalPMC(4)] genus_to_size = [2, 6, 20, 70] for pmc in pmc_to_test: diagram = getIdentityDiagram(pmc) self.assertEqual(diagram.getPMCs(), [pmc.opp(), pmc]) expected_size = genus_to_size[pmc.genus - 1] self.assertEqual(len(diagram.getHFGenerators()), expected_size) self.assertEqual(len(diagram.getPeriodicDomains()), pmc.genus * 2)
def testAbsGrading(self): def testOneAlgebra(alg, test_op = True): abs_gr = AbsZ2Grading(alg) for gen in alg.getGenerators(): # Test asserts in getAbsGrading abs_gr.getAbsGrading(gen) if not test_op: return # Test differential and multiplication for a in alg.getGenerators(): for term in a.diff(): a_gr, da_gr = [abs_gr.getAbsGrading(gen) for gen in a, term] assert (a_gr - 1) % 2 == da_gr for a in alg.getGenerators(): for b in alg.getGenerators(): if a * b != 0: a_gr, b_gr, ab_gr = [abs_gr.getAbsGrading(gen) for gen in a, b, (a*b).getElt()] assert (a_gr + b_gr) % 2 == ab_gr for pmc in [splitPMC(1), splitPMC(2), linearPMC(2)]: testOneAlgebra(pmc.getAlgebra()) for pmc in [antipodalPMC(2), splitPMC(3)]: testOneAlgebra(pmc.getAlgebra(), test_op = False) for (pmc, idem_size) in [(splitPMC(1), 1), (splitPMC(1), 2), (splitPMC(2), 1), (splitPMC(2), 2)]: testOneAlgebra(PreStrandAlgebra(F2, pmc, idem_size)) for (pmc, idem_size) in [(splitPMC(2), 3), (splitPMC(2), 4), (splitPMC(3), 2)]: testOneAlgebra(PreStrandAlgebra(F2, pmc, idem_size), test_op = False)
def testGetIntervalOrdering(self): tests = [(splitPMC(1), [0,1,2]), (splitPMC(2), [4,5,6,3,0,1,2]), (antipodalPMC(2), [2,5,0,3,6,1,4]), (linearPMC(2), [4,0,1,3,5,6,2])] for pmc, order in tests: self.assertEqual(_getIntervalOrdering(pmc), order)
def testGeneralOverslideDown(self): slides_to_test = [ Arcslide(splitPMC(1), 3, 2), Arcslide(splitPMC(2), 3, 2), Arcslide(splitPMC(2), 4, 3), Arcslide(splitPMC(2), 7, 6), Arcslide(linearPMC(2), 3, 2), Arcslide(linearPMC(2), 5, 4), Arcslide(linearPMC(2), 7, 6), Arcslide(antipodalPMC(2), 5, 4), Arcslide(antipodalPMC(2), 6, 5), Arcslide(antipodalPMC(2), 7, 6), ] for slide in slides_to_test: print slide dastr = ArcslideDA(slide).toSimpleDAStructure() self.assertTrue(dastr.testDelta())
def testOverslideAgreesWithDD(self): # This is not guaranteed (since there is choice involved in type DD for # overslides, but appears to work slides_to_test = [ # General overslides down Arcslide(splitPMC(1), 3, 2), Arcslide(splitPMC(2), 3, 2), Arcslide(splitPMC(2), 4, 3), Arcslide(splitPMC(2), 7, 6), Arcslide(linearPMC(2), 3, 2), Arcslide(linearPMC(2), 5, 4), Arcslide(linearPMC(2), 7, 6), Arcslide(antipodalPMC(2), 5, 4), Arcslide(antipodalPMC(2), 6, 5), Arcslide(antipodalPMC(2), 7, 6), # General overslides up Arcslide(splitPMC(1), 0, 1), Arcslide(splitPMC(2), 0, 1), Arcslide(splitPMC(2), 3, 4), Arcslide(splitPMC(2), 4, 5), Arcslide(linearPMC(2), 0, 1), Arcslide(linearPMC(2), 2, 3), Arcslide(linearPMC(2), 4, 5), Arcslide(antipodalPMC(2), 0, 1), Arcslide(antipodalPMC(2), 1, 2), Arcslide(antipodalPMC(2), 2, 3), ] for slide in slides_to_test: dastr = ArcslideDA(slide) ddstr = dastr.tensorDD(identityDD(slide.end_pmc)) ori_ddstr = slide.getDDStructure() self.assertTrue(ddstr.compareDDStructures(ori_ddstr))
def testGeneralUnderslideDown(self): slides_to_test = [ Arcslide(antipodalPMC(2), 1, 0), Arcslide(antipodalPMC(2), 2, 1), Arcslide(antipodalPMC(2), 3, 2), Arcslide(antipodalPMC(2), 4, 3), Arcslide(PMC([(0, 3), (1, 6), (2, 4), (5, 7)]), 1, 0), Arcslide(PMC([(0, 5), (1, 3), (2, 6), (4, 7)]), 1, 0), Arcslide(PMC([(0, 3), (1, 5), (2, 7), (4, 6)]), 1, 0), Arcslide(PMC([(0, 2), (1, 4), (3, 6), (5, 7)]), 2, 1), Arcslide(PMC([(0, 2), (1, 4), (3, 6), (5, 7)]), 4, 3), Arcslide(PMC([(0, 3), (1, 6), (2, 4), (5, 7)]), 2, 1), Arcslide(PMC([(0, 2), (1, 6), (3, 5), (4, 7)]), 2, 1), Arcslide(PMC([(0, 3), (1, 5), (2, 7), (4, 6)]), 2, 1), Arcslide(PMC([(0, 2), (1, 6), (3, 5), (4, 7)]), 5, 4), Arcslide(PMC([(0, 3), (1, 5), (2, 7), (4, 6)]), 3, 2), Arcslide(PMC([(0, 5), (1, 3), (2, 6), (4, 7)]), 5, 4), ] for slide in slides_to_test: print slide dastr = ArcslideDA(slide).toSimpleDAStructure() self.assertTrue(dastr.testDelta())
def testUnderslideAgreesWithDD(self): slides_to_test = [ # Short underslides down Arcslide(splitPMC(1), 1, 0), Arcslide(linearPMC(2), 6, 5), Arcslide(PMC([(0, 2), (1, 6), (3, 5), (4, 7)]), 1, 0), # General underslides down Arcslide(antipodalPMC(2), 1, 0), Arcslide(PMC([(0, 2), (1, 4), (3, 6), (5, 7)]), 4, 3), # Short underslides up Arcslide(splitPMC(1), 1, 2), Arcslide(linearPMC(2), 1, 2), Arcslide(PMC([(0, 2), (1, 6), (3, 5), (4, 7)]), 4, 5), # General underslides up Arcslide(antipodalPMC(2), 6, 7), Arcslide(PMC([(0, 3), (1, 6), (2, 4), (5, 7)]), 2, 3), ] for slide in slides_to_test: dastr = ArcslideDA(slide) ddstr = dastr.tensorDD(identityDD(slide.end_pmc)) ori_ddstr = slide.getDDStructure() self.assertTrue(ddstr.compareDDStructures(ori_ddstr))
def testPrintLocalDAStructure(self): slide, pmc_map1, pmc_map2 = ( # Uncomment one of the following lines # Arcslide(splitPMC(2), 2, 1), None, None, # short, down # Arcslide(splitPMC(2), 2, 3), None, None, # short, up # Arcslide(antipodalPMC(2), 2, 1), [0,1,2,3,4,6,7], [0,1,3,4,5,6,7], Arcslide(antipodalPMC(2), 4, 5), [0,1,3,4,5,6,7], [0,1,2,3,4,6,7], ) local_dastr = ArcslideDA(slide).getLocalDAStructure() f = open("latex_output.txt", "w") f.write(beginDoc()) f.write(showDAStructure(local_dastr, pmc_map1, pmc_map2)) f.write(endDoc()) f.close()
def testCreateRowSystem(self): sign = SignLinAlg(StrandAlgebra(F2, antipodalPMC(2), idem_size = 2, mult_one = True)) sign.createRowSystem()