Skip to content

Fix hidden=True still generating plots in Jupyter notebooks#32

Open
weisscharlesj wants to merge 7 commits into
sametz:developfrom
weisscharlesj:master
Open

Fix hidden=True still generating plots in Jupyter notebooks#32
weisscharlesj wants to merge 7 commits into
sametz:developfrom
weisscharlesj:master

Conversation

@weisscharlesj

Copy link
Copy Markdown

Fixed the issue where the mplplot(), mplplot_stem(), and mplplot_lineshape() functions still generate plots in Jupyter notebooks by moving all matplotlib code in these functions inside the if not hidden condition. Also cleaned up some code to account for newer versions of dependencies.

  • Removed deprecated use_line_collection keyword argument from ax.stem() call in mplplot_stick(), which caused a TypeError in matplotlib 3.3+
  • Moved all matplotlib plotting code inside if not hidden: blocks in mplplot(), mplplot_stick(), and mplplot_lineshape() to prevent figures from rendering in Jupyter when hidden=True
  • Removed leftover debug code (lines variable and print(lines)) from mplplot()
  • Removed outdated comment referencing matplotlib 3.3 use_line_collection warning and updated stem() function calls by removing this deprecated and removed parameter

All pytest and flake8 tests pass with these changes.

Moved all matpllotlib code in the mplplot() function into the if statement controlled by the hidden= parameter. This fixes the issues that hidden=True does not prevent plots from appearing in Jupyter notebooks.
Moved all matplotlib code into the if not hidden condition so that the plot doesn't show in a Jupyter notebook when hidden=True. This fixes an issue that the user cannot turn of plotting in the mplplot() function to use their own plotting library. Removed the deprecated and removed use_line_collection= argument from the plt.stem() function.
Updated .gitignore with *i.ni and *.bak.
Updated the qm_explanation.ipynb notebooks (both) imports by changing from IPython.core.display to IPython.display.
Added .ipynb_checkpoints to the exclude list for flake8 in the setup.cfg file.
The sphinxcontrib-napoleon package breaks in newer version of Python. Updated conf.py to use the version that comes with Sphinx.
Moved the rest of the plotting code inside the if not hidden conditions in mplplot(), mplplot_stick(), and mplplot_lineshape() functions. Removed print(lines) debugging code and removed the note about suppressing a warning until matplotlib 3.3 because this is now updated in the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant