def test_rgs(): raises(ValueError, lambda: RGS_unrank(-1, 3)) raises(ValueError, lambda: RGS_unrank(3, 0)) raises(ValueError, lambda: RGS_unrank(10, 1)) raises(ValueError, lambda: Partition.from_rgs(list(range(3)), list(range(2)))) 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_rgs(): raises(ValueError, lambda: RGS_unrank(-1, 3)) raises(ValueError, lambda: RGS_unrank(3, 0)) raises(ValueError, lambda: RGS_unrank(10, 1)) raises(ValueError, lambda: Partition.from_rgs(list(range(3)), list(range(2)))) 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_Partition(): assert str(Partition(FiniteSet(x, y), {z})) == 'Partition({z}, {x, y})'
def test_issue_21823(): assert str(Partition([1, 2])) == 'Partition({1, 2})' assert str(Partition({1, 2})) == 'Partition({1, 2})'
def test_ordered_partition_9608(): a = Partition([1, 2, 3], [4]) b = Partition([1, 2], [3, 4]) assert list(ordered([a, b], Set._infimum_key))
def test_partition_constructor(): raises(ValueError, lambda: Partition([1, 1, 2])) raises(ValueError, lambda: Partition([1, 2, 3], [2, 3, 4])) raises(ValueError, lambda: Partition(1, 2, 3)) raises(ValueError, lambda: Partition(*list(range(3)))) assert Partition([1, 2, 3], [4, 5]) == Partition([4, 5], [1, 2, 3]) assert Partition({1, 2, 3}, {4, 5}) == Partition([1, 2, 3], [4, 5]) a = FiniteSet(1, 2, 3) b = FiniteSet(4, 5) assert Partition(a, b) == Partition([1, 2, 3], [4, 5]) assert Partition({a, b}) == Partition(FiniteSet(a, b)) assert Partition({a, b}) != Partition(a, b)