test changes on sage.tests.book_stein_ent

48 views
Skip to first unread message

vdelecroix

unread,
May 18, 2013, 8:58:25 AM5/18/13
to sage-devel
Hi,

Because of #14568 some output of the tests in
sage.tests.book_stein_ent changed. As they are the doctest of some
book I wonder if there is something specific to do in that case ?

Best,
Vincent

John Cremona

unread,
May 18, 2013, 9:19:58 AM5/18/13
to SAGE devel
No, the convention is just to make appropriate changes to the output
as usual. This has happened to me.

John

> Best,
> Vincent
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To post to this group, send email to sage-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

William Stein

unread,
May 18, 2013, 11:41:43 AM5/18/13
to sage-...@googlegroups.com
On Sat, May 18, 2013 at 6:19 AM, John Cremona <john.c...@gmail.com> wrote:
> On 18 May 2013 13:58, vdelecroix <20100.d...@gmail.com> wrote:
>> Hi,
>>
>> Because of #14568 some output of the tests in
>> sage.tests.book_stein_ent changed. As they are the doctest of some
>> book I wonder if there is something specific to do in that case ?
>>
>
> No, the convention is just to make appropriate changes to the output
> as usual. This has happened to me.

Well it would be nice if somebody would tell the author (me, in this
case) so that they can update their book. Fortunately, I read
sage-devel, so I caught this...

>
> John
>
>> Best,
>> Vincent
>>
>> --
>> You received this message because you are subscribed to the Google Groups "sage-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
>> To post to this group, send email to sage-...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sage-devel?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To post to this group, send email to sage-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



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

John Cremona

unread,
May 18, 2013, 11:49:14 AM5/18/13
to SAGE devel
book I wonder if there is something specific to do in that case ?
>>>
>>
>> No, the convention is just to make appropriate changes to the output
>> as usual. This has happened to me.
>
> Well it would be nice if somebody would tell the author (me, in this
> case) so that they can update their book. Fortunately, I read
> sage-devel, so I caught this...

Apologies, I nearly added something like "of course it would be
courteous to inform William as author..." but for some reason did
not. Sorry, William!

John

vdelecroix

unread,
May 18, 2013, 12:42:16 PM5/18/13
to sage-devel
Hi William,

> >> Because of #14568 some output of the tests in
> >> sage.tests.book_stein_ent changed. As they are the doctest of some
> >> book I wonder if there is something specific to do in that case ?
>
> > No, the convention is just to make appropriate changes to the output
> > as usual.  This has happened to me.
>
> Well it would be nice if somebody would tell the author (me, in this
> case) so that they can update their book.  Fortunately, I read
> sage-devel, so I caught this...

Sure, it was not my intention to not inform the author !!! The patch
is still in an experimental version and it was just a precaution to
know if there is some special procedure to deal with sage.tests.

David Loeffler

