Facade Sets¶
For background, see What is a facade set?.
-
class
sage.categories.facade_sets.
FacadeSets
(base_category)¶ Bases:
sage.categories.category_with_axiom.CategoryWithAxiom_singleton
-
class
ParentMethods
¶ -
facade_for
()¶ Returns the parents this set is a facade for
This default implementation assumes that
self
has an attribute_facade_for
, typically initialized byParent.__init__()
. If the attribute is not present, the method raises a NotImplementedError.EXAMPLES:
sage: S = Sets().Facade().example(); S An example of facade set: the monoid of positive integers sage: S.facade_for() (Integer Ring,)
Check that trac ticket #13801 is corrected:
sage: class A(Parent): ....: def __init__(self): ....: Parent.__init__(self, category=Sets(), facade=True) sage: a = A() sage: a.facade_for() Traceback (most recent call last): ... NotImplementedError: this parent did not specify which parents it is a facade for
-
is_parent_of
(element)¶ Returns whether
self
is the parent ofelement
INPUT:
element
– any object
Since
self
is a facade domain, this actually tests whether the parent ofelement
is any of the parentself
is a facade for.EXAMPLES:
sage: S = Sets().Facade().example(); S An example of facade set: the monoid of positive integers sage: S.is_parent_of(1) True sage: S.is_parent_of(1/2) False
This method differs from
__contains__()
in two ways. First, this does not take into account the fact thatself
may be a strict subset of the parent(s) it is a facade for:sage: -1 in S, S.is_parent_of(-1) (False, True)
Furthermore, there is no coercion attempted:
sage: int(1) in S, S.is_parent_of(int(1)) (True, False)
Warning
this implementation does not handle facade parents of facade parents. Is this a feature we want generically?
-
-
example
(choice='subset')¶ Returns an example of facade set, as per
Category.example()
.INPUT:
choice
– ‘union’ or ‘subset’ (default: ‘subset’).
EXAMPLES:
sage: Sets().Facade().example() An example of facade set: the monoid of positive integers sage: Sets().Facade().example(choice='union') An example of a facade set: the integers completed by +-infinity sage: Sets().Facade().example(choice='subset') An example of facade set: the monoid of positive integers
-
class