On Mon, Jan 27, 2020 at 5:01 PM Nils Bruin <nbr...@sfu.ca> wrote: > For 2) there are different possibilities. > a) Something like sorted(D.iteritems()) works, but it means the doctest > now displays a list of tuples rather than something that looks like a dict: > not a problem for "TESTS:" but less than desirable for "EXAMPLES:". > b) It looks like with `from pprint import pprint` we could just do > `pprint(D)` to get a pretty-printed dict. > c) we have a pretty_print(...) which could grow a `sort=True` attribute > for dicts. However, its default currently is to output "latex" which is > grossly inappropriate for doctests. So if we go with that, we should > probably ensure that the "display manager" in force for doctests has text > preference set to "plain" (and perhaps also ensure that this is the case > when using the command line shell, where "latex" output is also far from > pretty. > > Generally I'm not so in favour of making special arrangements for the > benefit of doctests (just write them so that they don't rely on arbitrary > peculiarities, and use "#random" if you have to display such things in the > `EXAMPLES` area), but in this case we're inheriting a problem from a change > in IPython, so a more systematic approach seems appropriate. Since this > affects a lot of developers, a sage-devel discussion seem appropriate. Go > ahead! >
What about having another special doctest comment like "# sort-keys" that makes the doctest framework sort the keys before printing? This could be then implemented in one of the above ways in the doctest code. David -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAChs6_nD22%2BA4UCdn1JFRdQ4xNuvzsxqicS6nOY%2B3hTQ%3D3-EZg%40mail.gmail.com.