fix(merge_neighbors): support non-numeric endpoints - #156
Open
IMGillusion wants to merge 1 commit into
Open
IMGillusion wants to merge 1 commit into
IMGillusion wants to merge 1 commit into
Conversation
merge_neighbors() raised TypeError on non-numeric interval endpoints (e.g. datetime) because the default distance was the int 1 and the strict check compared margin against the int 0. The default distance is now inferred from the endpoint type: 1 for numeric endpoints (the historical default), or the zero of the endpoint type (e.g. timedelta(0) for datetime) so that only touching or overlapping intervals are merged. Fixes chaimleib#115
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
merge_neighbors()raisedTypeErroron non-numeric interval endpoints (e.g.datetime):because the default
distancewas theint 1, and the strict overlap check comparedmarginagainst theint 0.This PR makes both defaults type-aware, inferred from the interval endpoints:
distance=None(new default) becomes1for numeric endpoints (the historical default) or the zero of the endpoint type (e.g.timedelta(0)fordatetime), so only touching or overlapping intervals are merged.marginagainst that same zero instead of theint 0.An explicit
distanceof the endpoint type (e.g.timedelta(hours=3)) already worked before and still works.Fixes #115