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

How can I get all of the bounds when the interval is not atomic? #32

Closed
im-fancy opened this issue Jul 6, 2020 · 3 comments
Closed
Labels
question Issue is a question

Comments

@im-fancy
Copy link

im-fancy commented Jul 6, 2020

Dear author,

Thank you for your excellent work! I have a question:

when the interval is not atomic, eg,

x = P.open(0, 1) | P.closed(3, 4)

I can use x.lower and x.upper get 0 and 4. Which attribute can I use to access 1 and 3?

@AlexandreDecan AlexandreDecan added the question Issue is a question label Jul 6, 2020
@AlexandreDecan
Copy link
Owner

AlexandreDecan commented Jul 6, 2020

Hello,

You can iterate on an interval to get access to the underlying atomic intervals:

>>> x = P.open(0, 1) | P.closed(3, 4)
>>> for i in x: 
       print(i.lower, i.upper)
0 1
3 4

To get them all at once, e.g. in a list, you can use list comprehensions, as usual:

>>> lower = [i.lower for i in x]
>>> upper = [i.upper for i in x]

@im-fancy
Copy link
Author

im-fancy commented Jul 6, 2020

Many thanks!

@AlexandreDecan
Copy link
Owner

You're welcome ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue is a question
Projects
None yet
Development

No branches or pull requests

2 participants