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""" Example of facade set """ #***************************************************************************** # Copyright (C) 2010 Nicolas M. Thiery <nthiery at users.sf.net> # # Distributed under the terms of the GNU General Public License (GPL) # http://www.gnu.org/licenses/ #*****************************************************************************
r"""
An example of a facade parent: the positive integers viewed as a multiplicative monoid
This class illustrates a minimal implementation of a facade parent which models a subset of a set.
EXAMPLES::
sage: S = Sets().Facade().example(); S An example of facade set: the monoid of positive integers
TESTS::
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_new() . . . pass running ._test_nonzero_equal() . . . 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_new() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_one() . . . pass running ._test_pickling() . . . pass running ._test_prod() . . . pass running ._test_some_elements() . . . pass """ r""" EXAMPLES::
sage: from sage.categories.examples.facade_sets import PositiveIntegerMonoid sage: S = PositiveIntegerMonoid(); S An example of facade set: the monoid of positive integers
TESTS::
sage: TestSuite(S).run()
"""
r"""
EXAMPLES::
sage: S = Sets().Facade().example() # indirect doctest
"""
r""" Construction of elements
Since ``self`` is a strict subset of the parent it is a facade for, it is mandatory to override this method. This method indirectly influences membership testing (see :meth:`Parent.__contains__`).
EXAMPLES::
sage: S = Sets().Facade().example(); S An example of facade set: the monoid of positive integers sage: S(1) 1 sage: S(int(1)) 1 sage: S(2/1) 2 sage: (parent(S(1)) == ZZ, parent(S(int(1))) == ZZ, parent(S(2/1))) (True, True, Integer Ring) sage: S(1), S(int(1)), S(2/1) (1, 1, 2) sage: 1 in S True sage: 2/1 in S, int(1) in S (True, True) sage: -1 in S, 1/2 in S (False, False) """ else:
r""" An example of a facade parent: the set of integers completed with `+-\infty`
This class illustrates a minimal implementation of a facade parent that models the union of several other parents.
EXAMPLES::
sage: S = Sets().Facade().example("union"); S An example of a facade set: the integers completed by +-infinity
TESTS::
sage: TestSuite(S).run(verbose = True) running ._test_an_element() . . . 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_new() . . . pass running ._test_nonzero_equal() . . . 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_new() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_pickling() . . . pass running ._test_some_elements() . . . pass """ r""" EXAMPLES::
sage: from sage.categories.examples.facade_sets import IntegersCompletion sage: S = IntegersCompletion(); S An example of a facade set: the integers completed by +-infinity
TESTS::
sage: TestSuite(S).run()
""" # We can't use InfinityRing, because this ring contains 3 # elements besides +-infinity. We can't use Set either for the # moment, because Set([1,2])(1) raises an error
r"""
EXAMPLES::
sage: S = Sets().Facade().example() # indirect doctest
"""
|