Examples of semigroups in cython¶
-
class
sage.categories.examples.semigroups_cython.
IdempotentSemigroups
(s=None)¶ Bases:
sage.categories.category.Category
Initializes this category.
EXAMPLES:
sage: class SemiprimitiveRings(Category): ....: def super_categories(self): ....: return [Rings()] ....: ....: class ParentMethods: ....: def jacobson_radical(self): ....: return self.ideal(0) ....: sage: C = SemiprimitiveRings() sage: C Category of semiprimitive rings sage: C.__class__ <class '__main__.SemiprimitiveRings_with_category'>
Note
Specifying the name of this category by passing a string is deprecated. If the default name (built from the name of the class) is not adequate, please use
_repr_object_names()
to customize it.-
ElementMethods
¶ alias of
IdempotentSemigroupsElementMethods
-
super_categories
()¶ EXAMPLES:
sage: from sage.categories.examples.semigroups_cython import IdempotentSemigroups sage: IdempotentSemigroups().super_categories() [Category of semigroups]
-
-
class
sage.categories.examples.semigroups_cython.
IdempotentSemigroupsElementMethods
¶ Bases:
object
-
is_idempotent_cpdef
()¶ EXAMPLES:
sage: from sage.categories.examples.semigroups_cython import LeftZeroSemigroup sage: S = LeftZeroSemigroup() sage: S(2).is_idempotent_cpdef() # todo: not implemented (binding; see __getattr__) True
-
-
class
sage.categories.examples.semigroups_cython.
LeftZeroSemigroup
¶ Bases:
sage.categories.examples.semigroups.LeftZeroSemigroup
An example of semigroup
This class illustrates a minimal implementation of a semi-group where the element class is an extension type, and still gets code from the category. Also, the category itself includes some cython methods.
This is purely a proof of concept. The code obviously needs refactorisation!
Comments:
- nested classes seem not to be currently supported by Cython
- one cannot play ugly class surgery tricks (as with _mul_parent). available operations should really be declared to the coercion model!
EXAMPLES:
sage: from sage.categories.examples.semigroups_cython import LeftZeroSemigroup sage: S = LeftZeroSemigroup(); S An example of a semigroup: the left zero semigroup
This is the semigroup which contains all sort of objects:
sage: S.some_elements() [3, 42, 'a', 3.4, 'raton laveur']
with product rule is given by \(a \times b = a\) for all \(a,b\).
sage: S('hello') * S('world') 'hello' sage: S(3)*S(1)*S(2) 3 sage: S(3)^12312321312321 # todo: not implemented (see __getattr__) 3 sage: TestSuite(S).run(verbose = True) running ._test_an_element() . . . pass running ._test_associativity() . . . pass running ._test_cardinality() . . . pass running ._test_category() . . . pass running ._test_elements() . . . Running the test suite of self.an_element() running ._test_category() . . . pass running ._test_eq() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_pickling() . . . pass pass running ._test_elements_eq_reflexive() . . . pass running ._test_elements_eq_symmetric() . . . pass running ._test_elements_eq_transitive() . . . pass running ._test_elements_neq() . . . pass running ._test_eq() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_pickling() . . . pass running ._test_some_elements() . . . pass
That’s really the only method which is obtained from the category ...
sage: S(42).is_idempotent <bound method IdempotentSemigroups.element_class.is_idempotent of 42> sage: S(42).is_idempotent() True sage: S(42)._pow_ # todo: not implemented (how to bind it?) <method '_pow_' of 'sage.categories.examples.semigroups_cython.IdempotentSemigroupsElement' objects> sage: S(42)^10 # todo: not implemented (see __getattr__) 42 sage: S(42).is_idempotent_cpdef # todo: not implemented (how to bind it?) <method 'is_idempotent_cpdef' of 'sage.categories.examples.semigroups_cython.IdempotentSemigroupsElement' objects> sage: S(42).is_idempotent_cpdef() # todo: not implemented (see __getattr__) True
-
Element
¶ alias of
LeftZeroSemigroupElement
-
class
sage.categories.examples.semigroups_cython.
LeftZeroSemigroupElement
¶ Bases:
sage.structure.element.Element
EXAMPLES:
sage: from sage.categories.examples.semigroups_cython import LeftZeroSemigroup sage: S = LeftZeroSemigroup() sage: x = S(3) sage: TestSuite(x).run()