Bases: object
TESTS:
sage: from sage.categories.examples.semigroups_cython import DummyCClass
sage: DummyCClass().cpmethod()
TESTS:
sage: from sage.categories.examples.semigroups_cython import DummyCClass
sage: DummyCClass().method()
TESTS:
sage: from sage.categories.examples.semigroups_cython import DummyClass
sage: DummyClass().method()
Bases: sage.categories.category.Category
EXAMPLES:
sage: from sage.categories.examples.semigroups_cython import IdempotentSemigroups
sage: IdempotentSemigroups().super_categories()
[Category of semigroups]
Bases: sage.structure.element.Element
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
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:
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.3999999999999999, 'raton laveur']
with product rule is given by for all .
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_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() . . . 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