Beispiel #1
0
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'
Beispiel #2
0
def test_sievetools_Sieve__sort_rcs_01():
    r'''Unsorted RCs are sorted on RC expression initialization.
    '''

    RC = sievetools.ResidueClass
    rcexpression = sievetools.Sieve([RC(10, 0), RC(9, 0), RC(8, 0)])
    assert rcexpression.rcs == [RC(8, 0), RC(9, 0), RC(10, 0)]
Beispiel #3
0
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]
Beispiel #4
0
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]
Beispiel #5
0
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]
Beispiel #6
0
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]
Beispiel #7
0
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]