Conversation
Remove the timezone in the output, which is deprecated since 1.11. Skip the output showing deliberately the old and deprecated version.
Fix missing np prefix. Use print function instead of the statement. Add seed to make output repeatable.
Print statements, changes in the array repr.
| ... print("%d <%d>" % (it[0], it.index), end=' ') | ||
| ... it.iternext() | ||
| ... | ||
| 0 <0> 1 <2> 2 <4> 3 <1> 4 <3> 5 <5> | ||
| 0 <0> True | ||
| 1 <2> True | ||
| 2 <4> True | ||
| 3 <1> True | ||
| 4 <3> True | ||
| 5 <5> False |
There was a problem hiding this comment.
This doesn't look right - what is printing the booleans?
(edit: xref #15519 (comment))
There was a problem hiding this comment.
In a IPython terminal, I obtain the "old" result. When running the refguide_check.py tool the output is as in the commit.
There was a problem hiding this comment.
In a "plain" Python REPL, the output contains the booleans. All lines that return a value seem to appear. This type of detail is hard to find in the Python docs, it seems that it is "assumed to be known"...
eric-wieser
left a comment
There was a problem hiding this comment.
Mostly looks good. I'd like:
- @mattip's feedback on the use of doctest markers here
- To understand the
True/Falseprintouts in the iteration examples
Co-Authored-By: Eric Wieser <[email protected]>
| @@ -220,20 +220,37 @@ produce identical results to the ones in the previous section. | |||
| ... print("%d <%d>" % (it[0], it.index), end=' ') | |||
| ... it.iternext() | |||
There was a problem hiding this comment.
It's nasty, but this would make the output go away:
| ... it.iternext() | |
| ... it.iternext() | |
| ... None # needed to make the docs build properly :( |
There was a problem hiding this comment.
Well, the output that I put in the PR corresponds to the REPL output, that differs from the IPython output. It is a matter of choice between the two.
There was a problem hiding this comment.
I think we could make both the repl and ipython have the same output if we change line 221 to be v = it.iternext() (and line 233 too)
There was a problem hiding this comment.
I agree. However, it remains hacky: the example is modified for the purpose of a clean doctest but the modification does not reflect a programming necessity or a good practice. That being said, you are in a much better position to make the choice for this matter of style, let me know your decision.
There was a problem hiding this comment.
I think it is easier to hide this detail in an unused value than to try to explain why the loop is printing booleans. Good practice would be to use the for loop anyway, I am not a big fan of looping over an iterator with while.
There was a problem hiding this comment.
Perhaps is_not_finished = ... instead?
There was a problem hiding this comment.
, I am not a big fan of looping over an iterator with while.
Even that would be a better example, since next is a lot more useful than our iternext.
There was a problem hiding this comment.
So, for this PR, we keep the while and I add is_not_finished = ?
|
Does |
I also have the warning issue. The PR does not fix all errors, see #14970 (comment) Regarding the warning, it seems that the doctest runner at Line 766 in dae4f67 |
|
PS: how do you run pep8 on the rst files? |
Right, so it failing to work is a separate issue. It would be much easier to review your changes if I could (1) run the tests on master, see that they fail, (2) run them on your branch see that they pass, (3) review the changes for anything that looks off. But since (2) fails it means I have to think harder about whether the changes are correct, which is why I would prefer putting off the changes on that file until my preferred workflow is possible. |
Another reason to move to astropy's solution: we could file an issue there and maybe someone would add support :) |
|
I close following the merge of #15532 and will get back to it next week. Should we discuss the strategy for doctesting the guide? At https://github.com/scipy-lectures/scipy-lecture-notes we run pytest on all rst files for instance. I see that astropy also developed a tool, I will give it a look. |
|
Are there parts of this that didn't make it into #15532? It might be useful to reopen and rebase this, so we can see what's still to handle - even if we consider it in a WIP state. |
|
For the files For For |
|
Was hoping that would recompute the diff, but it doesn't seem to have |
part of #14970
Mostly "mechanical" changes following the changes of representation, the print function, or missing definitions.