-
-
Notifications
You must be signed in to change notification settings - Fork 34
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 the total duration of the interval. #61
Comments
Hello, Thanks for your question. It seems that this issue is related to #60. The question is: what would be the "duration" for an open (or open-closed, closed-open) interval such as (1, 3)? If the answer is "2", then I don't think you should wonder about the fact that an interval is closed or open. If the answer is "1", then it means you're considering that intervals are discrete (and not continuous). In that case, I would refer to #24 to see how to deal with discrete intervals. According to #60, it seems that the answer should be 2, though ;-) |
Hi, Thanks for your reply. Totally agree. I guess my question is, Have you considered adding an additional attribute to the def size_of_interval(interval):
if interval.empty:
return 0
total_duration = 0
for sub_interval in interval._intervals:
total_duration += sub_interval.upper - sub_interval.lower
return total_duration I am not sure whether this type of function is already included. |
No, such a function is not included in |
I'm definitely going to delay this for the next major release (if any), because there are a few cases that cannot be properly solved currently. The most annoying one is what to do with empty intervals? For example, one might expect This is likely to be solved if, as I hope to do for 3.0.0, |
I am wondering if it will be better if the total duration of the interval could be added.
For example, a interval with
[1, 3] + [5, 6]
have a total duration of2 + 1 = 3
My only concern is I am not sure how to distinguish the closed interval from the open interval when calculating the total duration. They could be the same though.
The text was updated successfully, but these errors were encountered: