passagemath-objects 10.6.45__cp313-cp313-musllinux_1_2_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of passagemath-objects might be problematic. Click here for more details.
- passagemath_objects/__init__.py +3 -0
- passagemath_objects-10.6.45.dist-info/METADATA +115 -0
- passagemath_objects-10.6.45.dist-info/RECORD +280 -0
- passagemath_objects-10.6.45.dist-info/WHEEL +5 -0
- passagemath_objects-10.6.45.dist-info/top_level.txt +3 -0
- passagemath_objects.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- sage/all__sagemath_objects.py +37 -0
- sage/arith/all__sagemath_objects.py +5 -0
- sage/arith/long.pxd +411 -0
- sage/arith/numerical_approx.cpython-313-x86_64-linux-musl.so +0 -0
- sage/arith/numerical_approx.pxd +35 -0
- sage/arith/numerical_approx.pyx +75 -0
- sage/arith/power.cpython-313-x86_64-linux-musl.so +0 -0
- sage/arith/power.pxd +31 -0
- sage/arith/power.pyx +127 -0
- sage/categories/action.cpython-313-x86_64-linux-musl.so +0 -0
- sage/categories/action.pxd +29 -0
- sage/categories/action.pyx +641 -0
- sage/categories/algebra_functor.py +745 -0
- sage/categories/all__sagemath_objects.py +33 -0
- sage/categories/basic.py +62 -0
- sage/categories/cartesian_product.py +295 -0
- sage/categories/category.py +3401 -0
- sage/categories/category_cy_helper.cpython-313-x86_64-linux-musl.so +0 -0
- sage/categories/category_cy_helper.pxd +8 -0
- sage/categories/category_cy_helper.pyx +322 -0
- sage/categories/category_singleton.cpython-313-x86_64-linux-musl.so +0 -0
- sage/categories/category_singleton.pxd +3 -0
- sage/categories/category_singleton.pyx +342 -0
- sage/categories/category_types.py +637 -0
- sage/categories/category_with_axiom.py +2876 -0
- sage/categories/covariant_functorial_construction.py +703 -0
- sage/categories/facade_sets.py +228 -0
- sage/categories/functor.cpython-313-x86_64-linux-musl.so +0 -0
- sage/categories/functor.pxd +7 -0
- sage/categories/functor.pyx +691 -0
- sage/categories/homset.py +1338 -0
- sage/categories/homsets.py +364 -0
- sage/categories/isomorphic_objects.py +73 -0
- sage/categories/map.cpython-313-x86_64-linux-musl.so +0 -0
- sage/categories/map.pxd +34 -0
- sage/categories/map.pyx +2106 -0
- sage/categories/morphism.cpython-313-x86_64-linux-musl.so +0 -0
- sage/categories/morphism.pxd +14 -0
- sage/categories/morphism.pyx +895 -0
- sage/categories/objects.py +167 -0
- sage/categories/primer.py +1696 -0
- sage/categories/pushout.py +4834 -0
- sage/categories/quotients.py +64 -0
- sage/categories/realizations.py +200 -0
- sage/categories/sets_cat.py +3290 -0
- sage/categories/sets_with_partial_maps.py +52 -0
- sage/categories/subobjects.py +64 -0
- sage/categories/subquotients.py +21 -0
- sage/categories/with_realizations.py +311 -0
- sage/cpython/__init__.py +19 -0
- sage/cpython/_py2_random.py +619 -0
- sage/cpython/all.py +3 -0
- sage/cpython/atexit.cpython-313-x86_64-linux-musl.so +0 -0
- sage/cpython/atexit.pyx +269 -0
- sage/cpython/builtin_types.cpython-313-x86_64-linux-musl.so +0 -0
- sage/cpython/builtin_types.pyx +7 -0
- sage/cpython/cython_metaclass.cpython-313-x86_64-linux-musl.so +0 -0
- sage/cpython/cython_metaclass.h +117 -0
- sage/cpython/cython_metaclass.pxd +3 -0
- sage/cpython/cython_metaclass.pyx +130 -0
- sage/cpython/debug.cpython-313-x86_64-linux-musl.so +0 -0
- sage/cpython/debug.pyx +302 -0
- sage/cpython/dict_del_by_value.cpython-313-x86_64-linux-musl.so +0 -0
- sage/cpython/dict_del_by_value.pxd +9 -0
- sage/cpython/dict_del_by_value.pyx +191 -0
- sage/cpython/dict_internal.h +245 -0
- sage/cpython/getattr.cpython-313-x86_64-linux-musl.so +0 -0
- sage/cpython/getattr.pxd +9 -0
- sage/cpython/getattr.pyx +439 -0
- sage/cpython/pycore_long.h +97 -0
- sage/cpython/pycore_long.pxd +10 -0
- sage/cpython/python_debug.h +44 -0
- sage/cpython/python_debug.pxd +47 -0
- sage/cpython/pyx_visit.h +13 -0
- sage/cpython/string.cpython-313-x86_64-linux-musl.so +0 -0
- sage/cpython/string.pxd +76 -0
- sage/cpython/string.pyx +34 -0
- sage/cpython/string_impl.h +60 -0
- sage/cpython/type.cpython-313-x86_64-linux-musl.so +0 -0
- sage/cpython/type.pxd +2 -0
- sage/cpython/type.pyx +40 -0
- sage/cpython/wrapperdescr.pxd +67 -0
- sage/ext/all__sagemath_objects.py +3 -0
- sage/ext/ccobject.h +64 -0
- sage/ext/cplusplus.pxd +17 -0
- sage/ext/mod_int.h +30 -0
- sage/ext/mod_int.pxd +24 -0
- sage/ext/stdsage.pxd +39 -0
- sage/groups/all__sagemath_objects.py +1 -0
- sage/groups/group.cpython-313-x86_64-linux-musl.so +0 -0
- sage/groups/group.pxd +14 -0
- sage/groups/group.pyx +322 -0
- sage/groups/old.cpython-313-x86_64-linux-musl.so +0 -0
- sage/groups/old.pxd +14 -0
- sage/groups/old.pyx +219 -0
- sage/libs/all__sagemath_objects.py +3 -0
- sage/libs/gmp/__init__.py +1 -0
- sage/libs/gmp/all.pxd +6 -0
- sage/libs/gmp/binop.pxd +23 -0
- sage/libs/gmp/misc.pxd +8 -0
- sage/libs/gmp/mpf.pxd +88 -0
- sage/libs/gmp/mpn.pxd +57 -0
- sage/libs/gmp/mpq.pxd +57 -0
- sage/libs/gmp/mpz.pxd +202 -0
- sage/libs/gmp/pylong.cpython-313-x86_64-linux-musl.so +0 -0
- sage/libs/gmp/pylong.pxd +12 -0
- sage/libs/gmp/pylong.pyx +150 -0
- sage/libs/gmp/random.pxd +25 -0
- sage/libs/gmp/randomize.pxd +59 -0
- sage/libs/gmp/types.pxd +53 -0
- sage/libs/gmpxx.pxd +19 -0
- sage/misc/abstract_method.py +276 -0
- sage/misc/all__sagemath_objects.py +43 -0
- sage/misc/bindable_class.py +253 -0
- sage/misc/c3_controlled.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/c3_controlled.pxd +2 -0
- sage/misc/c3_controlled.pyx +1402 -0
- sage/misc/cachefunc.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/cachefunc.pxd +43 -0
- sage/misc/cachefunc.pyx +3781 -0
- sage/misc/call.py +188 -0
- sage/misc/classcall_metaclass.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/classcall_metaclass.pxd +14 -0
- sage/misc/classcall_metaclass.pyx +599 -0
- sage/misc/constant_function.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/constant_function.pyx +130 -0
- sage/misc/decorators.py +747 -0
- sage/misc/fast_methods.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/fast_methods.pxd +20 -0
- sage/misc/fast_methods.pyx +351 -0
- sage/misc/flatten.py +90 -0
- sage/misc/fpickle.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/fpickle.pyx +177 -0
- sage/misc/function_mangling.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/function_mangling.pxd +11 -0
- sage/misc/function_mangling.pyx +308 -0
- sage/misc/inherit_comparison.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/inherit_comparison.pxd +5 -0
- sage/misc/inherit_comparison.pyx +105 -0
- sage/misc/instancedoc.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/instancedoc.pyx +331 -0
- sage/misc/lazy_attribute.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/lazy_attribute.pyx +607 -0
- sage/misc/lazy_format.py +135 -0
- sage/misc/lazy_import.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/lazy_import.pyx +1299 -0
- sage/misc/lazy_import_cache.py +36 -0
- sage/misc/lazy_list.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/lazy_list.pxd +19 -0
- sage/misc/lazy_list.pyx +1187 -0
- sage/misc/lazy_string.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/lazy_string.pxd +7 -0
- sage/misc/lazy_string.pyx +546 -0
- sage/misc/misc.py +1066 -0
- sage/misc/misc_c.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/misc_c.pxd +3 -0
- sage/misc/misc_c.pyx +766 -0
- sage/misc/namespace_package.py +37 -0
- sage/misc/nested_class.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/nested_class.pxd +3 -0
- sage/misc/nested_class.pyx +394 -0
- sage/misc/persist.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/persist.pyx +1251 -0
- sage/misc/prandom.py +418 -0
- sage/misc/randstate.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/randstate.pxd +30 -0
- sage/misc/randstate.pyx +1059 -0
- sage/misc/repr.py +203 -0
- sage/misc/reset.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/reset.pyx +196 -0
- sage/misc/sage_ostools.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/sage_ostools.pyx +323 -0
- sage/misc/sage_timeit.py +275 -0
- sage/misc/sage_timeit_class.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/sage_timeit_class.pyx +120 -0
- sage/misc/sage_unittest.py +637 -0
- sage/misc/sageinspect.py +2768 -0
- sage/misc/session.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/session.pyx +392 -0
- sage/misc/superseded.py +557 -0
- sage/misc/test_nested_class.py +228 -0
- sage/misc/timing.py +264 -0
- sage/misc/unknown.py +222 -0
- sage/misc/verbose.py +253 -0
- sage/misc/weak_dict.cpython-313-x86_64-linux-musl.so +0 -0
- sage/misc/weak_dict.pxd +15 -0
- sage/misc/weak_dict.pyx +1231 -0
- sage/modules/all__sagemath_objects.py +1 -0
- sage/modules/module.cpython-313-x86_64-linux-musl.so +0 -0
- sage/modules/module.pxd +5 -0
- sage/modules/module.pyx +329 -0
- sage/rings/all__sagemath_objects.py +3 -0
- sage/rings/integer_fake.h +22 -0
- sage/rings/integer_fake.pxd +55 -0
- sage/sets/all__sagemath_objects.py +3 -0
- sage/sets/pythonclass.cpython-313-x86_64-linux-musl.so +0 -0
- sage/sets/pythonclass.pxd +9 -0
- sage/sets/pythonclass.pyx +247 -0
- sage/structure/__init__.py +4 -0
- sage/structure/all.py +30 -0
- sage/structure/category_object.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/category_object.pxd +28 -0
- sage/structure/category_object.pyx +1087 -0
- sage/structure/coerce.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/coerce.pxd +44 -0
- sage/structure/coerce.pyx +2107 -0
- sage/structure/coerce_actions.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/coerce_actions.pxd +27 -0
- sage/structure/coerce_actions.pyx +988 -0
- sage/structure/coerce_dict.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/coerce_dict.pxd +51 -0
- sage/structure/coerce_dict.pyx +1557 -0
- sage/structure/coerce_exceptions.py +23 -0
- sage/structure/coerce_maps.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/coerce_maps.pxd +28 -0
- sage/structure/coerce_maps.pyx +718 -0
- sage/structure/debug_options.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/debug_options.pxd +6 -0
- sage/structure/debug_options.pyx +54 -0
- sage/structure/dynamic_class.py +541 -0
- sage/structure/element.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/element.pxd +272 -0
- sage/structure/element.pyx +4772 -0
- sage/structure/element_wrapper.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/element_wrapper.pxd +12 -0
- sage/structure/element_wrapper.pyx +582 -0
- sage/structure/factorization.py +1422 -0
- sage/structure/factorization_integer.py +105 -0
- sage/structure/factory.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/factory.pyx +786 -0
- sage/structure/formal_sum.py +489 -0
- sage/structure/gens_py.py +73 -0
- sage/structure/global_options.py +1743 -0
- sage/structure/indexed_generators.py +863 -0
- sage/structure/list_clone.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/list_clone.pxd +65 -0
- sage/structure/list_clone.pyx +1867 -0
- sage/structure/list_clone_demo.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/list_clone_demo.pyx +248 -0
- sage/structure/list_clone_timings.py +179 -0
- sage/structure/list_clone_timings_cy.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/list_clone_timings_cy.pyx +86 -0
- sage/structure/mutability.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/mutability.pxd +21 -0
- sage/structure/mutability.pyx +348 -0
- sage/structure/nonexact.py +69 -0
- sage/structure/parent.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/parent.pxd +112 -0
- sage/structure/parent.pyx +3093 -0
- sage/structure/parent_base.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/parent_base.pxd +13 -0
- sage/structure/parent_base.pyx +44 -0
- sage/structure/parent_gens.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/parent_gens.pxd +22 -0
- sage/structure/parent_gens.pyx +377 -0
- sage/structure/parent_old.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/parent_old.pxd +25 -0
- sage/structure/parent_old.pyx +294 -0
- sage/structure/proof/__init__.py +1 -0
- sage/structure/proof/all.py +243 -0
- sage/structure/proof/proof.py +300 -0
- sage/structure/richcmp.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/richcmp.pxd +213 -0
- sage/structure/richcmp.pyx +495 -0
- sage/structure/sage_object.cpython-313-x86_64-linux-musl.so +0 -0
- sage/structure/sage_object.pxd +3 -0
- sage/structure/sage_object.pyx +988 -0
- sage/structure/sage_object_test.py +19 -0
- sage/structure/sequence.py +937 -0
- sage/structure/set_factories.py +1178 -0
- sage/structure/set_factories_example.py +527 -0
- sage/structure/support_view.py +179 -0
- sage/structure/test_factory.py +56 -0
- sage/structure/unique_representation.py +1359 -0
|
Binary file
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
r"""
|
|
3
|
+
Elements, Array and Lists With Clone Protocol, demonstration classes
|
|
4
|
+
|
|
5
|
+
This module demonstrate the usage of the various classes defined in
|
|
6
|
+
:mod:`~sage.structure.list_clone`
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# ***************************************************************************
|
|
10
|
+
# Copyright (C) 2011 Florent Hivert <Florent.Hivert@univ-rouen.fr>
|
|
11
|
+
#
|
|
12
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
13
|
+
# https://www.gnu.org/licenses/
|
|
14
|
+
# ***************************************************************************
|
|
15
|
+
|
|
16
|
+
from sage.categories.sets_cat import Sets
|
|
17
|
+
from sage.structure.unique_representation import UniqueRepresentation
|
|
18
|
+
from sage.structure.list_clone cimport (
|
|
19
|
+
ClonableArray, ClonableList, NormalizedClonableList, ClonableIntArray)
|
|
20
|
+
from sage.structure.parent import Parent
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
cdef class IncreasingArray(ClonableArray):
|
|
24
|
+
"""
|
|
25
|
+
A small extension class for testing
|
|
26
|
+
:class:`~sage.structure.list_clone.ClonableArray`.
|
|
27
|
+
|
|
28
|
+
TESTS::
|
|
29
|
+
|
|
30
|
+
sage: from sage.structure.list_clone_demo import IncreasingArrays
|
|
31
|
+
sage: TestSuite(IncreasingArrays()([1,2,3])).run()
|
|
32
|
+
sage: TestSuite(IncreasingArrays()([])).run()
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
cpdef check(self):
|
|
36
|
+
"""
|
|
37
|
+
Check that ``self`` is increasing.
|
|
38
|
+
|
|
39
|
+
EXAMPLES::
|
|
40
|
+
|
|
41
|
+
sage: from sage.structure.list_clone_demo import IncreasingArrays
|
|
42
|
+
sage: IncreasingArrays()([1,2,3]) # indirect doctest
|
|
43
|
+
[1, 2, 3]
|
|
44
|
+
sage: IncreasingArrays()([3,2,1]) # indirect doctest
|
|
45
|
+
Traceback (most recent call last):
|
|
46
|
+
...
|
|
47
|
+
ValueError: array is not increasing
|
|
48
|
+
"""
|
|
49
|
+
cdef int i
|
|
50
|
+
for i in range(len(self)-1):
|
|
51
|
+
if self._getitem(i) > self._getitem(i+1):
|
|
52
|
+
raise ValueError("array is not increasing")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class IncreasingArrays(UniqueRepresentation, Parent):
|
|
56
|
+
"""
|
|
57
|
+
A small (incomplete) parent for testing
|
|
58
|
+
:class:`~sage.structure.list_clone.ClonableArray`
|
|
59
|
+
|
|
60
|
+
TESTS::
|
|
61
|
+
|
|
62
|
+
sage: from sage.structure.list_clone_demo import IncreasingArrays
|
|
63
|
+
sage: IncreasingArrays().element_class
|
|
64
|
+
<... 'sage.structure.list_clone_demo.IncreasingArray'>
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(self):
|
|
68
|
+
"""
|
|
69
|
+
TESTS::
|
|
70
|
+
|
|
71
|
+
sage: from sage.structure.list_clone_demo import IncreasingArrays
|
|
72
|
+
sage: IncreasingArrays()
|
|
73
|
+
<sage.structure.list_clone_demo.IncreasingArrays_with_category object at ...>
|
|
74
|
+
sage: IncreasingArrays() == IncreasingArrays()
|
|
75
|
+
True
|
|
76
|
+
"""
|
|
77
|
+
Parent.__init__(self, category = Sets())
|
|
78
|
+
|
|
79
|
+
def _element_constructor_(self, *args, **keywords):
|
|
80
|
+
"""
|
|
81
|
+
TESTS::
|
|
82
|
+
|
|
83
|
+
sage: from sage.structure.list_clone_demo import IncreasingArrays
|
|
84
|
+
sage: IncreasingArrays()([1]) # indirect doctest
|
|
85
|
+
[1]
|
|
86
|
+
"""
|
|
87
|
+
return self.element_class(self, *args, **keywords)
|
|
88
|
+
|
|
89
|
+
Element = IncreasingArray
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class IncreasingLists(IncreasingArrays):
|
|
93
|
+
"""
|
|
94
|
+
A small (incomplete) parent for testing
|
|
95
|
+
:class:`~sage.structure.list_clone.ClonableList`
|
|
96
|
+
|
|
97
|
+
TESTS::
|
|
98
|
+
|
|
99
|
+
sage: from sage.structure.list_clone_demo import IncreasingLists
|
|
100
|
+
sage: IncreasingLists().element_class
|
|
101
|
+
<... 'sage.structure.list_clone_demo.IncreasingList'>
|
|
102
|
+
"""
|
|
103
|
+
Element = IncreasingList
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
cdef class IncreasingList(ClonableList):
|
|
107
|
+
"""
|
|
108
|
+
A small extension class for testing
|
|
109
|
+
:class:`~sage.structure.list_clone.ClonableList`
|
|
110
|
+
|
|
111
|
+
TESTS::
|
|
112
|
+
|
|
113
|
+
sage: from sage.structure.list_clone_demo import IncreasingLists
|
|
114
|
+
sage: TestSuite(IncreasingLists()([1,2,3])).run()
|
|
115
|
+
sage: TestSuite(IncreasingLists()([])).run()
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
cpdef check(self):
|
|
119
|
+
"""
|
|
120
|
+
Check that ``self`` is increasing.
|
|
121
|
+
|
|
122
|
+
EXAMPLES::
|
|
123
|
+
|
|
124
|
+
sage: from sage.structure.list_clone_demo import IncreasingLists
|
|
125
|
+
sage: IncreasingLists()([1,2,3]) # indirect doctest
|
|
126
|
+
[1, 2, 3]
|
|
127
|
+
sage: IncreasingLists()([3,2,1]) # indirect doctest
|
|
128
|
+
Traceback (most recent call last):
|
|
129
|
+
...
|
|
130
|
+
ValueError: array is not increasing
|
|
131
|
+
"""
|
|
132
|
+
cdef int i
|
|
133
|
+
for i in range(len(self)-1):
|
|
134
|
+
if self._getitem(i) >= self._getitem(i+1):
|
|
135
|
+
raise ValueError("array is not increasing")
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
cdef class IncreasingIntArray(ClonableIntArray):
|
|
139
|
+
"""
|
|
140
|
+
A small extension class for testing
|
|
141
|
+
:class:`~sage.structure.list_clone.ClonableIntArray`.
|
|
142
|
+
|
|
143
|
+
TESTS::
|
|
144
|
+
|
|
145
|
+
sage: from sage.structure.list_clone_demo import IncreasingIntArrays
|
|
146
|
+
sage: TestSuite(IncreasingIntArrays()([1,2,3])).run()
|
|
147
|
+
sage: TestSuite(IncreasingIntArrays()([])).run()
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
cpdef check(self):
|
|
151
|
+
"""
|
|
152
|
+
Check that ``self`` is increasing.
|
|
153
|
+
|
|
154
|
+
EXAMPLES::
|
|
155
|
+
|
|
156
|
+
sage: from sage.structure.list_clone_demo import IncreasingIntArrays
|
|
157
|
+
sage: IncreasingIntArrays()([1,2,3]) # indirect doctest
|
|
158
|
+
[1, 2, 3]
|
|
159
|
+
sage: IncreasingIntArrays()([3,2,1]) # indirect doctest
|
|
160
|
+
Traceback (most recent call last):
|
|
161
|
+
...
|
|
162
|
+
ValueError: array is not increasing
|
|
163
|
+
"""
|
|
164
|
+
cdef int i
|
|
165
|
+
if not self:
|
|
166
|
+
return
|
|
167
|
+
for i in range(len(self)-1):
|
|
168
|
+
if self._getitem(i) >= self._getitem(i+1):
|
|
169
|
+
raise ValueError("array is not increasing")
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class IncreasingIntArrays(IncreasingArrays):
|
|
173
|
+
"""
|
|
174
|
+
A small (incomplete) parent for testing
|
|
175
|
+
:class:`~sage.structure.list_clone.ClonableIntArray`
|
|
176
|
+
|
|
177
|
+
TESTS::
|
|
178
|
+
|
|
179
|
+
sage: from sage.structure.list_clone_demo import IncreasingIntArrays
|
|
180
|
+
sage: IncreasingIntArrays().element_class
|
|
181
|
+
<... 'sage.structure.list_clone_demo.IncreasingIntArray'>
|
|
182
|
+
"""
|
|
183
|
+
Element = IncreasingIntArray
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
cdef class SortedList(NormalizedClonableList):
|
|
187
|
+
"""
|
|
188
|
+
A small extension class for testing
|
|
189
|
+
:class:`~sage.structure.list_clone.NormalizedClonableList`.
|
|
190
|
+
|
|
191
|
+
TESTS::
|
|
192
|
+
|
|
193
|
+
sage: from sage.structure.list_clone_demo import IncreasingIntArrays
|
|
194
|
+
sage: TestSuite(IncreasingIntArrays()([1,2,3])).run()
|
|
195
|
+
sage: TestSuite(IncreasingIntArrays()([])).run()
|
|
196
|
+
"""
|
|
197
|
+
cpdef normalize(self):
|
|
198
|
+
"""
|
|
199
|
+
Normalize ``self``.
|
|
200
|
+
|
|
201
|
+
Sort the list stored in ``self``.
|
|
202
|
+
|
|
203
|
+
EXAMPLES::
|
|
204
|
+
|
|
205
|
+
sage: from sage.structure.list_clone_demo import SortedList, SortedLists
|
|
206
|
+
sage: l = SortedList(SortedLists(), [3,1,2], False, False)
|
|
207
|
+
sage: l # indirect doctest
|
|
208
|
+
[1, 2, 3]
|
|
209
|
+
sage: l[1] = 5; l
|
|
210
|
+
[1, 5, 3]
|
|
211
|
+
sage: l.normalize(); l
|
|
212
|
+
[1, 3, 5]
|
|
213
|
+
"""
|
|
214
|
+
self._require_mutable()
|
|
215
|
+
self._get_list().sort()
|
|
216
|
+
|
|
217
|
+
cpdef check(self):
|
|
218
|
+
"""
|
|
219
|
+
Check that ``self`` is strictly increasing.
|
|
220
|
+
|
|
221
|
+
EXAMPLES::
|
|
222
|
+
|
|
223
|
+
sage: from sage.structure.list_clone_demo import SortedList, SortedLists
|
|
224
|
+
sage: SortedLists()([1,2,3]) # indirect doctest
|
|
225
|
+
[1, 2, 3]
|
|
226
|
+
sage: SortedLists()([3,2,2]) # indirect doctest
|
|
227
|
+
Traceback (most recent call last):
|
|
228
|
+
...
|
|
229
|
+
ValueError: list is not strictly increasing
|
|
230
|
+
"""
|
|
231
|
+
for i in range(len(self)-1):
|
|
232
|
+
if self._getitem(i) >= self._getitem(i+1):
|
|
233
|
+
raise ValueError("list is not strictly increasing")
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class SortedLists(IncreasingLists):
|
|
237
|
+
"""
|
|
238
|
+
A small (incomplete) parent for testing
|
|
239
|
+
:class:`~sage.structure.list_clone.NormalizedClonableList`
|
|
240
|
+
|
|
241
|
+
TESTS::
|
|
242
|
+
|
|
243
|
+
sage: from sage.structure.list_clone_demo import SortedList, SortedLists
|
|
244
|
+
sage: SL = SortedLists()
|
|
245
|
+
sage: SL([3,1,2])
|
|
246
|
+
[1, 2, 3]
|
|
247
|
+
"""
|
|
248
|
+
Element = SortedList
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
"""
|
|
3
|
+
Performance Test for Clone Protocol
|
|
4
|
+
|
|
5
|
+
see :class:`sage.structure.list_clone.ClonableArray`
|
|
6
|
+
|
|
7
|
+
EXAMPLES::
|
|
8
|
+
|
|
9
|
+
sage: from sage.structure.list_clone_timings import *
|
|
10
|
+
sage: cmd =["",
|
|
11
|
+
....: "e.__copy__()",
|
|
12
|
+
....: "copy(e)",
|
|
13
|
+
....: "e.clone()",
|
|
14
|
+
....: "e.__class__(e.parent(), e._get_list())",
|
|
15
|
+
....: "e.__class__(e.parent(), e[:])",
|
|
16
|
+
....: "e.check()",
|
|
17
|
+
....: "",
|
|
18
|
+
....: "add1_internal(e)",
|
|
19
|
+
....: "add1_immutable(e)",
|
|
20
|
+
....: "add1_mutable(e)",
|
|
21
|
+
....: "add1_with(e)",
|
|
22
|
+
....: "",
|
|
23
|
+
....: "cy_add1_internal(e)",
|
|
24
|
+
....: "cy_add1_immutable(e)",
|
|
25
|
+
....: "cy_add1_mutable(e)",
|
|
26
|
+
....: "cy_add1_with(e)"]
|
|
27
|
+
|
|
28
|
+
Various timings using a Cython class::
|
|
29
|
+
|
|
30
|
+
sage: size = 5
|
|
31
|
+
sage: e = IncreasingArrays()(range(size))
|
|
32
|
+
sage: # random
|
|
33
|
+
....: for p in cmd:
|
|
34
|
+
....: print("{0:36} : ".format(p), end=""); timeit(p)
|
|
35
|
+
:
|
|
36
|
+
e.__copy__() : 625 loops, best of 3: 446 ns per loop
|
|
37
|
+
copy(e) : 625 loops, best of 3: 1.94 µs per loop
|
|
38
|
+
e.clone() : 625 loops, best of 3: 736 ns per loop
|
|
39
|
+
e.__class__(e.parent(), e._get_list()) : 625 loops, best of 3: 1.34 µs per loop
|
|
40
|
+
e.__class__(e.parent(), e[:]) : 625 loops, best of 3: 1.35 µs per loop
|
|
41
|
+
e.check() : 625 loops, best of 3: 342 ns per loop
|
|
42
|
+
:
|
|
43
|
+
add1_internal(e) : 625 loops, best of 3: 3.53 µs per loop
|
|
44
|
+
add1_immutable(e) : 625 loops, best of 3: 3.72 µs per loop
|
|
45
|
+
add1_mutable(e) : 625 loops, best of 3: 3.42 µs per loop
|
|
46
|
+
add1_with(e) : 625 loops, best of 3: 4.05 µs per loop
|
|
47
|
+
:
|
|
48
|
+
cy_add1_internal(e) : 625 loops, best of 3: 752 ns per loop
|
|
49
|
+
cy_add1_immutable(e) : 625 loops, best of 3: 1.28 µs per loop
|
|
50
|
+
cy_add1_mutable(e) : 625 loops, best of 3: 861 ns per loop
|
|
51
|
+
cy_add1_with(e) : 625 loops, best of 3: 1.51 µs per loop
|
|
52
|
+
|
|
53
|
+
Various timings using a Python class::
|
|
54
|
+
|
|
55
|
+
sage: e = IncreasingArraysPy()(range(size))
|
|
56
|
+
sage: # random
|
|
57
|
+
....: for p in cmd: print("{0:36} : ".format(p), end=""); timeit(p)
|
|
58
|
+
:
|
|
59
|
+
e.__copy__() : 625 loops, best of 3: 869 ns per loop
|
|
60
|
+
copy(e) : 625 loops, best of 3: 2.13 µs per loop
|
|
61
|
+
e.clone() : 625 loops, best of 3: 1.86 µs per loop
|
|
62
|
+
e.__class__(e.parent(), e._get_list()) : 625 loops, best of 3: 7.52 µs per loop
|
|
63
|
+
e.__class__(e.parent(), e[:]) : 625 loops, best of 3: 7.27 µs per loop
|
|
64
|
+
e.check() : 625 loops, best of 3: 4.02 µs per loop
|
|
65
|
+
:
|
|
66
|
+
add1_internal(e) : 625 loops, best of 3: 9.34 µs per loop
|
|
67
|
+
add1_immutable(e) : 625 loops, best of 3: 9.91 µs per loop
|
|
68
|
+
add1_mutable(e) : 625 loops, best of 3: 12.6 µs per loop
|
|
69
|
+
add1_with(e) : 625 loops, best of 3: 15.9 µs per loop
|
|
70
|
+
:
|
|
71
|
+
cy_add1_internal(e) : 625 loops, best of 3: 7.13 µs per loop
|
|
72
|
+
cy_add1_immutable(e) : 625 loops, best of 3: 6.95 µs per loop
|
|
73
|
+
cy_add1_mutable(e) : 625 loops, best of 3: 14.1 µs per loop
|
|
74
|
+
cy_add1_with(e) : 625 loops, best of 3: 17.5 µs per loop
|
|
75
|
+
"""
|
|
76
|
+
# ****************************************************************************
|
|
77
|
+
# Copyright (C) 2009-2010 Florent Hivert <Florent.Hivert@univ-rouen.fr>
|
|
78
|
+
#
|
|
79
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
80
|
+
# https://www.gnu.org/licenses/
|
|
81
|
+
# ****************************************************************************
|
|
82
|
+
|
|
83
|
+
from sage.structure.list_clone import ClonableArray
|
|
84
|
+
from sage.structure.list_clone_demo import IncreasingArrays
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class IncreasingArraysPy(IncreasingArrays):
|
|
88
|
+
|
|
89
|
+
class Element(ClonableArray):
|
|
90
|
+
"""
|
|
91
|
+
A small class for testing :class:`ClonableArray`: Increasing Lists.
|
|
92
|
+
|
|
93
|
+
TESTS::
|
|
94
|
+
|
|
95
|
+
sage: from sage.structure.list_clone_timings import IncreasingArraysPy
|
|
96
|
+
sage: TestSuite(IncreasingArraysPy()([1,2,3])).run()
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
def check(self):
|
|
100
|
+
"""
|
|
101
|
+
Check that ``self`` is increasing.
|
|
102
|
+
|
|
103
|
+
EXAMPLES::
|
|
104
|
+
|
|
105
|
+
sage: from sage.structure.list_clone_timings import IncreasingArraysPy
|
|
106
|
+
sage: IncreasingArraysPy()([1,2,3]) # indirect doctest
|
|
107
|
+
[1, 2, 3]
|
|
108
|
+
sage: IncreasingArraysPy()([3,2,1]) # indirect doctest
|
|
109
|
+
Traceback (most recent call last):
|
|
110
|
+
...
|
|
111
|
+
ValueError: Lists is not increasing
|
|
112
|
+
"""
|
|
113
|
+
for i in range(len(self)-1):
|
|
114
|
+
if self[i] >= self[i+1]:
|
|
115
|
+
raise ValueError("Lists is not increasing")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
#####################################################################
|
|
119
|
+
# Timings functions #
|
|
120
|
+
#####################################################################
|
|
121
|
+
def add1_internal(bla):
|
|
122
|
+
"""
|
|
123
|
+
TESTS::
|
|
124
|
+
|
|
125
|
+
sage: from sage.structure.list_clone_timings import *
|
|
126
|
+
sage: add1_internal(IncreasingArrays()([1,4,5]))
|
|
127
|
+
[2, 5, 6]
|
|
128
|
+
"""
|
|
129
|
+
blo = bla.__copy__()
|
|
130
|
+
lst = blo._get_list()
|
|
131
|
+
for i in range(len(blo)):
|
|
132
|
+
lst[i] += 1
|
|
133
|
+
blo.set_immutable()
|
|
134
|
+
blo.check()
|
|
135
|
+
return blo
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def add1_immutable(bla):
|
|
139
|
+
"""
|
|
140
|
+
TESTS::
|
|
141
|
+
|
|
142
|
+
sage: from sage.structure.list_clone_timings import *
|
|
143
|
+
sage: add1_immutable(IncreasingArrays()([1,4,5]))
|
|
144
|
+
[2, 5, 6]
|
|
145
|
+
"""
|
|
146
|
+
lbla = bla[:]
|
|
147
|
+
for i in range(len(lbla)):
|
|
148
|
+
lbla[i] += 1
|
|
149
|
+
return bla.__class__(bla.parent(), lbla)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def add1_mutable(bla):
|
|
153
|
+
"""
|
|
154
|
+
TESTS::
|
|
155
|
+
|
|
156
|
+
sage: from sage.structure.list_clone_timings import *
|
|
157
|
+
sage: add1_mutable(IncreasingArrays()([1,4,5]))
|
|
158
|
+
[2, 5, 6]
|
|
159
|
+
"""
|
|
160
|
+
blo = bla.__copy__()
|
|
161
|
+
for i in range(len(blo)):
|
|
162
|
+
blo[i] += 1
|
|
163
|
+
blo.set_immutable()
|
|
164
|
+
blo.check()
|
|
165
|
+
return blo
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def add1_with(bla):
|
|
169
|
+
"""
|
|
170
|
+
TESTS::
|
|
171
|
+
|
|
172
|
+
sage: from sage.structure.list_clone_timings import *
|
|
173
|
+
sage: add1_with(IncreasingArrays()([1,4,5]))
|
|
174
|
+
[2, 5, 6]
|
|
175
|
+
"""
|
|
176
|
+
with bla.clone() as blo:
|
|
177
|
+
for i in range(len(blo)):
|
|
178
|
+
blo[i] += 1
|
|
179
|
+
return blo
|
|
Binary file
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
"""
|
|
3
|
+
Cython Functions for Timing Clone Protocol
|
|
4
|
+
"""
|
|
5
|
+
# ***************************************************************************
|
|
6
|
+
# Copyright (C) 2009-2010 Florent Hivert <Florent.Hivert@univ-rouen.fr>
|
|
7
|
+
#
|
|
8
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
9
|
+
# https://www.gnu.org/licenses/
|
|
10
|
+
# ***************************************************************************
|
|
11
|
+
|
|
12
|
+
from sage.structure.list_clone cimport ClonableArray
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#####################################################################
|
|
16
|
+
###### Timings functions ######
|
|
17
|
+
#####################################################################
|
|
18
|
+
cpdef ClonableArray cy_add1_internal(ClonableArray bla):
|
|
19
|
+
"""
|
|
20
|
+
TESTS::
|
|
21
|
+
|
|
22
|
+
sage: from sage.structure.list_clone_timings_cy import *
|
|
23
|
+
sage: from sage.structure.list_clone_timings import *
|
|
24
|
+
sage: cy_add1_internal(IncreasingArrays()([1,4,5]))
|
|
25
|
+
[2, 5, 6]
|
|
26
|
+
"""
|
|
27
|
+
cdef int i
|
|
28
|
+
cdef list lst
|
|
29
|
+
cdef ClonableArray blo
|
|
30
|
+
blo = bla.__copy__()
|
|
31
|
+
lst = blo._get_list()
|
|
32
|
+
for i in range(len(lst)): lst[i] += 1
|
|
33
|
+
blo.set_immutable()
|
|
34
|
+
blo.check()
|
|
35
|
+
return blo
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
cpdef ClonableArray cy_add1_immutable(ClonableArray bla):
|
|
39
|
+
"""
|
|
40
|
+
TESTS::
|
|
41
|
+
|
|
42
|
+
sage: from sage.structure.list_clone_timings import *
|
|
43
|
+
sage: from sage.structure.list_clone_timings_cy import *
|
|
44
|
+
sage: cy_add1_immutable(IncreasingArrays()([1,4,5]))
|
|
45
|
+
[2, 5, 6]
|
|
46
|
+
"""
|
|
47
|
+
cdef int i
|
|
48
|
+
cdef list lbla
|
|
49
|
+
lbla = bla[:]
|
|
50
|
+
for i in range(len(lbla)): lbla[i] += 1
|
|
51
|
+
return bla.__class__(bla._parent, lbla)
|
|
52
|
+
|
|
53
|
+
cpdef ClonableArray cy_add1_mutable(ClonableArray bla):
|
|
54
|
+
"""
|
|
55
|
+
TESTS::
|
|
56
|
+
|
|
57
|
+
sage: from sage.structure.list_clone_timings import *
|
|
58
|
+
sage: from sage.structure.list_clone_timings_cy import *
|
|
59
|
+
sage: cy_add1_mutable(IncreasingArrays()([1,4,5]))
|
|
60
|
+
[2, 5, 6]
|
|
61
|
+
"""
|
|
62
|
+
cdef int i
|
|
63
|
+
cdef ClonableArray blo
|
|
64
|
+
blo = bla.__copy__()
|
|
65
|
+
for i in range(len(blo)):
|
|
66
|
+
blo._setitem(i, blo._getitem(i)+1)
|
|
67
|
+
blo.set_immutable()
|
|
68
|
+
blo.check()
|
|
69
|
+
return blo
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
cpdef ClonableArray cy_add1_with(ClonableArray bla):
|
|
73
|
+
"""
|
|
74
|
+
TESTS::
|
|
75
|
+
|
|
76
|
+
sage: from sage.structure.list_clone_timings import *
|
|
77
|
+
sage: from sage.structure.list_clone_timings_cy import *
|
|
78
|
+
sage: cy_add1_with(IncreasingArrays()([1,4,5]))
|
|
79
|
+
[2, 5, 6]
|
|
80
|
+
"""
|
|
81
|
+
cdef int i
|
|
82
|
+
cdef ClonableArray blo
|
|
83
|
+
with bla.__copy__() as blo:
|
|
84
|
+
for i in range(len(blo)):
|
|
85
|
+
blo._setitem(i, blo._getitem(i)+1)
|
|
86
|
+
return blo
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
"""
|
|
3
|
+
Mutability -- Pyrex Implementation
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
##########################################################################
|
|
7
|
+
#
|
|
8
|
+
# Sage: Open Source Mathematical Software
|
|
9
|
+
#
|
|
10
|
+
# Copyright (C) 2006 William Stein <wstein@ucsd.edu>
|
|
11
|
+
#
|
|
12
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
13
|
+
# https://www.gnu.org/licenses/
|
|
14
|
+
##########################################################################
|
|
15
|
+
|
|
16
|
+
cdef class Mutability:
|
|
17
|
+
cdef public bint _is_immutable
|
|
18
|
+
cpdef _require_mutable(self)
|
|
19
|
+
cpdef _require_immutable(self)
|
|
20
|
+
cpdef bint is_immutable(self) noexcept
|
|
21
|
+
cpdef bint is_mutable(self) noexcept
|