Skip to content
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

Bugfix FiniteDateRange intersection #105

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Conversation

josh-lynch
Copy link
Contributor

The recent change to allow adjacent FiniteDateRanges to union (by
changing the behaviour of is_disjoint) broke the behaviour of
intersection for adjacent ranges, causing attempts to intersect
adjacent ranges to raise ValueError instead of returning None.

This change makes intersect on adjacent FiniteDateRanges return
None again.

@josh-lynch josh-lynch requested a review from a team October 20, 2023 09:23
@josh-lynch josh-lynch marked this pull request as ready for review October 20, 2023 09:23
@josh-lynch josh-lynch force-pushed the ranges/bugfix-intersection branch from 7e573a7 to b1d7e69 Compare October 20, 2023 09:24
try:
base_intersection = super().intersection(other)
except ValueError:
# This occurs when calling intersection on an adjacent date range.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to confirm that's the reason for the ValueError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe there is any other way we could get a ValueError coming up here, but I don't think there's any way programatically to specifically confirm that. Did you have something in mind?

I could replace raising a ValueError with a custom exception type, but it is a larger change.

The recent change to allow adjacent FiniteDateRanges to union (by
changing the behaviour of is_disjoint) broke the behaviour of
intersection for adjacent ranges, causing attempts to intersect
adjacent ranges to raise ValueError instead of returning None.

This change makes intersect on adjacent FiniteDateRanges return
None again.
@josh-lynch josh-lynch force-pushed the ranges/bugfix-intersection branch from b1d7e69 to ada427c Compare October 26, 2023 10:06
@josh-lynch josh-lynch merged commit 12e5f1b into main Oct 26, 2023
@josh-lynch josh-lynch deleted the ranges/bugfix-intersection branch October 26, 2023 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants