From edf4568e8fcbef288d560fb4d63b24e9bb56c165 Mon Sep 17 00:00:00 2001 From: Jim Paris Date: Wed, 14 Aug 2019 13:42:39 -0400 Subject: [PATCH] Fix error in interval comparisons; add coverage --- nilmdb/utils/interval.py | 2 +- tests/test_interval.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/nilmdb/utils/interval.py b/nilmdb/utils/interval.py index 2ac1f7b..5b5d7b4 100644 --- a/nilmdb/utils/interval.py +++ b/nilmdb/utils/interval.py @@ -46,7 +46,7 @@ class Interval: return (self.start, self.end) > (other.start, other.end) def __le__(self, other): return (self.start, self.end) <= (other.start, other.end) - def __le__(self, other): + def __ge__(self, other): return (self.start, self.end) >= (other.start, other.end) def __eq__(self, other): return (self.start, self.end) == (other.start, other.end) diff --git a/tests/test_interval.py b/tests/test_interval.py index 7515a44..8c00796 100644 --- a/tests/test_interval.py +++ b/tests/test_interval.py @@ -93,8 +93,13 @@ class TestInterval: # compare assert(Interval(d1, d2) == Interval(d1, d2)) + assert(Interval(d1, d2) <= Interval(d1, d2)) + assert(Interval(d1, d2) >= Interval(d1, d2)) + assert(Interval(d1, d2) != Interval(d1, d3)) assert(Interval(d1, d2) < Interval(d1, d3)) + assert(Interval(d1, d2) <= Interval(d1, d3)) assert(Interval(d1, d3) > Interval(d1, d2)) + assert(Interval(d1, d3) >= Interval(d1, d2)) assert(Interval(d1, d2) < Interval(d2, d3)) assert(Interval(d1, d3) < Interval(d2, d3)) assert(Interval(d2, d2+1) > Interval(d1, d3))