-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
Notebook flake fixes. #2439
Notebook flake fixes. #2439
Conversation
@@ -387,6 +387,7 @@ | |||
"source": [ | |||
"def show_callback():\n", | |||
" server.show('/')\n", | |||
"TODO: where does loop come from?\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this, the IOLoop import must have gotten lost somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used to be:
from tornado.ioloop import IOLoop
loop = IOLoop.current()
I wonder if this is needed though or if we can just call server.show()
right after server.start()
.
@@ -83,8 +83,7 @@ | |||
"metadata": {}, | |||
"outputs": [], | |||
"source": [ | |||
"from holoviews.plotting.mpl import MPLRenderer\n", | |||
"renderer = MPLRenderer.instance(dpi=120)" | |||
"renderer = holoviews.plotting.mpl.MPLRenderer.instance(dpi=120)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative would be to do from holoviews.plotting import mpl as hpm
at the top, then hpm.MPLRenderer.instance
here...
I've shortened it to What's the flake tool called and can I start using it myself? I'd like to make a release checklist which would include things like running nbsmoke and this flake tool. |
Looks good to me. I agree we do not want to have Merging. |
The intent of supporting Anyone got a better suggestion? And how do you feel about the above, @jbednar? |
@@ -13,7 +13,6 @@ | |||
"metadata": {}, | |||
"outputs": [], | |||
"source": [ | |||
"import xarray as xr\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I made a manual error here when dealing with the flakes caught by nbsmoke - xr
is used. I'll make a new PR (probably alongside doing python 2 lint checks).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
That's a good point and given that there seems to be exactly one such occurrence in the code I won't object marking it explicitly. |
It's nbsmoke: |
No objection from me, as long as the checks aren't any more strict than |
I'd have to see examples of where noqa in notebooks was really necessary. If we can avoid it altogether, I think we should, because notebooks are generally for showing people how things work, and any obscure syntax like that will confuse people. Of course, adding bogus actual statements like 0*val also confuses people, so it's a judgement call whether noqa is better if it comes down to that. |
It uses pyflakes, so the idea is it should "never complain about style, and it will try very, very hard to never emit false positives." |
By 'avoid it altogether', do you mean, 'avoid importing something that's not explicitly used, so noqa is never necessary in the first place', or do you mean, 'avoid adding noqa where something is imported but not explicitly used, and instead shut the linter up some other way'? (Or something else?) |
Personally I would prefer it if we just make sure our notebook are written so noqa is never necessary. If we find a particular type of noqa is often necessary, that suggests that there might be a legitimate case that it shouldn't be considered a flake. |
Notebooks are scary and confusing enough without magic comments. These comments will scare people who aren't developers. |
That's what I meant, yes. |
Ok, sounds like we're all in agreement, then. Nobody wants to see noqa in notebooks. I think I've only encountered one time where I've used noqa, and it was to mark an apparently unused import as being necessary for a particular side effect, where I did not understand why it had to be that way, but it was outside my control. |
Philipp was right that pyflakes would complain about the change he made to examples/user_guide/Plots_and_Renderers.ipynb:
Is that the best way to do it? I admit I'm now no longer asking in order to make this notebook clearer than it already is, but because I may need to do something in nbsmoke if we have code in notebooks that pyflakes complains about. Relevant pyflakes issues: PyCQA/pyflakes#159, PyCQA/pyflakes#248 |
@ceball Tbh, I think we should just replace that with:
and remove the import entirely. Probably needs some other edits to explain that properly and remove the other mention of |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Following on from #2091, I did some more work on a notebook flakes tool, and ran it on examples/. This PR is the result.
Notes:
loop
comes up as being an undefined name; is it?holoviews.plotting.mpl
is imported near the start, but is unused. I made it be used. You might not like the change. An alternative supported by the flakes tool would be to add#noqa: reason
to theholoviews.plotting.mpl
import, and reverting the change I've made here.