Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the Sage displayhook in doctests #16746

Closed
vbraun opened this issue Jul 31, 2014 · 45 comments
Closed

Use the Sage displayhook in doctests #16746

vbraun opened this issue Jul 31, 2014 · 45 comments

Comments

@vbraun
Copy link
Member

vbraun commented Jul 31, 2014

The doctests output should look like the Sage commandline output, which it currently does not quite. Differences include:

  • Dictionaries will be sorted by key, makes output more reproducable
  • Sets are printed as {1,2} instead of set([1,2])
  • Empty set is set() instead of set([])
  • Types are <Foo at 0x...> instead of <Foo object at 0x...>

Other changes:

  • Normal tracebacks can now be distinguished from tracebacks in __repr__ (IPython extension):
sage: f(*args)
<repr(<sage.interfaces.gap.GapElement at 0x...>) failed: ValueError: The session in which this object was defined is no longer running.>
  • Plots now print themselves in doctest mode:
sage: A.plot()
Graphics object consisting of 1 graphics primitive

Depends on #16992

CC: @dkrenn

Component: doctest framework

Author: Volker Braun

Branch/Commit: 3070715

Reviewer: François Bissey

Issue created by migration from https://trac.sagemath.org/ticket/16746

@vbraun vbraun added this to the sage-6.3 milestone Jul 31, 2014
@vbraun
Copy link
Member Author

vbraun commented Jul 31, 2014

Branch: u/vbraun/sort_dicts_in_doctests

@vbraun
Copy link
Member Author

vbraun commented Jul 31, 2014

New commits:

338c5c3Use Sage display hook in doctests

@vbraun
Copy link
Member Author

vbraun commented Jul 31, 2014

Commit: 338c5c3

@vbraun
Copy link
Member Author

vbraun commented Jul 31, 2014

Author: Volker Braun

@vbraun

This comment has been minimized.

@vbraun vbraun changed the title Sort dicts in doctests Use the Sage displayhook in doctests Jul 31, 2014
@vbraun

This comment has been minimized.

@vbraun
Copy link
Member Author

vbraun commented Jul 31, 2014

comment:5

The first commit changes the doctest displayhook to the one we want. This causes various doctest changes that need to be fixed.

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@vbraun
Copy link
Member Author

vbraun commented Sep 17, 2014

comment:8

I noticed that the fix for printing types "our way" (#14466) was incomplete, inside lists it still uses IPython style:

sage: type(1)
<type 'sage.rings.integer.Integer'>
sage: [type(1)]
[sage.rings.integer.Integer]

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 17, 2014

Changed commit from 338c5c3 to d363558

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 17, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

8c5f2b0Directly overwrite with fixed doctests
da59f20call git directly and from the right directory
e397b3eAdd newline at end of file and fix cmdline help
9135b6cMerge #16992 (Directly apply --fixdoctests) branch
89945c9Fix printing of types
d363558Refactor our displayhook IPython integration

@vbraun
Copy link
Member Author

vbraun commented Sep 17, 2014

Dependencies: #16992

@vbraun
Copy link
Member Author

vbraun commented Sep 18, 2014

comment:11

I've refactored our displayhook machinery so we can pick & choose which parts we want to take from IPython. Now works ok, still have to fixup old doctests.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 18, 2014

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

1b99c68Also fix the cmdline doctest
bdbdd5bMerge #16992 (Directly apply --fixdoctests) branch
a246e17Fix printing of types
eb6a66bRefactor our displayhook IPython integration
b579b92Update doctests that depended on the old displayhook

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 18, 2014

Changed commit from d363558 to b579b92

@vbraun

This comment has been minimized.

@kcrisman
Copy link
Member

comment:15

Wow, that is a massive set of changes... just out of curiosity, what does the documentation now look like for graphics? I don't know whether it is more obvious before or after this change that one needs to evaluate to get them. One reason for the spaces before (I mean the ones after plot doctests) was to "leave room" in the (live) doc for evaluating these.

@jdemeyer
Copy link
Contributor

comment:16

I see why you needed #16992 now...

@jdemeyer
Copy link
Contributor

comment:17

In src/sage/graphs/generic_graph.py, this was probably intended as a doctest (although certainly something went wrong around those lines):

sage: g.layout(layout="acyclic_dummy", save_po=True)
{('0', 0): [0.3356712660780875, 0],
 ('0', 1): [0.33563875939602245, 1],
 ('1', 0): [0.6751346747788185, 0],
 ('1', 1): [0.6715689173983604, 1]}

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 19, 2014

Changed commit from b362aa6 to 7de159a

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 19, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

7de159aFix more random test failures

@cheuberg
Copy link
Contributor

comment:29

Now, all doctests pass on my linux mint 64 bit desktop.

@vbraun
Copy link
Member Author

vbraun commented Sep 20, 2014

comment:30

All doctest pass on the buildbot...

@dimpase
Copy link
Member

dimpase commented Sep 26, 2014

comment:31

Did you try this on ARM?

@vbraun
Copy link
Member Author

vbraun commented Sep 26, 2014

comment:32

ARM is part of the buildbot now, so yes ;-)

@kiwifb
Copy link
Member

kiwifb commented Sep 26, 2014

comment:33

Since it pass on the build bot and I don;t see any obvious problem with the new code itself I will give it a positive review. I expect ARM to be irrelevant in this context as we are only talking about re-formatting current doctests.
Plus it will fix broken doctests in sage-on-gentoo (dictionaries displayed in a different order).

@kiwifb
Copy link
Member

kiwifb commented Sep 26, 2014

Reviewer: François Bissey

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 26, 2014

Changed commit from 7de159a to f9af4ee

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 26, 2014

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

a25e286trac #17013: new class WordDatatype_char
398b33ctrac #17013: added is_square in WordDatatype_char
a563343trac #17013: doctests improvements + bug fix
c00964dtrac #17013: fix Python C API declaration
f9af4eeMerge #17013 to resolve conflict

@vbraun
Copy link
Member Author

vbraun commented Sep 26, 2014

comment:36

surprisingly only one merge conflict ;-)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 27, 2014

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

3070715fix another doctest

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 27, 2014

Changed commit from f9af4ee to 3070715

@kiwifb
Copy link
Member

kiwifb commented Sep 27, 2014

comment:38

At this stage I think you have done all the work that should be done in one ticket. I suggest we have a follow up ticket for any new discoveries.

@vbraun
Copy link
Member Author

vbraun commented Sep 27, 2014

Changed branch from u/vbraun/sort_dicts_in_doctests to 3070715

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants