Skip to content

Commit 9818d94

Browse files
committed
Merge branch 't/21319/sequences/rec-hash' into t/21204/sequences/k-regular-guess
* t/21319/sequences/rec-hash: TestSuite pickling support an_element and some_elements FreeModule_generic.some_elements MatrixSpace.some_elements equality testing hashing mutability in transposed() fix doctests handle mutable structures
2 parents 0d5fbed + c2f9c62 commit 9818d94

File tree

4 files changed

+467
-10
lines changed

4 files changed

+467
-10
lines changed

src/sage/combinat/k_regular_sequence.py

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def __getitem__(self, n, **kwds):
323323
sage: W = Seq2.indices()
324324
sage: M0 = Matrix([[1, 0], [0, 1]])
325325
sage: M1 = Matrix([[0, -1], [1, 2]])
326-
sage: S = Seq2((M0, M1), [0, 1], [1, 1])
326+
sage: S = Seq2((M0, M1), vector([0, 1]), vector([1, 1]))
327327
sage: S._mu_of_word_(W(0.digits(2))) == M0
328328
True
329329
sage: S._mu_of_word_(W(1.digits(2))) == M1
@@ -712,6 +712,21 @@ def partial_sums(self, include_n=False, minimize=True):
712712
return result
713713

714714

715+
def _pickle_kRegularSequenceSpace(k, coefficients, category):
716+
r"""
717+
Pickle helper.
718+
719+
TESTS::
720+
721+
sage: Seq2 = kRegularSequenceSpace(2, ZZ)
722+
sage: from sage.combinat.k_regular_sequence import _pickle_kRegularSequenceSpace
723+
sage: _pickle_kRegularSequenceSpace(
724+
....: Seq2.k, Seq2.coefficients(), Seq2.category())
725+
Space of 2-regular sequences over Integer Ring
726+
"""
727+
return kRegularSequenceSpace(k, coefficients, category=category)
728+
729+
715730
class kRegularSequenceSpace(RecognizableSeriesSpace):
716731
r"""
717732
The space of `k`-regular Sequences over the given ``coefficients``.
@@ -788,6 +803,35 @@ def __init__(self, k, *args, **kwds):
788803
sage: kRegularSequenceSpace(3, ZZ)
789804
Space of 3-regular sequences over Integer Ring
790805
806+
::
807+
808+
sage: from itertools import islice
809+
sage: Seq2 = kRegularSequenceSpace(2, ZZ)
810+
sage: TestSuite(Seq2).run( # long time
811+
....: verbose=True,
812+
....: elements=tuple(islice(Seq2.some_elements(), 4)))
813+
running ._test_additive_associativity() . . . pass
814+
running ._test_an_element() . . . pass
815+
running ._test_cardinality() . . . pass
816+
running ._test_category() . . . pass
817+
running ._test_elements() . . .
818+
Running the test suite of self.an_element()
819+
running ._test_category() . . . pass
820+
running ._test_eq() . . . pass
821+
running ._test_nonzero_equal() . . . pass
822+
running ._test_not_implemented_methods() . . . pass
823+
running ._test_pickling() . . . pass
824+
pass
825+
running ._test_elements_eq_reflexive() . . . pass
826+
running ._test_elements_eq_symmetric() . . . pass
827+
running ._test_elements_eq_transitive() . . . pass
828+
running ._test_elements_neq() . . . pass
829+
running ._test_eq() . . . pass
830+
running ._test_not_implemented_methods() . . . pass
831+
running ._test_pickling() . . . pass
832+
running ._test_some_elements() . . . pass
833+
running ._test_zero() . . . pass
834+
791835
.. SEEALSO::
792836
793837
:doc:`k-regular sequence <k_regular_sequence>`,
@@ -797,6 +841,20 @@ def __init__(self, k, *args, **kwds):
797841
super(kRegularSequenceSpace, self).__init__(*args, **kwds)
798842

799843

844+
def __reduce__(self):
845+
r"""
846+
Pickling support.
847+
848+
TESTS::
849+
850+
sage: Seq2 = kRegularSequenceSpace(2, ZZ)
851+
sage: loads(dumps(Seq2)) # indirect doctest
852+
Space of 2-regular sequences over Integer Ring
853+
"""
854+
return _pickle_kRegularSequenceSpace, \
855+
(self.k, self.coefficients(), self.category())
856+
857+
800858
def _repr_(self):
801859
r"""
802860
Return a representation string of this `k`-regular sequence space.

0 commit comments

Comments
 (0)