Exemple #1
0
 def subprimes(self, limit=0):
     """
     Yields the subsets of the given object which have a unique set-class.
     Takes an optional limit argument with the same behavior as subsets().
     """
     from sator.pcset import PCSet
     for sub in self.subsets(limit):
         yield PCSet(self.copy(utils.fromint(sub.pcint)))
Exemple #2
0
 def setUp(self):
     self.l = [0, 1, 2, 3, 4, 6]
     self.set_ints = [0, 4095, 392, 661, 583, 203, 2741, 584, 394, 858]
     self.sets = [PCSet(utils.fromint(each)) for each in self.set_ints]
     self.pcset = PCSet(self.l)
     self.t_rots = list(self.pcset._t_rotations())
     self.i_rots = list(self.pcset._i_rotations())
     self.m_rots = list(self.pcset._m_rotations())
     self.mi_rots = list(self.pcset._mi_rotations())
Exemple #3
0
 def fromint(integer, modulus=12):
     """
     Static method that returns a PCSet object with pc's generated from
     their integer representation.
         Ex:
             0 = [], 1 = [0], 2 = [1], 3 = [0, 1], 4 = [2], 5 = [0, 2]
             PCSet.fromint(5) returns PCSet([0, 2])
     """
     from sator.pcset import PCSet
     new_set = PCSet(mod=modulus)
     new_set.pitches = utils.fromint(integer)
     return new_set
Exemple #4
0
 def zpartner(self):
     """
     Property that returns the Z-partner of the given object if it exists,
     otherwise returns None.
     """
     if self._mod == 12:
         zint = Z_PARTNERS.get(self.pcint, None)
         if zint:
             return self.copy(utils.fromint(zint))
         else:
             return
     for each in self.each_card():
         if each.icv == self.icv:
             if each.prime._unique_pcs != self.prime._unique_pcs:
                 return self.copy(each)
Exemple #5
0
 def testPrime(self):
     primes = []
     set_ints = [0, 4095, 420, 2224]
     sets = [PCSet(utils.fromint(each)) for each in set_ints]
     for t, i, m in self.make_canons():
         for each in sets:
             each.canon(t, i, m)
             primes.append(each.prime)
     self.assertEqual(primes, [
                      [],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
                      [0, 1, 3, 6],
                      [0, 1, 4, 6],
                      [],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
                      [0, 1, 3, 6],
                      [0, 1, 3, 7],
                      [],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
                      [0, 6, 7, 9],
                      [0, 1, 6, 10],
                      [],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
                      [0, 3, 5, 6],
                      [0, 1, 3, 7],
                      [],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
                      [2, 5, 7, 8],
                      [1, 5, 7, 8],
                      [],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
                      [2, 5, 7, 8],
                      [1, 5, 7, 8],
                      [],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
                      [2, 5, 7, 8],
                      [4, 5, 7, 11],
                      [],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
                      [2, 5, 7, 8],
                      [4, 5, 7, 11]                            
     ])
Exemple #6
0
 def each_set_in_mod(cls, mod):
     return(cls(utils.fromint(integer), mod=mod) for integer in range(0, 2 ** mod))
Exemple #7
0
 def testFromInt(self):
     self.assertEqual(utils.fromint(18), self.pcset._unique_pcs)
     self.assertEqual(utils.fromint(89), self.pcset2._unique_pcs)
Exemple #8
0
 def make_z_sets(self):
     zints = Z_PARTNERS.keys()
     return [PCSet(utils.fromint(zint)) for zint in zints]