def test_index_is_subpartition(self): ordered_list = [Nothing(), Index([3]), Index([1, 3]), Index(), Singleton()] for loose, strict in zip(ordered_list[:1], ordered_list[1:]): self.assertTrue(strict.is_subpartitioning_of(loose), (strict, loose)) self.assertFalse(loose.is_subpartitioning_of(strict), (loose, strict)) # Incomparable. self.assertFalse(Index([1, 2]).is_subpartitioning_of(Index([1, 3]))) self.assertFalse(Index([1, 3]).is_subpartitioning_of(Index([1, 2])))
def test_index_partition(self): self._check_partition(Index([0]), 2) self._check_partition(Index([0, 1]), 6) self._check_partition(Index([1]), 3) self._check_partition(Index([2]), 7, 24) self._check_partition(Index([0, 2]), 7, 24) self._check_partition(Index(), 7, 24)
def test_index_partition(self): try: # Reduce odds of collision. old, Index._INDEX_PARTITIONS = Index._INDEX_PARTITIONS, 1000 self._check_partition(Index([0]), 2) self._check_partition(Index([0, 1]), 6) self._check_partition(Index([1]), 3) self._check_partition(Index([2]), 7, 24) self._check_partition(Index([0, 2]), 7, 24) self._check_partition(Index(), 7, 24) finally: Index._INDEX_PARTITIONS = old
def test_index_is_subpartition(self): ordered_list = [ Singleton(), Index([3]), Index([1, 3]), Index(), JoinIndex('ref'), JoinIndex(), Arbitrary() ] for loose, strict in zip(ordered_list[:-1], ordered_list[1:]): self.assertTrue(strict.is_subpartitioning_of(loose), (strict, loose)) self.assertFalse(loose.is_subpartitioning_of(strict), (loose, strict)) # Incomparable. self.assertFalse(Index([1, 2]).is_subpartitioning_of(Index([1, 3]))) self.assertFalse(Index([1, 3]).is_subpartitioning_of(Index([1, 2]))) self.assertFalse(JoinIndex('a').is_subpartitioning_of(JoinIndex('b'))) self.assertFalse(JoinIndex('b').is_subpartitioning_of(JoinIndex('a')))
def test_singleton_subpartition(self): for p in [Nothing(), Index([1]), Index([1, 2]), Index(), Singleton()]: self.assertTrue(Singleton().is_subpartitioning_of(p), p)
def test_nothing_subpartition(self): self.assertTrue(Nothing().is_subpartitioning_of(Nothing())) for p in [Index([1]), Index([1, 2]), Index(), Singleton()]: self.assertFalse(Nothing().is_subpartitioning_of(p), p)
def test_singleton_subpartition(self): self.assertTrue(Singleton().is_subpartitioning_of(Singleton())) for p in [Arbitrary(), Index([1]), Index([1, 2]), Index()]: self.assertFalse(Singleton().is_subpartitioning_of(p), p)
def test_nothing_subpartition(self): for p in [Index([1]), Index([1, 2]), Index(), Singleton()]: self.assertTrue(Arbitrary().is_subpartitioning_of(p), p)