unread,
May 20, 2013, 4:34:27 AM5/20/13
to SAGE devel
We should have a clear policy on this, because it's been a contentious
issue in the past. I remember this came up once with regard to a patch
I had refereed, which changed an error message in finite fields and
thus broke the doctests in sage/tests/french_book/. The original fix
was just to change the doctests, but the authors of the French book
were very highly displeased by this and insisted that the code be
changed back to match the book. (See tickets #8334 and #12084.)

It seems sensible to me that any file in the "tests" directory can
have a nominated maintainer -- who should be clearly identified in the
file header -- and the file should not be changed without consulting
them. What do others think? If so, we should probably clarify this
policy with a README file in sage/tests/.

David

Nicolas M. Thiery

unread,
May 22, 2013, 1:12:36 PM5/22/13
to sage-...@googlegroups.com
On Mon, May 20, 2013 at 09:34:27AM +0100, David Loeffler wrote:
> We should have a clear policy on this, because it's been a contentious
> issue in the past. I remember this came up once with regard to a patch
> I had refereed, which changed an error message in finite fields and
> thus broke the doctests in sage/tests/french_book/. The original fix
> was just to change the doctests, but the authors of the French book
> were very highly displeased by this and insisted that the code be
> changed back to match the book. (See tickets #8334 and #12084.)
>
> It seems sensible to me that any file in the "tests" directory can
> have a nominated maintainer -- who should be clearly identified in the
> file header -- and the file should not be changed without consulting
> them. What do others think? If so, we should probably clarify this
> policy with a README file in sage/tests/.

+1
Nicolas
--
Nicolas M. Thi�ry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/

Rob Beezer

unread,
May 23, 2013, 3:57:30 PM5/23/13
to sage-...@googlegroups.com
I have given this a lot of thought the past few years (perhaps this is obvious).  I prepared extensive material about Sage for Tom Judson's Abstract Algebra book and have an automated procedure to produce doctests of the code examples.  While I use sagetex for some aspects of this, the philosophy is the reverse.  I provide expected output in the source, rather than just blindly letting Sage produce the output.  In a few places I illustrate bugs, in hope of catching their corrections later.

About twice a year, I update the source in response to failures in these doctests.  Largely, these are just formatting or sorting changes.  But it is obvious that over time significant bitrot can set in.  So I think this is an extremely important part of writing about Sage - put in the infrastructure for testing, and revisit it regularly.  I hope to make some progress this summer making such an infrastructure more usable than what I have done already.

Relative to this thread, I have *never* felt that the Sage library should react to trivially-failing doctests associated with books.  It should be the author's responsibility to keep the book current with the (changing) state of Sage.  However, I do hope doctests from books, included in the Sage distribution, extend the protection against bugs, and further help developers as they produce code.

So I very much agree with David's proposal below that such doctest files are clearly labeled with a maintainer.  Further, I would suggest that we do not let "the tail wag the dog" by requiring patches to pass these tests.  I would prefer not to see these files edited, so that they continue to reflect the source they come from.   Of course, this leads to the situation where a doctest file might consistently produce many errors - an undesirable situation, especially if the maintainer is not very responsive.

One solution might be to have entire books in the Sage distribution (in a source format that is not too large) and under revision control.  Anyone could edit the code examples in response to patches, and the changes could be used by the author to update their canonical version.  Perhaps this could all be accomplished in the spkg format, similar to making changes for upstream maintainers (along with scripts for generating books from source into different formats, such as web pages or PDF).  I am not familiar enough with the technical mechanics of an spkg to be sure if this would be workable.  Any informed opinions?

Rob

leif

unread,
May 23, 2013, 5:12:01 PM5/23/13
to sage-...@googlegroups.com
Rob Beezer wrote:
> <SNIP>
> One solution might be to have entire books in the Sage distribution (in
> a source format that is not too large) and under revision control.
> Anyone could edit the code examples in response to patches, and the
> changes could be used by the author to update their canonical version.
> Perhaps this could all be accomplished in the spkg format, similar to
> making changes for upstream maintainers (along with scripts for
> generating books from source into different formats, such as web pages
> or PDF). I am not familiar enough with the technical mechanics of an
> spkg to be sure if this would be workable. Any informed opinions?

Currently, those tests are part of the Sage library, and the policy is
that spkgs are not allowed to modify it.

We could probably move them to (e.g.) $SAGE_SHARE/doc/... though, and
change doctesting (and docbuilding?) accordingly.


-leif

--
() The ASCII Ribbon Campaign
/\ Help Cure HTML E-Mail

Nicolas M. Thiery

unread,
May 23, 2013, 9:28:33 PM5/23/13
to sage-...@googlegroups.com
On Thu, May 23, 2013 at 12:57:30PM -0700, Rob Beezer wrote:
> I have given this a lot of thought the past few years (perhaps this is
> obvious). I prepared extensive material about Sage for Tom Judson's
> Abstract Algebra book and have an automated procedure to produce doctests
> of the code examples. While I use sagetex for some aspects of this, the
> philosophy is the reverse. I provide expected output in the source,
> rather than just blindly letting Sage produce the output. In a few places
> I illustrate bugs, in hope of catching their corrections later.

For the record: for the French sage book we are following the same
strategy, using sagetex. We put the expected results in the file. and
sagetex extracts a file on which we can run the tests (and that we can
submit for inclusion into Sage). Depending on the situation the
examples are setup so that what's get typeset is either the latex
output produced by sage, the text output produced by sage, or the
expected output that is specified in the file.

It's not perfect (especially for speed of compilation). Also in the
process we patched quite some sagetex and it would be great if those
patches made their way into standard sagetex (hint hint).

Cheers,

William Stein

unread,
May 27, 2013, 12:30:10 PM5/27/13
to sage-...@googlegroups.com
Hi,

Going with the topic of this thread, a new Sage user just sent me an
email explaining that an example from Ch 8 of Craig Finch's book
doesn't work with sage-5.10.beta4:


var('x')
f = lambda x: 3 * x^3 - 7 * x^2 + 2
minval, x_min = find_minimum_on_interval(f, 0, 3)
print("Min on interval [0,3]: f({0}) = {1}".format(x_min, minval))
maxval, x_max = find_maximum_on_interval(f, -1, 1)
print("Max on interval [-1,1]: f({0}) = {1}".format(x_max, maxval))
f_plot = plot(f,(x, -1, 2.5))
min_point = point((x_min, minval), color='red', size=50)
max_point = point((x_max, maxval), color='black', size=50)
show(f_plot + min_point + max_point, figsize=(4, 4))


I tried it out, and the fix is to change find_minimum_on_interval to
find_local_minimum, and the same with maximum, so this works:

var('x')
f = 3 * x^3 - 7 * x^2 + 2
minval, x_min = find_local_minimum(f, 0, 3)
print("Min on interval [0,3]: f({0}) = {1}".format(x_min, minval))
maxval, x_max = find_local_maximum(f, -1, 1)
print("Max on interval [-1,1]: f({0}) = {1}".format(x_max, maxval))
f_plot = plot(f,(x, -1, 2.5))
min_point = point((x_min, minval), color='red', size=50)
max_point = point((x_max, maxval), color='black', size=50)
show(f_plot + min_point + max_point, figsize=(4, 4))
#########

Anyway this was caused by http://trac.sagemath.org/2607, which is a
complicated ticket with remarks like "I'm not in favour of giving a
positive review, since the proposed patch does not solve the problem
described in the description of that ticket. -- Paul Zimmerman". I
hope maybe people who were involved will re-consider looking into
this, since it seems that we've broken code in a published Sage book,
which is hard to update (since it is paper).

(In https://cloud.sagemath.com, this issue a bit non-obvious for users
to resovle because evidently the deprecation decorator is somehow
broken there, at least in this case -- but that's entirely my fault,
and a bug in cloud.sagemath, which I'll fix.)

-- William
> Nicolas M. Thiéry "Isil" <nth...@users.sf.net>
> http://Nicolas.Thiery.name/
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To post to this group, send email to sage-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



Reply all
Reply to author
Forward
0 new messages