Re: [sage-devel] Re: hiding doctest in documentation

2014-08-28 Thread Nicolas M. Thiery
On Thu, Jul 31, 2014 at 02:23:02PM -0700, Travis Scrimshaw wrote: ... Just do ``sorted(d.items(), key=str)`` for doctests where the order could change (which usually is for dicts of size larger than 3). An variant which I like is to use ``pprint`` sage: d = { 'b':1, 'a':3, 'c':5

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Daniel Krenn
Am 2014-07-28 um 17:47 schrieb Volker Braun: On Monday, July 28, 2014 11:42:05 AM UTC-4, William wrote: Specifically for dictionaries we also have the displayhook sorting by key: sage: d = {'a':23, 'b':34, 'au':56, 'bbf':234, 'aaa':234} sage: str(d)# dict uses internal order {'a': 23,

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Volker Braun
On Thursday, July 31, 2014 9:16:50 AM UTC-4, Daniel Krenn wrote: Does this mean it is guaranteed that in doctests dicts are always shown with their keys sorted? AFAIK: Yes, but only the top-level dict (no guarantees for nested datastructures) -- You received this message because you are

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Daniel Krenn
Am 2014-07-31 um 15:55 schrieb Volker Braun: On Thursday, July 31, 2014 9:16:50 AM UTC-4, Daniel Krenn wrote: Does this mean it is guaranteed that in doctests dicts are always shown with their keys sorted? AFAIK: Yes, but only the top-level dict (no guarantees for nested

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Volker Braun
The doctesting uses its own displayhook, though I thought it would also sort dicts (since it obviously helps with making doctests reproducable). IMHO we should add it... On Thursday, July 31, 2014 10:43:27 AM UTC-4, Daniel Krenn wrote: Am 2014-07-31 um 15:55 schrieb Volker Braun: On

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Nils Bruin
On Thursday, July 31, 2014 7:43:27 AM UTC-7, Daniel Krenn wrote: Am 2014-07-31 um 15:55 schrieb Volker Braun: On Thursday, July 31, 2014 9:16:50 AM UTC-4, Daniel Krenn wrote: Does this mean it is guaranteed that in doctests dicts are always shown with their keys sorted?

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Volker Braun
On Thursday, July 31, 2014 11:28:59 AM UTC-4, Nils Bruin wrote: not everything in python *can* be sorted. Everything can be sorted, but not necessarily in a stable way ;-) -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Volker Braun
This is now http://trac.sagemath.org/ticket/16746 On Thursday, July 31, 2014 11:23:14 AM UTC-4, Volker Braun wrote: The doctesting uses its own displayhook, though I thought it would also sort dicts (since it obviously helps with making doctests reproducable). IMHO we should add it... --

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Travis Scrimshaw
I disagree with sorting the output of dicts. I ended up finding a very subtle bug dealing with dictionary output that I would have had a much harder time figuring out with the automatic sorting. Just do ``sorted(d.items(), key=str)`` for doctests where the order could change (which usually

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Nils Bruin
On Thursday, July 31, 2014 2:23:03 PM UTC-7, Travis Scrimshaw wrote: I disagree with sorting the output of dicts. I ended up finding a very subtle bug dealing with dictionary output that I would have had a much harder time figuring out with the automatic sorting. Just do

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread Volker Braun
I disagree with the whole idea that doctests should be deliberately fragile and break randomly on the buildbot to teach unwary developers a lesson. Either sort by keys, or disallow dictionary output altogether AND print a useful diagnostic in doctests. This whole discussion is similar to the

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-31 Thread William Stein
On Jul 31, 2014 7:34 PM, Volker Braun vbraun.n...@gmail.com wrote: I disagree with the whole idea that doctests should be deliberately fragile and break randomly on the buildbot to teach unwary developers a lesson. I very strongly agree with you. I was going to write but you said it better.

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-29 Thread Nathann Cohen
That's annoying. The entire point of the tests section (which I introduced in the first place) was to not appear in the ref manual, interactive docs, etc. I guess I never got around to implementing that or somebody changed it. Well, it does not hurt much after all.. Users see the

[sage-devel] Re: hiding doctest in documentation

2014-07-28 Thread Volker Braun
On Monday, July 28, 2014 9:42:16 AM UTC-4, Daniel Krenn wrote: Is there a way to hide a doctest in the documentation, but still keep it in the source, so that it will get tested? No. It wouldn't be a doctest then, would it? sage: dict = {'a': 'b', 'x': 'y'} # random {'a': 'b', 'x':

[sage-devel] Re: hiding doctest in documentation

2014-07-28 Thread Simon King
Hi Daniel, On 2014-07-28, Daniel Krenn kr...@aon.at wrote: Background: The output of a doctest is a dictionary; therefore there is some uncertainty about the ordering of the entires. To have the dict-output, but get tested as well, I want to do the following: sage: dict = {'a': 'b', 'x':

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-28 Thread William Stein
On Mon, Jul 28, 2014 at 8:24 AM, Simon King simon.k...@uni-jena.de wrote: Hi Daniel, On 2014-07-28, Daniel Krenn kr...@aon.at wrote: Background: The output of a doctest is a dictionary; therefore there is some uncertainty about the ordering of the entires. To have the dict-output, but get

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-28 Thread Volker Braun
On Monday, July 28, 2014 11:42:05 AM UTC-4, William wrote: That said, there is a ready-made solution [1] for exactly the original question, The TESTS: section does appear in the reference manual, fyi. Its just a way to separate it off from EXAMPLES: Specifically for dictionaries we also

Re: [sage-devel] Re: hiding doctest in documentation

2014-07-28 Thread William Stein
On Jul 28, 2014 8:47 AM, Volker Braun vbraun.n...@gmail.com wrote: On Monday, July 28, 2014 11:42:05 AM UTC-4, William wrote: That said, there is a ready-made solution [1] for exactly the original question, The TESTS: section does appear in the reference manual, fyi. Its just a way to