-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
"if 1:" blocks in examples #12191
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
Comments
👍 |
I can do this, should I take it up? |
You are welcome to do this! 👍 Concerning, E.g. for https://matplotlib.org/devdocs/gallery/axisartist/demo_axisline_style.html I would just remove the conditional and dedent. OTOH, more program like examples such as https://matplotlib.org/devdocs/gallery/misc/demo_agg_filter.html?highlight=agg%20filter definitively call for |
added the commits @timhoffm, please review! |
Fixed by #12222. |
Oops, no, that didn't catch all of them:
|
Let me add them, might take some time! |
I think I know why this exists - it's a trick I use to paste multiple lines of code into IDLE, which unlike IPython refuses to run any of them if there are non-indented newlines |
* change proposed in issue #12191 removed the confusing if 1: as propsed in #12191 * change requested in #12191 * added main() to resolve comments from #12191 * update #12191 * flake-8 corrections #12191 * update ```plt.show``` for #12191 * flake8 update #12191 * Update demo_annotation_box.py * Update demo_agg_filter.py * Update patheffect_demo.py * Update demo_text_rotation_mode.py * Update demo_text_path.py * Update demo_curvelinear_grid.py * Update demo_curvelinear_grid2.py * flake8 compliant * flake8 compliant * flake8 compliant * Update patheffect_demo.py * Update demo_annotation_box.py * flake8 compliant * Update demo_text_rotation_mode.py * Update patheffect_demo.py * Update demo_annotation_box.py
Now complete with #12260. |
Bug report
Some examples contain code in an
if 1:
block.e.g. https://matplotlib.org/devdocs/gallery/axisartist/demo_axisline_style.html
or https://matplotlib.org/devdocs/gallery/event_handling/pick_event_demo.html
IMO this does not make sense and is rather confusing for the reader.
The condition should simply be removed for trivial cases, or replaced by functions if appropriate.
The text was updated successfully, but these errors were encountered: