Skip to content

Commit 5a4b995

Browse files
committed
Updated the doc and fixed changes according to PR thread
1 parent e623b41 commit 5a4b995

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

intervaltree/interval.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,22 @@ def overlap_size(self, begin, end=None):
5959
:param begin: beginning point of the range, or the point, or an Interval
6060
:param end: end point of the range. Optional if not testing ranges.
6161
:return: Return the overlap size, None if not overlap is found
62-
:rtype: int
62+
:rtype: depends on the given input (e.g., int will be returned for int interval and timedelta for
63+
datetime intervals)
6364
"""
6465
overlaps = self.overlaps(begin, end)
6566
if not overlaps:
66-
return None
67+
return 0
6768

6869
if end is not None:
6970
# case end is given
7071
i0 = max(self.begin, begin)
7172
i1 = min(self.end, end)
7273
return i1 - i0
73-
try:
74-
# assume this is
75-
i0 = max(self.begin, begin.begin)
76-
i1 = min(self.end, begin.end)
77-
return i1 - i0
78-
except:
79-
return 1 # case the begin is point
74+
# assume the type is interval, in other cases, an exception will be thrown
75+
i0 = max(self.begin, begin.begin)
76+
i1 = min(self.end, begin.end)
77+
return i1 - i0
8078

8179
def contains_point(self, p):
8280
"""

test/interval_methods/binary_test.py

-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ def test_interval_overlap_interval():
6262
assert not iv0.overlaps(iv9)
6363

6464

65-
def test_interval_overlaps_size_point():
66-
assert iv0.overlap_size(4) == 1
67-
assert not iv0.overlap_size(19)
68-
assert not iv0.overlap_size(-19)
69-
70-
7165
def test_contains_interval():
7266
assert iv0.contains_interval(iv0)
7367
assert not iv0.contains_interval(iv1)

0 commit comments

Comments
 (0)