def test_partition(): pytest.raises(ValueError, lambda: Partition(*range(3))) pytest.raises(ValueError, lambda: Partition([1, 1, 2])) a = Partition([1, 2, 3], [4]) b = Partition([1, 2], [3, 4]) c = Partition([x]) l = [a, b, c] l.sort(key=default_sort_key) assert l == [c, a, b] l.sort(key=lambda w: default_sort_key(w, order='rev-lex')) assert l == [c, a, b] assert (a == b) is False assert a <= b assert (a > b) is False assert a != b assert (a + 2).partition == [[1, 2], [3, 4]] assert (b - 1).partition == [[1, 2, 4], [3]] assert (a - 1).partition == [[1, 2, 3, 4]] assert (a + 1).partition == [[1, 2, 4], [3]] assert (b + 1).partition == [[1, 2], [3], [4]] assert a.rank == 1 assert b.rank == 3 assert a.RGS == (0, 0, 0, 1) assert b.RGS == (0, 0, 1, 1)
def test_rgs(): pytest.raises(ValueError, lambda: RGS_unrank(-1, 3)) pytest.raises(ValueError, lambda: RGS_unrank(3, 0)) pytest.raises(ValueError, lambda: RGS_unrank(10, 1)) pytest.raises(ValueError, lambda: Partition.from_rgs(list(range(3)), list(range(2)))) pytest.raises(ValueError, lambda: Partition.from_rgs(list(range(1, 3)), list(range(2)))) assert RGS_enum(-1) == 0 assert RGS_enum(1) == 1 assert RGS_unrank(7, 5) == [0, 0, 1, 0, 2] assert RGS_unrank(23, 14) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2] assert RGS_rank(RGS_unrank(40, 100)) == 40
def test_sympyissue_9608(): a = Partition([1, 2, 3], [4]) b = Partition([1, 2], [3, 4]) assert list(ordered([a, b], Set._infimum_key)) # does not raise an error