is_simplified()

2 views
Skip to first unread message

Alex Ghitza

unread,
Jan 26, 2008, 3:29:53 PM1/26/08
to sage-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

The following is a bit confusing:

sage: f=(x-1)
sage: f.is_simplified()
False
sage: g=f.simplify()
sage: g
x - 1
sage: g.is_simplified()
True

Is this on purpose? I.e. if one had to describe what the function
is_simplified() is supposed to do, that description should be

"Return True if self is the result of running simplify() on a symbolic
expression"

rather than the naive

"Return True if self is a simplified symbolic expression"

If yes, should I just add this description to the function's doc? If
no, should I report this as a bug?

Cheers,
Alex
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHm5hBdZTaNFFPILgRAtzmAJ4ssbGkMLRGqfH6sYxvc/bVHo2xeQCcCDs5
JGN2jVZK5PziGVL4QIVTtWQ=
=c41N
-----END PGP SIGNATURE-----

Robert Bradshaw

unread,
Jan 26, 2008, 4:10:39 PM1/26/08
to sage-...@googlegroups.com
I believe the point of is_simplified() is to see if the result has
already been simplified. Trying to detect if simplify() will modify
self is a (potentially) expensive operation, so if it knows it's been
simplified then it returns True, but otherwise it returns False
(which may be a false positive).

Perhaps a clearer name would have been "has_been_simplified?" The
docstring could use clarifying though (and whoever wrote this
function might want to speak up).

- Robert

> --~--~---------~--~----~------------~-------~--~----~
> To post to this group, send email to sage-...@googlegroups.com
> To unsubscribe from this group, send email to sage-devel-
> unsub...@googlegroups.com
> For more options, visit this group at http://groups.google.com/
> group/sage-devel
> URLs: http://www.sagemath.org
> -~----------~----~----~----~------~----~------~--~---

PGP.sig

William Stein

unread,
Jan 27, 2008, 12:08:53 PM1/27/08
to sage-...@googlegroups.com
On Jan 26, 2008 1:10 PM, Robert Bradshaw <robe...@math.washington.edu> wrote:
> I believe the point of is_simplified() is to see if the result has
> already been simplified. Trying to detect if simplify() will modify
> self is a (potentially) expensive operation, so if it knows it's been
> simplified then it returns True, but otherwise it returns False
> (which may be a false positive).
>
> Perhaps a clearer name would have been "has_been_simplified?" The
> docstring could use clarifying though (and whoever wrote this
> function might want to speak up).

I wrote it. You're right about the intention -- it's really
"has_been_simplified".
I would be OK with somebody changing the name to that.

--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Reply all
Reply to author
Forward
0 new messages