-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ranges.any_gaps
#185
Add ranges.any_gaps
#185
Conversation
To give us even more confidence that the order of the input ranges does not matter.
deebcde
to
e927d82
Compare
@@ -589,6 +589,17 @@ def test_timestamps_sorted(self, period): | |||
|
|||
|
|||
class TestAnyOverlapping: | |||
def test_does_not_modify_ranges(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably have been part of #184
@@ -624,6 +624,7 @@ def test_does_not_modify_ranges(self): | |||
) | |||
def test_returns_true_if_and_ranges_overlap(self, ranges_): | |||
assert ranges.any_overlapping(ranges_) | |||
assert ranges.any_overlapping(reversed(ranges_)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably have been part of #184
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR adds a
ranges.any_gaps
utility function.This function is very simple - all work is delegated to a
RangeSet
. So arguably this function is not needed at all. I think it's still a useful addition though, since this check is commonly used and this utility function makes it slightly clearer and less likely to make an error.A benchmark is added, however the existing implementation was found to be pretty optimal. I suggest leaving the benchmark to help guard against regressions (I'm interested to set up codespeed for this, see here).