Browse Source

Fix error in interval comparisons; add coverage

tags/nilmdb-2.0.0
Jim Paris 4 years ago
parent
commit
edf4568e8f
2 changed files with 6 additions and 1 deletions
  1. +1
    -1
      nilmdb/utils/interval.py
  2. +5
    -0
      tests/test_interval.py

+ 1
- 1
nilmdb/utils/interval.py View File

@@ -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)


+ 5
- 0
tests/test_interval.py View File

@@ -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))


Loading…
Cancel
Save