Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
RealSet._element_constructor_: Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Aug 31, 2022
1 parent 20c153d commit 9a789a9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/sage/sets/real_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,17 @@ def _coerce_map_from_(self, X):
return FacadeInclusionMorphism(Hom(X, self))

def _element_constructor_(self, x):
r"""
EXAMPLES::
sage: S = RealSet.open(1, 3)
sage: S(2)
2
sage: S(3)
Traceback (most recent call last):
...
TypeError: 3 is not an element of (1, 3)
"""
if self.contains(x):
return x
raise TypeError(f'{x} is not an element of {self}')
Expand Down

0 comments on commit 9a789a9

Please sign in to comment.