def testSums(self): """Check that all outputs are partitions of the input.""" for n in range(len(self.counts)): for p in mckay(n): self.assertEqual(n, sum(p)) for p in revlex_partitions(n): self.assertEqual(n, sum(p)) for p in lex_partitions(n): self.assertEqual(n, sum(p))
def testRevLex(self): """Check that the revlex generators' outputs are in revlex order.""" for n in range(len(self.counts)): last = [n + 1] for p in mckay(n): self.assertGreater(last, p) last = list(p) # make less-mutable copy last = [n + 1] for p in revlex_partitions(n): self.assertGreater(last, p) last = list(p) # make less-mutable copy
def testFixedLength(self): """Check that the fixed length partition outputs are correct.""" for n in range(len(self.counts)): pn = [list(p) for p in revlex_partitions(n)] pn.sort() np = 0 for L in range(n + 1): pnL = [list(p) for p in fixed_length_partitions(n, L)] pnL.sort() np += len(pnL) self.assertEqual(pnL, [p for p in pn if len(p) == L]) self.assertEqual(np, len(pn))
def testRange(self): """Check that all numbers in output partitions are in range.""" for n in range(len(self.counts)): for p in mckay(n): for x in p: self.assertLess(0, x) self.assertLessEqual(x, n) for p in lex_partitions(n): for x in p: self.assertLess(0, x) self.assertLessEqual(x, n) for p in revlex_partitions(n): for x in p: self.assertLess(0, x) self.assertLessEqual(x, n)
def testCounts(self): """Check that each generator has the right number of outputs.""" for n in range(len(self.counts)): self.assertEqual(self.counts[n], len(list(mckay(n)))) self.assertEqual(self.counts[n], len(list(lex_partitions(n)))) self.assertEqual(self.counts[n], len(list(revlex_partitions(n))))