Renaming Real to Float

8 views
Skip to first unread message

Aaron Meurer

unread,
May 12, 2011, 6:49:41 PM5/12/11
to sy...@googlegroups.com
Hi.

There was a discussion over at
http://code.google.com/p/sympy/issues/detail?id=1721 to rename the
Real class to Float, because the name fits the class better. The
reasoning is that Real represents floating point numbers, not any real
number like sin(1) or 2*pi, and it is confusing to have the subtle
difference between Real and real in the docs. See the discussion over
at that issue page for more info.

How do people feel about this? If it were to happen, it would happen
in the next release, which also breaks some other things in terms of
backwards compatibly.

Aaron Meurer

Ondrej Certik

unread,
May 12, 2011, 7:06:55 PM5/12/11
to sy...@googlegroups.com

It seems that most code uses some variation of Real already:

Sage: uses RealField and RealLiteral:

sage: a = 1.345
sage: type(a)
<type 'sage.rings.real_mpfr.RealLiteral'>


Mathematica uses "Real": http://reference.wolfram.com/mathematica/ref/Real.html

And given that it would break compatibility, it seems to me that it's
not worthy to make the change.

Ondrej

Ronan Lamy

unread,
May 12, 2011, 8:28:03 PM5/12/11
to sy...@googlegroups.com
Le jeudi 12 mai 2011 à 16:06 -0700, Ondrej Certik a écrit :
> On Thu, May 12, 2011 at 3:49 PM, Aaron Meurer <asme...@gmail.com> wrote:
> > Hi.
> >
> > There was a discussion over at
> > http://code.google.com/p/sympy/issues/detail?id=1721 to rename the
> > Real class to Float, because the name fits the class better. The
> > reasoning is that Real represents floating point numbers, not any real
> > number like sin(1) or 2*pi, and it is confusing to have the subtle
> > difference between Real and real in the docs. See the discussion over
> > at that issue page for more info.
> >
> > How do people feel about this? If it were to happen, it would happen
> > in the next release, which also breaks some other things in terms of
> > backwards compatibly.
>
> It seems that most code uses some variation of Real already:
>
> Sage: uses RealField and RealLiteral:
>
> sage: a = 1.345
> sage: type(a)
> <type 'sage.rings.real_mpfr.RealLiteral'>
>
>
> Mathematica uses "Real": http://reference.wolfram.com/mathematica/ref/Real.html

And their "Possible issues" section can be summed up with "Reals aren't
reals, reals aren't Reals". Do we need to repeat others' mistakes?

Anyway, both Python and numpy call floats "float" which, I think, trumps
compatibility with Sage and Mathematica. Maple and Maxima use "float" as
well.

> And given that it would break compatibility, it seems to me that it's
> not worthy to make the change.

If you look at the tree for 0.6.7, it seems to be used less often than
the syntax symbols('xyz') which will be forbidden in 0.7.0, apparently.
Not to mention the Basic/Expr split that is bound to break a lot of code
in ways that won't always be easily fixed.

For me, this is a big flaw that confuses users and devs on a crucial
matter for sympy: the difference between symbolic and numeric
computation. I certainly think it's worth the small increase in
compatibility breaking.

Aaron Meurer

unread,
May 12, 2011, 8:50:11 PM5/12/11
to sy...@googlegroups.com
By the way, I watched this presentation about the ast module from
PyCon 2011. It's pretty interesting. Based on that, doing something
like this would be really easy to do.

http://pycon.blip.tv/file/4880291/

Aaron Meurer

> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>
>

Ondrej Certik

unread,
May 12, 2011, 10:22:27 PM5/12/11
to sy...@googlegroups.com

If Maple + Maxima both use float, I am ok with that. Do you have some
reference for that? I didn't manage to find one for Maple.


>
>> And given that it would break compatibility, it seems to me that it's
>> not worthy to make the change.
>
> If you look at the tree for 0.6.7, it seems to be used less often than
> the syntax symbols('xyz') which will be forbidden in 0.7.0, apparently.
> Not to mention the Basic/Expr split that is bound to break a lot of code
> in ways that won't always be easily fixed.

Yes, the Expr thing broke pydy for example. It was easy to fix, but it
is backwards incompatible.

>
> For me, this is a big flaw that confuses users and devs on a crucial
> matter for sympy: the difference between symbolic and numeric
> computation. I certainly think it's worth the small increase in
> compatibility breaking.

