def test_sievetools_Sieve_01(): r'''Boolean operator defaults to OR. ''' sieve = sievetools.Sieve([ResidueClass(2, 0), ResidueClass(3, 0)]) assert sieve.logical_operator == 'or'
def test_sievetools_Sieve_02(): r'''Logical OR. ''' sieve = sievetools.Sieve([ResidueClass(2, 0), ResidueClass(3, 0)]) assert sieve.get_boolean_train(6) == [1, 0, 1, 1, 1, 0] assert sieve.get_congruent_bases(6) == [0, 2, 3, 4, 6]
def test_sievetools_Sieve_05(): r'''Logical AND. ''' sieve = sievetools.Sieve([ResidueClass(2, 1), ResidueClass(3, 0)], 'and') assert sieve.get_boolean_train(6) == [0, 0, 0, 1, 0, 0] assert sieve.get_congruent_bases(6) == [3]
def test_sievetools_ResidueClass_operator_or_06(): r'''OR. ''' residueclass = ResidueClass(2, 1) | ResidueClass(3, 0) assert residueclass.get_boolean_train(6) == [1, 1, 0, 1, 0, 1] assert residueclass.get_congruent_bases(6) == [0, 1, 3, 5, 6]
def test_sievetools_Sieve_07(): r'''Logical XOR. ''' sieve = sievetools.Sieve([ResidueClass(2, 1), ResidueClass(3, 0)], 'xor') assert sieve.get_boolean_train(6) == [1, 1, 0, 0, 0, 1] assert sieve.get_congruent_bases(6) == [0, 1, 5, 6]
def test_sievetools_ResidueClass_operator_or_06(): r'''OR. ''' residueclass = ResidueClass(2, 1) | ResidueClass(3, 0) assert residueclass.get_boolean_train(6) == [1,1,0,1,0,1] assert residueclass.get_congruent_bases(6) == [0,1,3,5,6]
def test_sievetools_ResidueClass_operator_and_06(): r'''AND. ''' residueclass = ResidueClass(2, 1) & ResidueClass(3, 0) assert residueclass.get_boolean_train(6) == [0, 0, 0, 1, 0, 0] assert residueclass.get_congruent_bases(6) == [3]
def test_sievetools_ResidueClass_operator_and_06(): r'''AND. ''' residueclass = ResidueClass(2, 1) & ResidueClass(3, 0) assert residueclass.get_boolean_train(6) == [0,0,0,1,0,0] assert residueclass.get_congruent_bases(6) == [3]
def test_sievetools_Sieve_04(): r'''Logical AND. ''' sieve = sievetools.Sieve([ResidueClass(2, 0), ResidueClass(3, 0)], 'and') assert sieve.logical_operator == 'and' assert sieve.get_boolean_train(6) == [1, 0, 0, 0, 0, 0] assert sieve.get_congruent_bases(6) == [0, 6]
def test_sievetools_Sieve_06(): r'''Logical XOR. ''' sieve = sievetools.Sieve([ResidueClass(2, 0), ResidueClass(3, 0)], 'xor') assert sieve.logical_operator == 'xor' assert sieve.get_boolean_train(6) == [0, 0, 1, 1, 1, 0] assert sieve.get_congruent_bases(6) == [2, 3, 4]
def test_sievetools_ResidueClass_operator_and_05(): r'''AND. ''' residueclass = ResidueClass(2, 0) & ResidueClass(3, 0) assert isinstance(residueclass, sievetools.Sieve) assert residueclass.logical_operator == 'and' assert residueclass.get_boolean_train(6) == [1,0,0,0,0,0] assert residueclass.get_congruent_bases(6) == [0, 6]
def test_sievetools_ResidueClass_operator_or_05(): r'''OR. ''' residueclass = ResidueClass(2, 0) | ResidueClass(3, 0) assert isinstance(residueclass, sievetools.Sieve) assert residueclass.logical_operator == 'or' assert residueclass.get_boolean_train(6) == [1,0,1,1,1,0] assert residueclass.get_congruent_bases(6) == [0,2,3,4,6]
def test_sievetools_ResidueClass_operator_or_05(): r'''OR. ''' residueclass = ResidueClass(2, 0) | ResidueClass(3, 0) assert isinstance(residueclass, sievetools.Sieve) assert residueclass.logical_operator == 'or' assert residueclass.get_boolean_train(6) == [1, 0, 1, 1, 1, 0] assert residueclass.get_congruent_bases(6) == [0, 2, 3, 4, 6]
def test_sievetools_ResidueClass_operator_and_05(): r'''AND. ''' residueclass = ResidueClass(2, 0) & ResidueClass(3, 0) assert isinstance(residueclass, sievetools.Sieve) assert residueclass.logical_operator == 'and' assert residueclass.get_boolean_train(6) == [1, 0, 0, 0, 0, 0] assert residueclass.get_congruent_bases(6) == [0, 6]
def test_sievetools_ResidueClass_operator_or_01(): r'''ResidueClass OR ResidueClass returns a sieve. ''' rc1 = ResidueClass(4, 0) rc2 = ResidueClass(4, 1) t = rc1 | rc2 assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'or' assert t.rcs == [rc1, rc2]
def test_sievetools_ResidueClass_operator_mixed_04(): r'''Operators combined. ''' t = (ResidueClass(2, 0) ^ ResidueClass(3, 0)) | ResidueClass(3, 0) assert isinstance(t, sievetools.Sieve) assert len(t.rcs) == 2 assert isinstance(t.rcs[0], sievetools.Sieve) assert t.rcs[0].logical_operator == 'xor' assert isinstance(t.rcs[1], ResidueClass) assert t.get_boolean_train(6) == [1, 0, 1, 1, 1, 0] assert t.get_congruent_bases(6) == [0, 2, 3, 4, 6]
def test_sievetools_ResidueClass_operator_and_01(): r'''Residue class AND residue class returns a sieve. ''' rc1 = ResidueClass(4, 0) rc2 = ResidueClass(4, 1) t = rc1 & rc2 assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'and' assert t.rcs == [rc1, rc2] assert t.get_boolean_train(4) == [0, 0, 0, 0] assert t.get_congruent_bases(6) == []
def test_sievetools_ResidueClass_operator_xor_02(): r'''xor-sieve XOR ResidueClass returns a flat xor-sieve. ''' rcexpression = ResidueClass(4, 0) ^ ResidueClass(4, 1) rc = ResidueClass(3, 0) t = rc ^ rcexpression assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'xor' assert len(t.rcs) == 3 assert rcexpression.rcs[0] in t.rcs assert rcexpression.rcs[1] in t.rcs assert rc in t.rcs
def test_sievetools_ResidueClass_operator_and_03(): r'''residue class AND and-sieve returns a flat and-sieve. ''' rcexpression = ResidueClass(4, 0) & ResidueClass(4, 1) rc = ResidueClass(3, 0) t = rcexpression & rc assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'and' assert len(t.rcs) == 3 assert rcexpression.rcs[0] in t.rcs assert rcexpression.rcs[1] in t.rcs assert rc in t.rcs
def test_sievetools_ResidueClass_operator_or_03(): r'''ResidueClass OR or-sieve returns a flat or-sieve. ''' rcexpression = ResidueClass(4, 0) | ResidueClass(4, 1) rc = ResidueClass(3, 0) t = rcexpression | rc assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'or' assert len(t.rcs) == 3 assert rcexpression.rcs[0] in t.rcs assert rcexpression.rcs[1] in t.rcs assert rc in t.rcs
def test_sievetools_ResidueClass_operator_or_04(): r'''or-sieve OR or-Sieve returns a flat or-sieve. ''' rc1 = ResidueClass(4, 0) rc2 = ResidueClass(4, 1) rc3 = ResidueClass(3, 0) rc4 = ResidueClass(3, 1) rcsA = rc1 | rc2 rcsB = rc3 | rc4 t = rcsA | rcsB assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'or' assert len(t.rcs) == 4 assert rc1 in t.rcs assert rc2 in t.rcs assert rc3 in t.rcs assert rc4 in t.rcs
def test_sievetools_ResidueClass_operator_and_04(): r'''and-sieve AND and-sieve returns a flat and-sieve. ''' rc1 = ResidueClass(4, 0) rc2 = ResidueClass(4, 1) rc3 = ResidueClass(3, 0) rc4 = ResidueClass(3, 1) rcsA = rc1 & rc2 rcsB = rc3 & rc4 t = rcsA & rcsB assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'and' assert len(t.rcs) == 4 assert rc1 in t.rcs assert rc2 in t.rcs assert rc3 in t.rcs assert rc4 in t.rcs
def test_sievetools_ResidueClass_operator_mixed_01(): r'''Mixed operators yield nested sieves. ''' rc1 = ResidueClass(4, 0) rc2 = ResidueClass(4, 1) rc3 = ResidueClass(3, 0) rc4 = ResidueClass(3, 1) rcsA = rc1 & rc2 rcsB = rc3 | rc4 t = rcsA ^ rcsB assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'xor' assert len(t.rcs) == 2 assert isinstance(t.rcs[0], sievetools.Sieve) assert t.rcs[0].logical_operator == 'and' assert isinstance(t.rcs[1], sievetools.Sieve) assert t.rcs[1].logical_operator == 'or' assert t.rcs[0] is rcsA assert t.rcs[1] is rcsB
def test_sievetools_ResidueClass_operator_mixed_02(): r'''Mixed operators yield nested sieves. Sieves with the same operator, merge. ''' rc1 = ResidueClass(4, 0) rc2 = ResidueClass(4, 1) rc3 = ResidueClass(3, 0) rc4 = ResidueClass(3, 1) rcsA = rc1 & rc2 rcsB = rc3 | rc4 t = rcsA | rcsB assert isinstance(t, sievetools.Sieve) assert t.logical_operator == 'or' assert len(t.rcs) == 3 assert isinstance(t.rcs[0], sievetools.Sieve) assert t.rcs[0].logical_operator == 'and' assert isinstance(t.rcs[1], ResidueClass) assert isinstance(t.rcs[2], ResidueClass) assert t.rcs[0] is rcsA assert t.rcs[1] is rc3 assert t.rcs[2] is rc4