summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Delecroix <20100.delecroix@gmail.com>2014-06-15 19:59:54 +0200
committerVincent Delecroix <20100.delecroix@gmail.com>2014-06-15 21:13:02 +0200
commit714f266d81f57dd6d98daa5598a3b54478c213c8 (patch)
tree871e717487dc189f0d6e082aea88da086cf66e96
parentTrivial doctest fix due to line number changes. (diff)
trac #10534: fix picklingpublic/10534
-rw-r--r--src/sage/combinat/combination.py25
-rw-r--r--src/sage/combinat/set_partition_ordered.py27
2 files changed, 52 insertions, 0 deletions
diff --git a/src/sage/combinat/combination.py b/src/sage/combinat/combination.py
index f2a7066..0326633 100644
--- a/src/sage/combinat/combination.py
+++ b/src/sage/combinat/combination.py
@@ -463,3 +463,28 @@ class Combinations_setk(Combinations_msetk):
"""
x = map(self.mset.index, x)
return rank(x, len(self.mset))
+
+
+##########################################################
+# Deprecations
+
+class ChooseNK(Combinations_setk):
+ def __setstate__(self, state):
+ r"""
+ For unpickling old ``ChooseNK`` objects.
+
+ TESTS::
+
+ sage: loads("x\x9ck`J.NLO\xd5K\xce\xcfM\xca\xccK,\xd1K\xce\xc8\xcf"
+ ....: "/N\x8d\xcf\xcb\xe6r\x06\xb3\xfc\xbc\xb9\n\x195\x1b\x0b"
+ ....: "\x99j\x0b\x995B\x99\xe2\xf3\nY :\x8a2\xf3\xd2\x8b\xf52"
+ ....: "\xf3JR\xd3S\x8b\xb8r\x13\xb3S\xe3a\x9cB\xd6PF\xd3\xd6\xa0"
+ ....: "B6\xa0\xfa\xecB\xf6\x0c \xd7\x08\xc8\xe5(M\xd2\x03\x00{"
+ ....: "\x82$\xd8")
+ Combinations of [0, 1, 2, 3, 4] of length 2
+ """
+ self.__class__ = Combinations_setk
+ Combinations_setk.__init__(self, range(state['_n']), state['_k'])
+
+from sage.structure.sage_object import register_unpickle_override
+register_unpickle_override("sage.combinat.choose_nk", "ChooseNK", ChooseNK)
diff --git a/src/sage/combinat/set_partition_ordered.py b/src/sage/combinat/set_partition_ordered.py
index 0f0dbd6..eded336 100644
--- a/src/sage/combinat/set_partition_ordered.py
+++ b/src/sage/combinat/set_partition_ordered.py
@@ -575,3 +575,30 @@ class OrderedSetPartitions_scomp(OrderedSetPartitions):
res = Word(x).standard_permutation().inverse()
res = [lset[x-1] for x in res]
yield self.element_class( self, [ Set( res[dcomp[i]+1:dcomp[i+1]+1] ) for i in range(l)] )
+
+##########################################################
+# Deprecations
+
+class SplitNK(OrderedSetPartitions_scomp):
+ def __setstate__(self, state):
+ r"""
+ For unpickling old ``SplitNK`` objects.
+
+ TESTS::
+
+ sage: loads("x\x9ck`J.NLO\xd5K\xce\xcfM\xca\xccK,\xd1+.\xc8\xc9,"
+ ....: "\x89\xcf\xcb\xe6\n\x061\xfc\xbcA\xccBF\xcd\xc6B\xa6\xda"
+ ....: "Bf\x8dP\xa6\xf8\xbcB\x16\x88\x96\xa2\xcc\xbc\xf4b\xbd\xcc"
+ ....: "\xbc\x92\xd4\xf4\xd4\"\xae\xdc\xc4\xec\xd4x\x18\xa7\x905"
+ ....: "\x94\xd1\xb45\xa8\x90\r\xa8>\xbb\x90=\x03\xc85\x02r9J\x93"
+ ....: "\xf4\x00\xb4\xc6%f")
+ Ordered set partitions of {0, 1, 2, 3, 4} into parts of size [2, 3]
+ """
+ self.__class__ = OrderedSetPartitions_scomp
+ n = state['_n']
+ k = state['_k']
+ OrderedSetPartitions_scomp.__init__(self, range(state['_n']), (k,n-k))
+
+from sage.structure.sage_object import register_unpickle_override
+register_unpickle_override("sage.combinat.split_nk", "SplitNK_nk", SplitNK)
+