Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
r""" Elements, Array and Lists With Clone Protocol, demonstration classes
This module demonstrate the usage of the various classes defined in :mod:`~sage.structure.list_clone` """
#***************************************************************************** # Copyright (C) 2011 Florent Hivert <Florent.Hivert@univ-rouen.fr> # # Distributed under the terms of the GNU General Public License (GPL) # http://www.gnu.org/licenses/ #*****************************************************************************
from sage.structure.list_clone cimport ( ClonableArray, ClonableList, NormalizedClonableList, ClonableIntArray )
cdef class IncreasingArray(ClonableArray): """ A small extension class for testing :class:`~sage.structure.list_clone.ClonableArray`.
TESTS::
sage: from sage.structure.list_clone_demo import IncreasingArrays sage: TestSuite(IncreasingArrays()([1,2,3])).run() sage: TestSuite(IncreasingArrays()([])).run() """
cpdef check(self): """ Check that ``self`` is increasing.
EXAMPLES::
sage: from sage.structure.list_clone_demo import IncreasingArrays sage: IncreasingArrays()([1,2,3]) # indirect doctest [1, 2, 3] sage: IncreasingArrays()([3,2,1]) # indirect doctest Traceback (most recent call last): ... ValueError: array is not increasing """ cdef int i
""" A small (incomplete) parent for testing :class:`~sage.structure.list_clone.ClonableArray`
TESTS::
sage: from sage.structure.list_clone_demo import IncreasingArrays sage: IncreasingArrays().element_class <... 'sage.structure.list_clone_demo.IncreasingArray'> """
""" TESTS::
sage: from sage.structure.list_clone_demo import IncreasingArrays sage: IncreasingArrays() <sage.structure.list_clone_demo.IncreasingArrays_with_category object at ...> sage: IncreasingArrays() == IncreasingArrays() True """
""" TESTS::
sage: from sage.structure.list_clone_demo import IncreasingArrays sage: IncreasingArrays()([1]) # indirect doctest [1] """
""" A small (incomplete) parent for testing :class:`~sage.structure.list_clone.ClonableList`
TESTS::
sage: from sage.structure.list_clone_demo import IncreasingLists sage: IncreasingLists().element_class <... 'sage.structure.list_clone_demo.IncreasingList'> """
cdef class IncreasingList(ClonableList): """ A small extension class for testing :class:`~sage.structure.list_clone.ClonableList`
TESTS::
sage: from sage.structure.list_clone_demo import IncreasingLists sage: TestSuite(IncreasingLists()([1,2,3])).run() sage: TestSuite(IncreasingLists()([])).run() """
cpdef check(self): """ Check that ``self`` is increasing
EXAMPLES::
sage: from sage.structure.list_clone_demo import IncreasingLists sage: IncreasingLists()([1,2,3]) # indirect doctest [1, 2, 3] sage: IncreasingLists()([3,2,1]) # indirect doctest Traceback (most recent call last): ... ValueError: array is not increasing """ cdef int i
cdef class IncreasingIntArray(ClonableIntArray): """ A small extension class for testing :class:`~sage.structure.list_clone.ClonableIntArray`.
TESTS::
sage: from sage.structure.list_clone_demo import IncreasingIntArrays sage: TestSuite(IncreasingIntArrays()([1,2,3])).run() sage: TestSuite(IncreasingIntArrays()([])).run() """
cpdef check(self): """ Check that ``self`` is increasing.
EXAMPLES::
sage: from sage.structure.list_clone_demo import IncreasingIntArrays sage: IncreasingIntArrays()([1,2,3]) # indirect doctest [1, 2, 3] sage: IncreasingIntArrays()([3,2,1]) # indirect doctest Traceback (most recent call last): ... ValueError: array is not increasing """ cdef int i
""" A small (incomplete) parent for testing :class:`~sage.structure.list_clone.ClonableIntArray`
TESTS::
sage: from sage.structure.list_clone_demo import IncreasingIntArrays sage: IncreasingIntArrays().element_class <... 'sage.structure.list_clone_demo.IncreasingIntArray'> """
cdef class SortedList(NormalizedClonableList): """ A small extension class for testing :class:`~sage.structure.list_clone.NormalizedClonableList`.
TESTS::
sage: from sage.structure.list_clone_demo import IncreasingIntArrays sage: TestSuite(IncreasingIntArrays()([1,2,3])).run() sage: TestSuite(IncreasingIntArrays()([])).run() """ cpdef normalize(self): """ Normalize ``self``
Sort the list stored in ``self``.
EXAMPLES::
sage: from sage.structure.list_clone_demo import SortedList, SortedLists sage: l = SortedList(SortedLists(), [3,1,2], False, False) sage: l # indirect doctest [1, 2, 3] sage: l[1] = 5; l [1, 5, 3] sage: l.normalize(); l [1, 3, 5] """
cpdef check(self): """ Check that ``self`` is strictly increasing
EXAMPLES::
sage: from sage.structure.list_clone_demo import SortedList, SortedLists sage: SortedLists()([1,2,3]) # indirect doctest [1, 2, 3] sage: SortedLists()([3,2,2]) # indirect doctest Traceback (most recent call last): ... ValueError: list is not strictly increasing """
""" A small (incomplete) parent for testing :class:`~sage.structure.list_clone.NormalizedClonableList`
TESTS::
sage: from sage.structure.list_clone_demo import SortedList, SortedLists sage: SL = SortedLists() sage: SL([3,1,2]) [1, 2, 3] """ |