-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Chaining Interval Operations #33
Comments
Hello, I'm not 100% sure I understood the question, but if I'm right, what you're looking for is For example: >>> import portion as P
>>> m = [P.closed(0, 10), P.closed(2, 8), P.closed(1, 4)]
>>> from functools import reduce
>>> reduce(P.Interval.intersection, m, P.open(-P.inf, P.inf))
[2, 4] Is it what you were looking for? |
@AlexandreDecan - yes exactly that. I was didn't realise |
You're welcome ;-) Note that |
Thanks for the further explanation. For anyone who comes across this issue and needs to chain a from functools import reduce
m = [P.closed(0, 10), P.closed(2, 8), P.closed(1, 4)]
reduce(P.Interval.union, m, P.empty())
>>> [0,10] |
Very nice library - thanks!
I was wondering if you have a suggested method for chaining interval operations on lists of intervals?
For example for intersecting several lists you can use:
r = P.closed(100.1239812, 300.9012312) | P.closed(110, 300.9012312) | P.closed(97, 300.9012312)
If you have a list of unknown size is it possible to chain the intersection?
It would be nice if one of the approaches for chaining sets could be used as described here:
So something like:
Maybe this is already possible but I've not found a successful approach so far (beyond a simple loop and applying intersection one by one).
The text was updated successfully, but these errors were encountered: