passagemath-objects 10.6.46__cp314-cp314t-macosx_13_0_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/.dylibs/libgmp.10.dylib +0 -0
- passagemath_objects/__init__.py +3 -0
- passagemath_objects-10.6.46.dist-info/METADATA +115 -0
- passagemath_objects-10.6.46.dist-info/RECORD +280 -0
- passagemath_objects-10.6.46.dist-info/WHEEL +6 -0
- passagemath_objects-10.6.46.dist-info/top_level.txt +3 -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-314t-darwin.so +0 -0
- sage/arith/numerical_approx.pxd +35 -0
- sage/arith/numerical_approx.pyx +75 -0
- sage/arith/power.cpython-314t-darwin.so +0 -0
- sage/arith/power.pxd +31 -0
- sage/arith/power.pyx +127 -0
- sage/categories/action.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/categories/category_cy_helper.pxd +8 -0
- sage/categories/category_cy_helper.pyx +322 -0
- sage/categories/category_singleton.cpython-314t-darwin.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-314t-darwin.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-314t-darwin.so +0 -0
- sage/categories/map.pxd +34 -0
- sage/categories/map.pyx +2106 -0
- sage/categories/morphism.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/cpython/atexit.pyx +269 -0
- sage/cpython/builtin_types.cpython-314t-darwin.so +0 -0
- sage/cpython/builtin_types.pyx +7 -0
- sage/cpython/cython_metaclass.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/cpython/debug.pyx +302 -0
- sage/cpython/dict_del_by_value.cpython-314t-darwin.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-314t-darwin.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-314t-darwin.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-314t-darwin.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-314t-darwin.so +0 -0
- sage/groups/group.pxd +14 -0
- sage/groups/group.pyx +322 -0
- sage/groups/old.cpython-314t-darwin.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-314t-darwin.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-314t-darwin.so +0 -0
- sage/misc/c3_controlled.pxd +2 -0
- sage/misc/c3_controlled.pyx +1402 -0
- sage/misc/cachefunc.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/misc/classcall_metaclass.pxd +14 -0
- sage/misc/classcall_metaclass.pyx +599 -0
- sage/misc/constant_function.cpython-314t-darwin.so +0 -0
- sage/misc/constant_function.pyx +130 -0
- sage/misc/decorators.py +747 -0
- sage/misc/fast_methods.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/misc/fpickle.pyx +177 -0
- sage/misc/function_mangling.cpython-314t-darwin.so +0 -0
- sage/misc/function_mangling.pxd +11 -0
- sage/misc/function_mangling.pyx +308 -0
- sage/misc/inherit_comparison.cpython-314t-darwin.so +0 -0
- sage/misc/inherit_comparison.pxd +5 -0
- sage/misc/inherit_comparison.pyx +105 -0
- sage/misc/instancedoc.cpython-314t-darwin.so +0 -0
- sage/misc/instancedoc.pyx +331 -0
- sage/misc/lazy_attribute.cpython-314t-darwin.so +0 -0
- sage/misc/lazy_attribute.pyx +607 -0
- sage/misc/lazy_format.py +135 -0
- sage/misc/lazy_import.cpython-314t-darwin.so +0 -0
- sage/misc/lazy_import.pyx +1299 -0
- sage/misc/lazy_import_cache.py +36 -0
- sage/misc/lazy_list.cpython-314t-darwin.so +0 -0
- sage/misc/lazy_list.pxd +19 -0
- sage/misc/lazy_list.pyx +1187 -0
- sage/misc/lazy_string.cpython-314t-darwin.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-314t-darwin.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-314t-darwin.so +0 -0
- sage/misc/nested_class.pxd +3 -0
- sage/misc/nested_class.pyx +394 -0
- sage/misc/persist.cpython-314t-darwin.so +0 -0
- sage/misc/persist.pyx +1251 -0
- sage/misc/prandom.py +418 -0
- sage/misc/randstate.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/misc/reset.pyx +196 -0
- sage/misc/sage_ostools.cpython-314t-darwin.so +0 -0
- sage/misc/sage_ostools.pyx +323 -0
- sage/misc/sage_timeit.py +275 -0
- sage/misc/sage_timeit_class.cpython-314t-darwin.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-314t-darwin.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-314t-darwin.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-314t-darwin.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-314t-darwin.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-314t-darwin.so +0 -0
- sage/structure/category_object.pxd +28 -0
- sage/structure/category_object.pyx +1087 -0
- sage/structure/coerce.cpython-314t-darwin.so +0 -0
- sage/structure/coerce.pxd +44 -0
- sage/structure/coerce.pyx +2107 -0
- sage/structure/coerce_actions.cpython-314t-darwin.so +0 -0
- sage/structure/coerce_actions.pxd +27 -0
- sage/structure/coerce_actions.pyx +988 -0
- sage/structure/coerce_dict.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/structure/coerce_maps.pxd +28 -0
- sage/structure/coerce_maps.pyx +718 -0
- sage/structure/debug_options.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/structure/element.pxd +272 -0
- sage/structure/element.pyx +4772 -0
- sage/structure/element_wrapper.cpython-314t-darwin.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-314t-darwin.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-314t-darwin.so +0 -0
- sage/structure/list_clone.pxd +65 -0
- sage/structure/list_clone.pyx +1867 -0
- sage/structure/list_clone_demo.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/structure/list_clone_timings_cy.pyx +86 -0
- sage/structure/mutability.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/structure/parent.pxd +112 -0
- sage/structure/parent.pyx +3093 -0
- sage/structure/parent_base.cpython-314t-darwin.so +0 -0
- sage/structure/parent_base.pxd +13 -0
- sage/structure/parent_base.pyx +44 -0
- sage/structure/parent_gens.cpython-314t-darwin.so +0 -0
- sage/structure/parent_gens.pxd +22 -0
- sage/structure/parent_gens.pyx +377 -0
- sage/structure/parent_old.cpython-314t-darwin.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-314t-darwin.so +0 -0
- sage/structure/richcmp.pxd +213 -0
- sage/structure/richcmp.pyx +495 -0
- sage/structure/sage_object.cpython-314t-darwin.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
Binary file
|
sage/modules/module.pxd
ADDED
sage/modules/module.pyx
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
"""
|
|
3
|
+
Abstract base class for modules
|
|
4
|
+
|
|
5
|
+
AUTHORS:
|
|
6
|
+
|
|
7
|
+
- William Stein: initial version
|
|
8
|
+
|
|
9
|
+
- Julian Rueth (2014-05-10): category parameter for Module, doc cleanup
|
|
10
|
+
|
|
11
|
+
EXAMPLES:
|
|
12
|
+
|
|
13
|
+
A minimal example of a module::
|
|
14
|
+
|
|
15
|
+
sage: from sage.structure.richcmp import richcmp
|
|
16
|
+
sage: class MyElement(sage.structure.element.ModuleElement):
|
|
17
|
+
....: def __init__(self, parent, x):
|
|
18
|
+
....: self.x = x
|
|
19
|
+
....: sage.structure.element.ModuleElement.__init__(self, parent=parent)
|
|
20
|
+
....: def _lmul_(self, c):
|
|
21
|
+
....: return self.parent()(c*self.x)
|
|
22
|
+
....: def _add_(self, other):
|
|
23
|
+
....: return self.parent()(self.x + other.x)
|
|
24
|
+
....: def _richcmp_(self, other, op):
|
|
25
|
+
....: return richcmp(self.x, other.x, op)
|
|
26
|
+
....: def __hash__(self):
|
|
27
|
+
....: return hash(self.x)
|
|
28
|
+
....: def _repr_(self):
|
|
29
|
+
....: return repr(self.x)
|
|
30
|
+
|
|
31
|
+
sage: from sage.modules.module import Module
|
|
32
|
+
sage: class MyModule(Module):
|
|
33
|
+
....: Element = MyElement
|
|
34
|
+
....: def _element_constructor_(self, x):
|
|
35
|
+
....: if isinstance(x, MyElement): x = x.x
|
|
36
|
+
....: return self.element_class(self, self.base_ring()(x))
|
|
37
|
+
....: def __eq__(self, other):
|
|
38
|
+
....: if not isinstance(other, MyModule): return False
|
|
39
|
+
....: return self.base_ring() == other.base_ring()
|
|
40
|
+
....: def __hash__(self):
|
|
41
|
+
....: return hash(self.base_ring())
|
|
42
|
+
|
|
43
|
+
sage: M = MyModule(QQ)
|
|
44
|
+
sage: M(1)
|
|
45
|
+
1
|
|
46
|
+
|
|
47
|
+
sage: import __main__
|
|
48
|
+
sage: __main__.MyModule = MyModule
|
|
49
|
+
sage: __main__.MyElement = MyElement
|
|
50
|
+
sage: TestSuite(M).run()
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
#*****************************************************************************
|
|
54
|
+
# Copyright (C) 2005 William Stein <wstein@gmail.com>
|
|
55
|
+
# 2014 Julian Rueth <julian.rueth@fsfe.org>
|
|
56
|
+
#
|
|
57
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
58
|
+
#
|
|
59
|
+
# This code is distributed in the hope that it will be useful,
|
|
60
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
61
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
62
|
+
# General Public License for more details.
|
|
63
|
+
#
|
|
64
|
+
# The full text of the GPL is available at:
|
|
65
|
+
#
|
|
66
|
+
# http://www.gnu.org/licenses/
|
|
67
|
+
#*****************************************************************************
|
|
68
|
+
|
|
69
|
+
cdef class Module(Parent):
|
|
70
|
+
"""
|
|
71
|
+
Generic module class.
|
|
72
|
+
|
|
73
|
+
INPUT:
|
|
74
|
+
|
|
75
|
+
- ``base`` -- a ring; the base ring of the module
|
|
76
|
+
|
|
77
|
+
- ``category`` -- a category (default: ``None``), the category for this
|
|
78
|
+
module. If ``None``, then this is set to the category of modules/vector
|
|
79
|
+
spaces over ``base``.
|
|
80
|
+
|
|
81
|
+
- ``names`` -- names of generators
|
|
82
|
+
|
|
83
|
+
EXAMPLES::
|
|
84
|
+
|
|
85
|
+
sage: from sage.modules.module import Module
|
|
86
|
+
sage: M = Module(ZZ)
|
|
87
|
+
sage: M.base_ring()
|
|
88
|
+
Integer Ring
|
|
89
|
+
sage: M.category()
|
|
90
|
+
Category of modules over Integer Ring
|
|
91
|
+
|
|
92
|
+
Normally the category is set to the category of modules over ``base``. If
|
|
93
|
+
``base`` is a field, then the category is the category of vector spaces
|
|
94
|
+
over ``base``::
|
|
95
|
+
|
|
96
|
+
sage: M_QQ = Module(QQ)
|
|
97
|
+
sage: M_QQ.category()
|
|
98
|
+
Category of vector spaces over Rational Field
|
|
99
|
+
|
|
100
|
+
The ``category`` parameter can be used to set a more specific category::
|
|
101
|
+
|
|
102
|
+
sage: N = Module(ZZ, category=FiniteDimensionalModulesWithBasis(ZZ))
|
|
103
|
+
sage: N.category()
|
|
104
|
+
Category of finite dimensional modules with basis over Integer Ring
|
|
105
|
+
|
|
106
|
+
TESTS:
|
|
107
|
+
|
|
108
|
+
We check that :issue:`8119` has been resolved::
|
|
109
|
+
|
|
110
|
+
sage: # needs sage.modules
|
|
111
|
+
sage: M = ZZ^3
|
|
112
|
+
sage: h = M.__hash__()
|
|
113
|
+
sage: M.rename('toto')
|
|
114
|
+
sage: h == M.__hash__()
|
|
115
|
+
True
|
|
116
|
+
"""
|
|
117
|
+
def __init__(self, base, category=None, names=None):
|
|
118
|
+
"""
|
|
119
|
+
Initialization.
|
|
120
|
+
|
|
121
|
+
TESTS::
|
|
122
|
+
|
|
123
|
+
sage: from sage.modules.module import Module
|
|
124
|
+
sage: M = Module(ZZ)
|
|
125
|
+
sage: type(M)
|
|
126
|
+
<class 'sage.modules.module.Module'>
|
|
127
|
+
"""
|
|
128
|
+
from sage.categories.modules import Modules
|
|
129
|
+
if category is None:
|
|
130
|
+
category = Modules(base)
|
|
131
|
+
Parent.__init__(self, base=base, category=category, names=names)
|
|
132
|
+
|
|
133
|
+
cpdef _coerce_map_from_(self, M):
|
|
134
|
+
"""
|
|
135
|
+
Return a coercion map from `M` to ``self``, or None.
|
|
136
|
+
|
|
137
|
+
The implementation of this method in module classes should
|
|
138
|
+
observe the following guidelines:
|
|
139
|
+
|
|
140
|
+
1. We want to relate two different *ambient* modules if and
|
|
141
|
+
only if they have the same rank (which is the same as
|
|
142
|
+
degree) and if there is a coercion of the base rings.
|
|
143
|
+
|
|
144
|
+
2. Two modules embedded in other modules that have a coercion
|
|
145
|
+
may inherit a coercion if they are in fact sub-modules of
|
|
146
|
+
one another.
|
|
147
|
+
|
|
148
|
+
3. Since different embeddings of one abstract module are
|
|
149
|
+
related by non-identical coerce maps (in 2.), we must not
|
|
150
|
+
have coercion from a sub-module to the corresponding
|
|
151
|
+
abstract module, for otherwise non-commuting coercion
|
|
152
|
+
triangles emerge.
|
|
153
|
+
|
|
154
|
+
4. Quotient modules must not coerce unless their modulus `W`
|
|
155
|
+
is the same. There must not be forgetful maps.
|
|
156
|
+
|
|
157
|
+
5. Coerce maps for quotient modules are already registered on
|
|
158
|
+
construction.
|
|
159
|
+
|
|
160
|
+
TESTS:
|
|
161
|
+
|
|
162
|
+
Make sure :issue:`3638` is fixed::
|
|
163
|
+
|
|
164
|
+
sage: vector(ZZ,[1,2,11]) == vector(Zmod(8),[1,2,3]) # needs sage.modules
|
|
165
|
+
True
|
|
166
|
+
|
|
167
|
+
AUTHORS:
|
|
168
|
+
|
|
169
|
+
- Simon King (2010-12)
|
|
170
|
+
|
|
171
|
+
- Peter Bruin (June 2014)
|
|
172
|
+
"""
|
|
173
|
+
try:
|
|
174
|
+
if (isinstance(M, Module)
|
|
175
|
+
and self.base_ring().has_coerce_map_from(M.base_ring())
|
|
176
|
+
and M.change_ring(self.base_ring()).is_submodule(self)):
|
|
177
|
+
return M.hom([self._element_constructor_(x) for x in M.gens()], self)
|
|
178
|
+
except (TypeError, NotImplementedError, AttributeError, ArithmeticError):
|
|
179
|
+
pass
|
|
180
|
+
return None
|
|
181
|
+
|
|
182
|
+
def change_ring(self, R):
|
|
183
|
+
"""
|
|
184
|
+
Return the base change of ``self`` to `R`.
|
|
185
|
+
|
|
186
|
+
EXAMPLES::
|
|
187
|
+
|
|
188
|
+
sage: from sage.modular.modform.space import ModularFormsSpace # needs sage.modular
|
|
189
|
+
sage: ModularFormsSpace(Gamma0(11), 2, # needs sage.modular sage.rings.finite_rings
|
|
190
|
+
....: DirichletGroup(1)[0], QQ).change_ring(GF(7))
|
|
191
|
+
Traceback (most recent call last):
|
|
192
|
+
...
|
|
193
|
+
NotImplementedError: the method change_ring() has not yet been implemented
|
|
194
|
+
"""
|
|
195
|
+
if R is self.base_ring():
|
|
196
|
+
return self
|
|
197
|
+
raise NotImplementedError('the method change_ring() has not yet been implemented')
|
|
198
|
+
|
|
199
|
+
def base_extend(self, R):
|
|
200
|
+
r"""
|
|
201
|
+
Return the base extension of ``self`` to `R`.
|
|
202
|
+
|
|
203
|
+
This is the same as ``self.change_ring(R)`` except that a
|
|
204
|
+
:exc:`TypeError` is raised if there is no canonical coerce map
|
|
205
|
+
from the base ring of ``self`` to `R`.
|
|
206
|
+
|
|
207
|
+
INPUT:
|
|
208
|
+
|
|
209
|
+
- ``R`` -- ring
|
|
210
|
+
|
|
211
|
+
EXAMPLES::
|
|
212
|
+
|
|
213
|
+
sage: V = ZZ^7 # needs sage.modules
|
|
214
|
+
sage: V.base_extend(QQ) # needs sage.modules
|
|
215
|
+
Vector space of dimension 7 over Rational Field
|
|
216
|
+
|
|
217
|
+
TESTS::
|
|
218
|
+
|
|
219
|
+
sage: N = ModularForms(6, 4) # needs sage.modular
|
|
220
|
+
sage: N.base_extend(CyclotomicField(7)) # needs sage.modular sage.rings.number_field
|
|
221
|
+
Modular Forms space of dimension 5 for Congruence Subgroup Gamma0(6)
|
|
222
|
+
of weight 4 over Cyclotomic Field of order 7 and degree 6
|
|
223
|
+
|
|
224
|
+
sage: m = ModularForms(DirichletGroup(13).0^2,2); m # needs sage.modular sage.rings.number_field
|
|
225
|
+
Modular Forms space of dimension 3, character [zeta6] and weight 2
|
|
226
|
+
over Cyclotomic Field of order 6 and degree 2
|
|
227
|
+
sage: m.base_extend(CyclotomicField(12)) # needs sage.modular sage.rings.number_field
|
|
228
|
+
Modular Forms space of dimension 3, character [zeta6] and weight 2
|
|
229
|
+
over Cyclotomic Field of order 12 and degree 4
|
|
230
|
+
|
|
231
|
+
sage: # needs sage.modular sage.rings.number_field
|
|
232
|
+
sage: chi = DirichletGroup(109, CyclotomicField(3)).0
|
|
233
|
+
sage: S3 = CuspForms(chi, 2)
|
|
234
|
+
sage: S9 = S3.base_extend(CyclotomicField(9)); S9
|
|
235
|
+
Cuspidal subspace of dimension 8 of
|
|
236
|
+
Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2
|
|
237
|
+
over Cyclotomic Field of order 9 and degree 6
|
|
238
|
+
sage: S9.has_coerce_map_from(S3) # not implemented
|
|
239
|
+
True
|
|
240
|
+
sage: S9.base_extend(CyclotomicField(3))
|
|
241
|
+
Traceback (most recent call last):
|
|
242
|
+
...
|
|
243
|
+
TypeError: Base extension of self (over 'Cyclotomic Field of order 9 and degree 6')
|
|
244
|
+
to ring 'Cyclotomic Field of order 3 and degree 2' not defined.
|
|
245
|
+
"""
|
|
246
|
+
if R.has_coerce_map_from(self.base_ring()):
|
|
247
|
+
return self.change_ring(R)
|
|
248
|
+
raise TypeError("Base extension of self (over '%s') to ring '%s' not defined."
|
|
249
|
+
% (self.base_ring(), R))
|
|
250
|
+
|
|
251
|
+
def endomorphism_ring(self):
|
|
252
|
+
"""
|
|
253
|
+
Return the endomorphism ring of this module in its category.
|
|
254
|
+
|
|
255
|
+
EXAMPLES::
|
|
256
|
+
|
|
257
|
+
sage: from sage.modules.module import Module
|
|
258
|
+
sage: M = Module(ZZ)
|
|
259
|
+
sage: M.endomorphism_ring()
|
|
260
|
+
Set of Morphisms
|
|
261
|
+
from <sage.modules.module.Module object at ...>
|
|
262
|
+
to <sage.modules.module.Module object at ...>
|
|
263
|
+
in Category of modules over Integer Ring
|
|
264
|
+
"""
|
|
265
|
+
from sage.categories.homset import End
|
|
266
|
+
return End(self)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def is_Module(x):
|
|
270
|
+
"""
|
|
271
|
+
Return ``True`` if ``x`` is a module, ``False`` otherwise.
|
|
272
|
+
|
|
273
|
+
INPUT:
|
|
274
|
+
|
|
275
|
+
- ``x`` -- anything
|
|
276
|
+
|
|
277
|
+
EXAMPLES::
|
|
278
|
+
|
|
279
|
+
sage: from sage.modules.module import is_Module
|
|
280
|
+
sage: is_Module(10)
|
|
281
|
+
doctest:warning...
|
|
282
|
+
DeprecationWarning: the function is_Module is deprecated;
|
|
283
|
+
use 'isinstance(..., Module)' instead
|
|
284
|
+
See https://github.com/sagemath/sage/issues/37924 for details.
|
|
285
|
+
False
|
|
286
|
+
sage: M = FreeModule(RationalField(),30) # needs sage.modules
|
|
287
|
+
sage: is_Module(M) # needs sage.modules
|
|
288
|
+
True
|
|
289
|
+
"""
|
|
290
|
+
from sage.misc.superseded import deprecation_cython
|
|
291
|
+
deprecation_cython(37924, "the function is_Module is deprecated; use 'isinstance(..., Module)' instead")
|
|
292
|
+
return isinstance(x, Module)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def is_VectorSpace(x):
|
|
296
|
+
"""
|
|
297
|
+
Return ``True`` if ``x`` is a vector space, ``False`` otherwise.
|
|
298
|
+
|
|
299
|
+
INPUT:
|
|
300
|
+
|
|
301
|
+
- ``x`` -- anything
|
|
302
|
+
|
|
303
|
+
EXAMPLES::
|
|
304
|
+
|
|
305
|
+
sage: # needs sage.modules
|
|
306
|
+
sage: from sage.modules.module import is_Module, is_VectorSpace
|
|
307
|
+
sage: M = FreeModule(RationalField(),30)
|
|
308
|
+
sage: is_VectorSpace(M)
|
|
309
|
+
doctest:warning...
|
|
310
|
+
DeprecationWarning: the function is_VectorSpace is deprecated;
|
|
311
|
+
use 'isinstance(..., Module)' and check the base ring instead
|
|
312
|
+
See https://github.com/sagemath/sage/issues/37924 for details.
|
|
313
|
+
True
|
|
314
|
+
sage: M = FreeModule(IntegerRing(),30)
|
|
315
|
+
sage: is_Module(M)
|
|
316
|
+
doctest:warning...
|
|
317
|
+
DeprecationWarning: the function is_Module is deprecated;
|
|
318
|
+
use 'isinstance(..., Module)' instead
|
|
319
|
+
See https://github.com/sagemath/sage/issues/37924 for details.
|
|
320
|
+
True
|
|
321
|
+
sage: is_VectorSpace(M)
|
|
322
|
+
False
|
|
323
|
+
"""
|
|
324
|
+
from sage.misc.superseded import deprecation_cython
|
|
325
|
+
deprecation_cython(37924, "the function is_VectorSpace is deprecated; use 'isinstance(..., Module)' and check the base ring instead")
|
|
326
|
+
try:
|
|
327
|
+
return isinstance(x, Module) and x.base_ring().is_field()
|
|
328
|
+
except AttributeError:
|
|
329
|
+
return False
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* sage_setup: distribution = sagemath-objects
|
|
2
|
+
*/
|
|
3
|
+
#include <Python.h>
|
|
4
|
+
#include <gmp.h>
|
|
5
|
+
|
|
6
|
+
static PyTypeObject* Integer = NULL;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/* Replication of the internal structure of a Sage Integer */
|
|
10
|
+
struct Integer_Object
|
|
11
|
+
{
|
|
12
|
+
PyObject_HEAD
|
|
13
|
+
void* __pyx_vtab;
|
|
14
|
+
void* _parent;
|
|
15
|
+
mpz_t value;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
static inline mpz_ptr Integer_AS_MPZ(PyObject* x)
|
|
20
|
+
{
|
|
21
|
+
return ((struct Integer_Object*)x)->value;
|
|
22
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
"""
|
|
3
|
+
Fake Integer interface
|
|
4
|
+
|
|
5
|
+
This exists to solve the problem of cyclic imports involving the
|
|
6
|
+
``Integer`` class. The problem is that ``Integer`` depends on the
|
|
7
|
+
coercion model and the coercion model depends on ``Integer``.
|
|
8
|
+
|
|
9
|
+
Therefore, this should only be used to implement things at a lower
|
|
10
|
+
level than ``Integer``, such as the coercion model.
|
|
11
|
+
|
|
12
|
+
This provides two functions:
|
|
13
|
+
|
|
14
|
+
- ``Integer_AS_MPZ(x)``: access the value of the Integer ``x`` as GMP
|
|
15
|
+
``mpz_t``.
|
|
16
|
+
|
|
17
|
+
- ``is_Integer(x)``: is ``x`` an Integer?
|
|
18
|
+
|
|
19
|
+
TESTS::
|
|
20
|
+
|
|
21
|
+
sage: cython( # needs sage.misc.cython
|
|
22
|
+
....: '''
|
|
23
|
+
....: from sage.rings.integer_fake cimport Integer_AS_MPZ, is_Integer
|
|
24
|
+
....: from sage.rings.integer cimport Integer
|
|
25
|
+
....: cdef Integer x = Integer(123456789)
|
|
26
|
+
....: assert is_Integer(x)
|
|
27
|
+
....: assert Integer_AS_MPZ(x) is x.value
|
|
28
|
+
....: ''')
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
# ***************************************************************************
|
|
32
|
+
# Copyright (C) 2017 Jeroen Demeyer <J.Demeyer@UGent.be>
|
|
33
|
+
#
|
|
34
|
+
# This program is free software: you can redistribute it and/or modify
|
|
35
|
+
# it under the terms of the GNU General Public License as published by
|
|
36
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
37
|
+
# (at your option) any later version.
|
|
38
|
+
# https://www.gnu.org/licenses/
|
|
39
|
+
# ***************************************************************************
|
|
40
|
+
|
|
41
|
+
from cpython.ref cimport PyTypeObject, Py_TYPE
|
|
42
|
+
from sage.libs.gmp.types cimport mpz_ptr
|
|
43
|
+
|
|
44
|
+
cdef extern from "integer_fake.h":
|
|
45
|
+
PyTypeObject* Integer # Imported as needed
|
|
46
|
+
mpz_ptr Integer_AS_MPZ(x)
|
|
47
|
+
bint unlikely(bint c) # Defined by Cython
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
cdef inline bint is_Integer(x) noexcept:
|
|
51
|
+
global Integer
|
|
52
|
+
if unlikely(Integer is NULL):
|
|
53
|
+
import sage.rings.integer
|
|
54
|
+
Integer = <PyTypeObject*>sage.rings.integer.Integer
|
|
55
|
+
return Py_TYPE(x) is Integer
|
|
Binary file
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
"""
|
|
3
|
+
Set of all objects of a given Python class
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ****************************************************************************
|
|
7
|
+
# Copyright (C) 2018 Jeroen Demeyer <J.Demeyer@UGent.be>
|
|
8
|
+
#
|
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
# https://www.gnu.org/licenses/
|
|
14
|
+
# ****************************************************************************
|
|
15
|
+
|
|
16
|
+
from cpython.object cimport Py_EQ, Py_NE
|
|
17
|
+
from sage.structure.richcmp cimport rich_to_bool
|
|
18
|
+
from sage.categories.sets_cat import Sets
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
cdef dict _type_set_cache = {}
|
|
22
|
+
|
|
23
|
+
cpdef Set_PythonType(typ):
|
|
24
|
+
"""
|
|
25
|
+
Return the (unique) Parent that represents the set of Python objects
|
|
26
|
+
of a specified type.
|
|
27
|
+
|
|
28
|
+
EXAMPLES::
|
|
29
|
+
|
|
30
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
31
|
+
sage: Set_PythonType(list)
|
|
32
|
+
Set of Python objects of class 'list'
|
|
33
|
+
sage: Set_PythonType(list) is Set_PythonType(list)
|
|
34
|
+
True
|
|
35
|
+
sage: S = Set_PythonType(tuple)
|
|
36
|
+
sage: S([1,2,3])
|
|
37
|
+
(1, 2, 3)
|
|
38
|
+
|
|
39
|
+
S is a parent which models the set of all lists::
|
|
40
|
+
|
|
41
|
+
sage: S.category()
|
|
42
|
+
Category of infinite sets
|
|
43
|
+
"""
|
|
44
|
+
try:
|
|
45
|
+
return _type_set_cache[typ]
|
|
46
|
+
except KeyError:
|
|
47
|
+
_type_set_cache[typ] = theSet = Set_PythonType_class(typ)
|
|
48
|
+
return theSet
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
cdef class Set_PythonType_class(Set_generic):
|
|
52
|
+
r"""
|
|
53
|
+
The set of Python objects of a given class.
|
|
54
|
+
|
|
55
|
+
The elements of this set are not instances of
|
|
56
|
+
:class:`~sage.structure.element.Element`; they are instances of
|
|
57
|
+
the given class.
|
|
58
|
+
|
|
59
|
+
INPUT:
|
|
60
|
+
|
|
61
|
+
- ``typ`` -- a Python (new-style) class
|
|
62
|
+
|
|
63
|
+
EXAMPLES::
|
|
64
|
+
|
|
65
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
66
|
+
sage: S = Set_PythonType(int); S
|
|
67
|
+
Set of Python objects of class 'int'
|
|
68
|
+
sage: int('1') in S
|
|
69
|
+
True
|
|
70
|
+
sage: Integer('1') in S
|
|
71
|
+
False
|
|
72
|
+
|
|
73
|
+
sage: Set_PythonType(2)
|
|
74
|
+
Traceback (most recent call last):
|
|
75
|
+
...
|
|
76
|
+
TypeError: must be initialized with a class, not 2
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
def __init__(self, typ):
|
|
80
|
+
"""
|
|
81
|
+
EXAMPLES::
|
|
82
|
+
|
|
83
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
84
|
+
sage: Set_PythonType(float).category()
|
|
85
|
+
Category of infinite sets
|
|
86
|
+
"""
|
|
87
|
+
if not isinstance(typ, type):
|
|
88
|
+
raise TypeError(f"must be initialized with a class, not {typ!r}")
|
|
89
|
+
super().__init__(category=Sets().Finite() if typ is bool else Sets().Infinite())
|
|
90
|
+
self._type = <type>typ
|
|
91
|
+
|
|
92
|
+
def _element_constructor_(self, *args, **kwds):
|
|
93
|
+
"""
|
|
94
|
+
Construct an instance of the class.
|
|
95
|
+
|
|
96
|
+
EXAMPLES::
|
|
97
|
+
|
|
98
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
99
|
+
sage: S = Set_PythonType(complex)
|
|
100
|
+
sage: S._element_constructor_(5)
|
|
101
|
+
(5+0j)
|
|
102
|
+
sage: S._element_constructor_(1, 5/2)
|
|
103
|
+
(1+2.5j)
|
|
104
|
+
"""
|
|
105
|
+
return self._type(*args, **kwds)
|
|
106
|
+
|
|
107
|
+
def __reduce__(self):
|
|
108
|
+
r"""
|
|
109
|
+
Pickling support.
|
|
110
|
+
|
|
111
|
+
TESTS::
|
|
112
|
+
|
|
113
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
114
|
+
sage: S = Set_PythonType(object)
|
|
115
|
+
sage: loads(dumps(S))
|
|
116
|
+
Set of Python objects of class 'object'
|
|
117
|
+
"""
|
|
118
|
+
return type(self), (self._type,)
|
|
119
|
+
|
|
120
|
+
def __call__(self, x):
|
|
121
|
+
"""
|
|
122
|
+
Construct a new instance from ``x``. If ``x`` is already an
|
|
123
|
+
instance of the correct class, directly return ``x`` itself.
|
|
124
|
+
|
|
125
|
+
EXAMPLES::
|
|
126
|
+
|
|
127
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
128
|
+
sage: S = Set_PythonType(float)
|
|
129
|
+
sage: S(5)
|
|
130
|
+
5.0
|
|
131
|
+
sage: S(9/3)
|
|
132
|
+
3.0
|
|
133
|
+
sage: S(1/3)
|
|
134
|
+
0.333333333333333...
|
|
135
|
+
sage: a = float(3); S(a) is a
|
|
136
|
+
True
|
|
137
|
+
"""
|
|
138
|
+
if isinstance(x, self._type):
|
|
139
|
+
return x
|
|
140
|
+
return self._type(x)
|
|
141
|
+
|
|
142
|
+
def __hash__(self):
|
|
143
|
+
"""
|
|
144
|
+
TESTS::
|
|
145
|
+
|
|
146
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
147
|
+
sage: S = Set_PythonType(int)
|
|
148
|
+
sage: hash(S) == -hash(int)
|
|
149
|
+
True
|
|
150
|
+
"""
|
|
151
|
+
return -hash(self._type)
|
|
152
|
+
|
|
153
|
+
def __richcmp__(self, other, int op):
|
|
154
|
+
"""
|
|
155
|
+
Two Python class sets are considered the same if they contain
|
|
156
|
+
the same class.
|
|
157
|
+
|
|
158
|
+
EXAMPLES::
|
|
159
|
+
|
|
160
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
161
|
+
sage: S = Set_PythonType(int)
|
|
162
|
+
sage: T = Set_PythonType(int)
|
|
163
|
+
sage: U = type(S)(int) # bypass caching
|
|
164
|
+
sage: S is T
|
|
165
|
+
True
|
|
166
|
+
sage: S == T
|
|
167
|
+
True
|
|
168
|
+
sage: S is U
|
|
169
|
+
False
|
|
170
|
+
sage: S == U
|
|
171
|
+
True
|
|
172
|
+
sage: S == Set_PythonType(float)
|
|
173
|
+
False
|
|
174
|
+
sage: S == int
|
|
175
|
+
False
|
|
176
|
+
"""
|
|
177
|
+
if not (op == Py_EQ or op == Py_NE):
|
|
178
|
+
return NotImplemented
|
|
179
|
+
if self is other:
|
|
180
|
+
return rich_to_bool(op, 0)
|
|
181
|
+
if not isinstance(other, Set_PythonType_class):
|
|
182
|
+
return rich_to_bool(op, 1)
|
|
183
|
+
s = (<Set_PythonType_class>self)._type
|
|
184
|
+
o = (<Set_PythonType_class>other)._type
|
|
185
|
+
return rich_to_bool(op, s is not o)
|
|
186
|
+
|
|
187
|
+
def __contains__(self, x):
|
|
188
|
+
"""
|
|
189
|
+
Only things of the right class (or subclasses thereof) are
|
|
190
|
+
considered to belong to the set.
|
|
191
|
+
|
|
192
|
+
EXAMPLES::
|
|
193
|
+
|
|
194
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
195
|
+
sage: S = Set_PythonType(tuple)
|
|
196
|
+
sage: (1,2,3) in S
|
|
197
|
+
True
|
|
198
|
+
sage: () in S
|
|
199
|
+
True
|
|
200
|
+
sage: [1,2] in S
|
|
201
|
+
False
|
|
202
|
+
"""
|
|
203
|
+
return isinstance(x, self._type)
|
|
204
|
+
|
|
205
|
+
def _repr_(self):
|
|
206
|
+
"""
|
|
207
|
+
EXAMPLES::
|
|
208
|
+
|
|
209
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
210
|
+
sage: Set_PythonType(tuple)
|
|
211
|
+
Set of Python objects of class 'tuple'
|
|
212
|
+
sage: Set_PythonType(Integer)
|
|
213
|
+
Set of Python objects of class 'Integer'
|
|
214
|
+
sage: Set_PythonType(Parent)
|
|
215
|
+
Set of Python objects of class 'Parent'
|
|
216
|
+
"""
|
|
217
|
+
return f"Set of Python objects of class '{self._type.__name__}'"
|
|
218
|
+
|
|
219
|
+
def object(self):
|
|
220
|
+
"""
|
|
221
|
+
EXAMPLES::
|
|
222
|
+
|
|
223
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
224
|
+
sage: Set_PythonType(tuple).object()
|
|
225
|
+
<... 'tuple'>
|
|
226
|
+
"""
|
|
227
|
+
return self._type
|
|
228
|
+
|
|
229
|
+
def cardinality(self):
|
|
230
|
+
"""
|
|
231
|
+
EXAMPLES::
|
|
232
|
+
|
|
233
|
+
sage: from sage.sets.pythonclass import Set_PythonType
|
|
234
|
+
sage: S = Set_PythonType(bool)
|
|
235
|
+
sage: S.cardinality()
|
|
236
|
+
2
|
|
237
|
+
sage: S = Set_PythonType(int)
|
|
238
|
+
sage: S.cardinality()
|
|
239
|
+
+Infinity
|
|
240
|
+
"""
|
|
241
|
+
if self._type is bool:
|
|
242
|
+
from sage.rings.integer import Integer
|
|
243
|
+
return Integer(2)
|
|
244
|
+
else:
|
|
245
|
+
# Probably infinite
|
|
246
|
+
import sage.rings.infinity
|
|
247
|
+
return sage.rings.infinity.infinity
|