-
Notifications
You must be signed in to change notification settings - Fork 2
Add intersect_spans function
#72
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dec62b3
intersect_spans function
chetchavat 1e6e53d
export function
chetchavat b8a37f4
test intersection
chetchavat c89d6a0
remove whitespacre
chetchavat 52715f5
update project
chetchavat 934eab0
Update src/TimeSpans.jl
chetchavat 1c72dbd
Update src/TimeSpans.jl
chetchavat 9c26ca2
Update test/runtests.jl
chetchavat 69e0134
Update test/runtests.jl
chetchavat 0bcfd50
change to intersect, avoid collision
chetchavat 0dd7b07
Update src/TimeSpans.jl
chetchavat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I wonder whether "intersect" is really the right verb here. Describing it as the intersection of the two spans makes sense, but it kind of suggests to me that other set terminology would be applicable, but I don't believe there are any such cases. For example, TimeSpans.jl uses
overlaps(a, b)rather than!isdisjoint(a, b), andTimeSpans.contains(a, b)rather thanissubset(b, a). I could imagine that given that the query for "is there a nonempty intersection" isoverlaps, "what is the intersection" would beoverlap. But ifoverlapreturns a span, it's not immediately obvious whetheroverlapsthen is plural or present tense. I have no answers, only quandaries.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.
if it helps any, the original function was called
innerspanThere 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 is really the set-theoretic operation though, (other than the error-if-disjoint lol).
my gripe with
intersect_spansis the other part, the_spans: the other_spansfunctions operate on iterables of spans rather than pairs; the pairwiseoverlaps,containsdon't have_spans.I think
TimeSpans.intersectis fine, it has the same semantics as the base function and not exporting it makes the scope clear a lacontainsThere 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.
I'll also add that
Base.containstends to come along with other collection-y methods, but the namespacing makes it pretty clear that it's differentThere 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.
Very, very late to the party but IMO
TimeSpans.containsshould be renamed tocontains_span. (Actually, in basically all code I've written where I've needed that function, I dousing TimeSpans: contains as contains_span, haha.) Having only part of the API namespaced feels inconsistent, and having a package with a function that has the same name as a Base function is really confusing. I strongly preferintersect_spansoverTimeSpans.intersect.