From f3507df005b47775927ad30e287e741489e4e010 Mon Sep 17 00:00:00 2001 From: Eric Moyer Date: Sun, 29 Jul 2018 14:08:56 -0400 Subject: [PATCH] Fix bug in hull Without this fix, hull returns the wrong result when one interval is completely contained in the other Interval(4, 7).hull(Interval(5, 6)) returns Interval(4, 6) not the correct answer of Interval(4, 7) --- recipes/Python/576816_Interval/recipe-576816.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/recipes/Python/576816_Interval/recipe-576816.py b/recipes/Python/576816_Interval/recipe-576816.py index 11fe0ca22..ef98dad32 100644 --- a/recipes/Python/576816_Interval/recipe-576816.py +++ b/recipes/Python/576816_Interval/recipe-576816.py @@ -55,9 +55,7 @@ def intersection(self, other): def hull(self, other): "@return: Interval containing both self and other." - if self > other: - other, self = self, other - return Interval(self.start, other.end) + return Interval(min(self.start, other.start), max(self.end, other.end)) def overlap(self, other):