On Tue, Oct 21, 2008 at 11:00 PM, Fabian Seoane <[EMAIL PROTECTED]> wrote: > > > ---------- Forwarded message ---------- > From: Fabian Seoane <[EMAIL PROTECTED]> > Date: 2008/10/21 > Subject: Re: [PATCH] Make Rational accept a wider range of types as > arguments. > To: sympy-patches@googlegroups.com > > >> > >> > But then Rational(1.2222) == Integer(1) >> > and that is not only ugly but incorrect ... >> >> A solution would be to check if int(p) == p. > > yeah, that would be a nice solution, but I think that accepting float's as > arguments is inherently a bad idea (that's why we accept strings instead). > It can be handy that Integer(1.0) == Integer(1), but then > >>>> int(1.0 + less_than_machine_precission) > 1 > > and with the p = int(p) thing, you cannot tell if you are casting an int or > a float if the float is closer to an int than the machine precision. > > On the other hand, I really like the idea of being able to work with > arbitrary types that 'work like integer types' no matter whether they are > python int's or third party types. I then thought that maybe this could be > checked looking for the attribute __mod__, but this of course would be > tricky, because other libraries (or ourselves) could overload the % operator > for other purposes ... > > So no one objects, I think the best is to return to the bigining and just > accept as arguments for Rational: Integer, int's and strings ... > > Any comments??
Let's just get this in with Integer's ints and strings and then we can figure out if there is some robust way to support all int like stuff. Well, why don't you just call sympify in Rational? sympify can work with anything. Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---