Skip to content

Commit

Permalink
Fixed bug in difference
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsch420 committed Dec 20, 2024
1 parent be4dcb7 commit 478ec79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/random_events/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.1.2'
__version__ = '3.1.3'
3 changes: 3 additions & 0 deletions src/random_events/sigma_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ def difference_with_simple_set(self, other: AbstractSimpleSet) -> Self:

def difference_with_simple_sets(self, other: SimpleSetContainer) -> Self:

if len(other) == 0:
return self

# initialize the result
result = self.new_empty_set()

Expand Down
7 changes: 6 additions & 1 deletion test/test_product_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ def test_union_different_variables(self):
event_1 = SimpleEvent({self.x: SimpleInterval(0, 1)}).as_composite_set()
event_2 = SimpleEvent({self.y: SimpleInterval(0, 1)}).as_composite_set()
union = event_1.union_with(event_2)
print(union)
# self.assertEqual(union, Event(event_1, event_2))

def test_difference_with_empty_set(self):
event = SimpleEvent({self.x: SimpleInterval(0, 1), self.y: SimpleInterval(0, 1)}).as_composite_set()
empty_event = Event()
diff = event.difference_with(empty_event)
self.assertEqual(diff, event)

if __name__ == '__main__':
unittest.main()

0 comments on commit 478ec79

Please sign in to comment.