Ondrej

Ronan Lamy

unread,
May 12, 2011, 10:40:36 PM5/12/11
to sy...@googlegroups.com

Ondrej Certik

unread,
May 13, 2011, 12:19:20 AM5/13/11
to sy...@googlegroups.com

Thanks. This looks good. I am ok with Float too. If it is not too
hard, we can deprecate Real(), e.g. something like:

class Real(Basic)

def __eval__ /or __new__/ ()
deprecated
return Float(*args)

Ondrej

Aaron Meurer

unread,
May 13, 2011, 1:13:45 AM5/13/11
to sy...@googlegroups.com

Yeah, let's do that.

Aaron Meurer

asmeurer

unread,
May 17, 2011, 10:12:29 PM5/17/11
to sympy


On May 12, 11:13 pm, Aaron Meurer <asmeu...@gmail.com> wrote:
> On Thu, May 12, 2011 at 10:19 PM, Ondrej Certik <ond...@certik.cz> wrote:
> > On Thu, May 12, 2011 at 7:40 PM, Ronan Lamy <ronan.l...@gmail.com> wrote:
> >> Le jeudi 12 mai 2011 à 19:22 -0700, Ondrej Certik a écrit :
> >>> On Thu, May 12, 2011 at 5:28 PM, Ronan Lamy <ronan.l...@gmail.com> wrote:
> >>> > Le jeudi 12 mai 2011 à 16:06 -0700, Ondrej Certik a écrit :
> >>> >> On Thu, May 12, 2011 at 3:49 PM, Aaron Meurer <asmeu...@gmail.com> wrote:
> >>> >> > Hi.
>
> >>> >> > There was a discussion over at
> >>> >> >http://code.google.com/p/sympy/issues/detail?id=1721to rename the
This would still break things like isinstance(expr, Real) and
expr.is_Real (I suppose we could also create a deprecated property for
the last one).

Ronan, do you have time to update your patch for this?

Aaron Meurer

Ronan Lamy

unread,
May 17, 2011, 10:34:38 PM5/17/11
to sy...@googlegroups.com

Yes, I can do it. The commit renaming Real to Float is ready, but I'm
not sure how to handle the deprecation. For isinstance(expr, Real), the
only thing we could do is to play tricks with ABCs and__subclasshook__
in 2.6+. For Real(...), it's probably easier to make it a just a
function:
def Real(*args, **kwargs):
return Float(*args, kwargs)


asmeurer

unread,
May 18, 2011, 7:50:34 PM5/18/11
to sympy
Can you submit it as a pull request?

Don't worry about isinstance. We might as well create a
deprecated .is_Real property, since that will be trivial. And the
function idea sounds good too (just don't forget to put deprecation
warnings in there).

Aaron Meurer

On May 17, 8:34 pm, Ronan Lamy <ronan.l...@gmail.com> wrote:
> Le mardi 17 mai 2011 à 19:12 -0700, asmeurer a écrit :
>
>
>
>
>
>
>
>
>
>
>
> > On May 12, 11:13 pm, Aaron Meurer <asmeu...@gmail.com> wrote:
> > > On Thu, May 12, 2011 at 10:19 PM, Ondrej Certik <ond...@certik.cz> wrote:
> > > > On Thu, May 12, 2011 at 7:40 PM, Ronan Lamy <ronan.l...@gmail.com> wrote:
> > > >> Le jeudi 12 mai 2011 à 19:22 -0700, Ondrej Certik a écrit :
> > > >>> On Thu, May 12, 2011 at 5:28 PM, Ronan Lamy <ronan.l...@gmail.com> wrote:
> > > >>> > Le jeudi 12 mai 2011 à 16:06 -0700, Ondrej Certik a écrit :
> > > >>> >> On Thu, May 12, 2011 at 3:49 PM, Aaron Meurer <asmeu...@gmail.com> wrote:
> > > >>> >> > Hi.
>
> > > >>> >> > There was a discussion over at
> > > >>> >> >http://code.google.com/p/sympy/issues/detail?id=1721torename the

Ronan Lamy

unread,
May 18, 2011, 8:10:57 PM5/18/11
to sy...@googlegroups.com
Le mercredi 18 mai 2011 à 16:50 -0700, asmeurer a écrit :
> Can you submit it as a pull request?
>
https://github.com/sympy/sympy/pull/321
Reply all
Reply to author
Forward
0 new messages