Comment #7 on issue 1646 by asmeurer: Solving inequalities
http://code.google.com/p/sympy/issues/detail?id=1646
Wow. This is shaping up nicely. Here are some things I found:
This test fails:
________________ sympy/printing/tests/test_str.py:test_Interval
________________
File
"/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/tests/test_str.py",
line 120, in
test_Interval
assert str(Interval(0, x)) == "[0, x]"
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/interval.py",
line 61, in __new__
raise ValueError, "Only real intervals are supported"
ValueError: Only real intervals are supported
tests finished: 1630 passed, 9 skipped, 37 xfailed, 1 xpassed, 1
exceptions in 311.55 seconds
DO *NOT* COMMIT!
I am assuming you will fix this whenever you get around to writing the
tests.
In [2]: Union(Interval(1, 2), Interval(2, 3))
Out[2]: [1, 3]
In [3]: Union(Interval(1, 2), Interval(2, 3, True))
Out[3]: [1, 2] ∪ (2, 3]
Shouldn't the second one also return [1, 3]?
Very nice:
In [4]: a = Interval(1, 2)
In [5]: b = Interval(3, oo)
In [6]: a
Out[6]: [1, 2]
In [7]: b
Out[7]: [3, ∞)
In [8]: a + b
Out[8]: [1, 2] ∪ [3, ∞)
In [9]: a - b
Out[9]: [1, 2]
In [13]: a.complement
Out[13]: (-∞, 1) ∪ (2, ∞)
Is this a standard convention, or did you just come up with it to do this?
I wonder if it would make more
sense for * to do cartesian product, whenever that is implemented. By the
way, there is also __div__ to work
with.
In [14]: a*b
Out[14]: ∅
One thing, shouldn't this return a complement, fitting with __sub__?:
In [10]: -a
Out[10]: -[1, 2]
Also cool:
In [34]: a.sup
Out[34]: 2
In [35]: a.inf
Out[35]: 1
In [37]: latex(a + b)
Out[37]: $\left[1, 2\right] \cup \left[3, \infty\right)$
In [44]: b = Interval(3, 4, False, True)
In [45]: b
Out[45]: [3, 4)
In [46]: a + b
Out[46]: [1, 2] ∪ [3, 4)
In [47]: (a + b).measure
Out[47]: 2
This is very nice. It just needs tests and documentation as you noted. By
the way, your patches are getting
large. It would be easier for both of us if you uploaded to a github
account.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en
-~----------~----~----~----~------~----~------~--~---