Skip to content

Commit

Permalink
Fixed bug in make_disjoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsch420 committed Jul 16, 2024
1 parent 5efa43f commit 13229a2
Show file tree
Hide file tree
Showing 3 changed files with 22 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.0.5'
__version__ = '3.0.6'
2 changes: 1 addition & 1 deletion src/random_events/sigma_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def split_into_disjoint_and_non_disjoint(self) -> Tuple[Self, Self]:
if len(difference_with_intersection.simple_sets) == 0:
# skip the rest of the loop and mark the set for discarding
difference_of_a_with_every_b = None
continue
break

# add the disjoint remainder
difference_of_a_with_every_b = difference_with_intersection
Expand Down
20 changes: 20 additions & 0 deletions test/test_product_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,25 @@ def test_to_json_multiple_events(self):
event_ = AbstractSimpleSet.from_json(event.to_json())
self.assertEqual(event_, event)


class NoneTypeObjectInDifferenceTestCase(unittest.TestCase):
x: Continuous = Continuous("x")
y: Continuous = Continuous("y")
event_1 = Event(SimpleEvent({x: SimpleInterval(0, 0.25, Bound.CLOSED, Bound.CLOSED),
y: SimpleInterval(0.25, 1, Bound.CLOSED, Bound.CLOSED)}),
SimpleEvent({x: SimpleInterval(0.75, 1, Bound.CLOSED, Bound.CLOSED),
y: SimpleInterval(0.75, 1, Bound.CLOSED, Bound.CLOSED)}))
event_2 = SimpleEvent({x: SimpleInterval(0., 0.25, Bound.CLOSED, Bound.CLOSED),
y: SimpleInterval(0., 1, Bound.CLOSED, Bound.CLOSED)}).as_composite_set()

def test_union(self):
union = self.event_1 | self.event_2
union_by_hand = Event(SimpleEvent({self.x: SimpleInterval(0, 0.25, Bound.CLOSED, Bound.CLOSED),
self.y: SimpleInterval(0., 1, Bound.CLOSED, Bound.CLOSED)}),
SimpleEvent({self.x: SimpleInterval(0.75, 1, Bound.CLOSED, Bound.CLOSED),
self.y: SimpleInterval(0.75, 1, Bound.CLOSED, Bound.CLOSED)}))
self.assertEqual(union, union_by_hand)


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

0 comments on commit 13229a2

Please sign in to comment.