Le mardi 24 juillet 2012 à 18:37 +0300, Sergiu Ivanov a écrit : > On Mon, Jul 23, 2012 at 9:52 PM, Aaron Meurer <[email protected]> wrote: > > On Jul 23, 2012, at 12:33 PM, Sergiu Ivanov <[email protected]> > > wrote: > > > >> On Mon, Jul 23, 2012 at 9:17 PM, Aaron Meurer <[email protected]> wrote: > >>> On Jul 23, 2012, at 2:20 AM, Sergiu Ivanov <[email protected]> > >>> wrote: > >>> > >>>> On Sun, Jul 22, 2012 at 11:44 PM, Aaron Meurer <[email protected]> > >>>> wrote: > >>>>> > >>>>> Can you be more specific? Most likely, one of the results is "better" > >>>>> than the other, and the algorithm should be fixed to always give it > >>>>> regardless of ordering. > >>>> > >>>> FiniteSet._complement works as follows: > >>>> > >>>>>>> from sympy import FiniteSet > >>>>>>> FiniteSet(1, 2, 3).complement > >>>> (-oo, 1) U (1, 2) U (2, 3) U (3, oo) > >>>> > >>>> I'm not sure this result can be achieved more efficiently by a > >>>> different approach then sorting the elements. > >>> > >>> This is the exact same as FiniteSet itself. Union's args do not need > >>> to be sorted except within the printer. > >> > >> I was referring to the fact that, for example, FiniteSet(3, 1, > >> 2).complement should return the same result. > >> > >> In other words, to get the complement relative to RR, one has to sort > >> the numbers in the FiniteSet first, because otherwise one may get > >> stuff like (-oo, 3) U (1, 2) U (2, oo). > > > > Well this answer is simply wrong. > > Obviously; that's why one needs to sort the elements of the FiniteSet > when computing the complement with respect to real numbers.
The elements need to be sorted by value, not by sort_key, so this case is unrelated to the current discussion. -- You received this message because you are subscribed to the Google Groups "sympy" 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?hl=en.
