Skip to content

Commit

Permalink
sets: correct Interval.boundary to satisfy the standard topology of ℝ
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Apr 28, 2022
1 parent 77af038 commit 6791717
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions diofant/sets/sets.py
Expand Up @@ -448,8 +448,7 @@ def is_open(self):
boundary
"""
if not Intersection(self, self.boundary):
return True
return not Intersection(self, self.boundary)

@property
def is_closed(self):
Expand Down Expand Up @@ -949,7 +948,9 @@ def _union(self, other):

@property
def boundary(self):
return FiniteSet(self.start, self.end)
return FiniteSet(*(p for p, c in [(self.start, not self.left_open),
(self.end, not self.right_open)]
if abs(p) != oo or c))

def _contains(self, other):
if not isinstance(other, Expr) or other in (nan, zoo):
Expand Down
3 changes: 3 additions & 0 deletions diofant/tests/sets/test_fancysets.py
Expand Up @@ -228,8 +228,11 @@ def test_reals():
assert sqrt(-1) not in S.Reals
assert S.Reals == Interval.open(-oo, oo)
assert hash(S.Reals) == hash(Interval.open(-oo, oo))
assert S.Reals.is_open is True
assert S.Reals.is_closed is True
assert S.ExtendedReals == Interval(-oo, oo)
assert hash(S.ExtendedReals) == hash(Interval(-oo, oo))
assert S.ExtendedReals.is_closed is True


def test_intersections():
Expand Down

0 comments on commit 6791717

Please sign in to comment.