-
Notifications
You must be signed in to change notification settings - Fork 24
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
Complement of interval? #15
Comments
You are perfectly right. I should be able to add a |
Alternatively, since the set-theoretic complement of an instance of the Interval class is not representable with an instance of the Interval class, I could define a method that simply returns a list of pairs. The reason this might be preferrable is illustrated by: >>> x = interval([1, 2], [3])
>>> x.closed_complement()
interval([-inf, 1.0], [2.0, inf])
>>> x.complement()
[(-inf, 1.0), (2.0, 3.0), (3.0, inf)] |
Landed here looking for exactly this functionality. |
Here's how I'm doing it, in a new subclass of
|
Thanks @kenahoo this was exactly what I needed. |
Is there a way to take the complement of an interval object?
Strictly speaking I think it's not possible since you define all your intervals to be unions of closed simple intervals, so the complements would be unions of open simple intervals, which are not representable in your scheme.
But if you define
complement(x)
to be the smallest object representable in your scheme whose union withx
produces the entire extended real line; or equivalently, the union of the classical complement ofx
withx.extrema()
, then it's in your scheme and it would work for me.The text was updated successfully, but these errors were encountered: