Esempio n. 1
0
def test_sievetools_ResidueClass___init___02():
    r'''Initialize from other rc instance.
    '''

    rc = sievetools.ResidueClass(sievetools.ResidueClass(6, 0))

    assert isinstance(rc, sievetools.ResidueClass)
    assert rc.modulo == 6
    assert rc.residue == 0
Esempio n. 2
0
def test_sievetools_ResidueClass___cmp___01():

    rc1 = sievetools.ResidueClass(6, 0)
    rc2 = sievetools.ResidueClass(6, 1)

    assert not rc1 == rc2
    assert rc1 != rc2
    assert rc1 < rc2
    assert rc1 <= rc2
    assert not rc1 > rc2
    assert not rc1 >= rc2
Esempio n. 3
0
def test_sievetools_ResidueClass___init___01():
    r'''Initialize from modulo and residue.
    '''

    rc = sievetools.ResidueClass(6, 0)

    assert isinstance(rc, sievetools.ResidueClass)
    assert rc.modulo == 6
    assert rc.residue == 0
Esempio n. 4
0
 def __init__(self, rcs=None, logical_operator='or'):
     from abjad.tools import sievetools
     if isinstance(rcs, type(self)):
         self._rcs = rcs.rcs[:]
         self._logical_operator = rcs.logical_operator
     elif rcs is None:
         rcs = [sievetools.ResidueClass()]
         self._rcs = rcs
         self._logical_operator = logical_operator
     else:
         self._rcs = rcs[:]
         self._logical_operator = logical_operator
     self._sort_rcs()
Esempio n. 5
0
 def _cycle_token_to_sieve(cycle_token):
     from abjad.tools import sievetools
     if isinstance(cycle_token, Sieve):
         return Sieve(cycle_token)
     modulo = cycle_token[0]
     residues = cycle_token[1]
     try:
         offset = cycle_token[2]
     except IndexError:
         offset = 0
     residue_classes = []
     for residue in residues:
         adjusted_residue = (residue + offset) % modulo
         residue_class = sievetools.ResidueClass(modulo, adjusted_residue)
         residue_classes.append(residue_class)
     residue_classes.sort(key=lambda x: x.residue)
     sieve = Sieve(residue_classes, logical_operator='or')
     return sieve