From fba7e5cd2ad12e239346a256f08b15be78fa7e2b Mon Sep 17 00:00:00 2001 From: Ryan Soklaski Date: Sat, 11 Apr 2020 10:23:51 -0400 Subject: [PATCH 1/5] fix missing markdown block surrounding python code --- Python/Module5_OddsAndEnds/WorkingWithFiles.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Python/Module5_OddsAndEnds/WorkingWithFiles.md b/Python/Module5_OddsAndEnds/WorkingWithFiles.md index 1c76cbfc..d68d8f27 100644 --- a/Python/Module5_OddsAndEnds/WorkingWithFiles.md +++ b/Python/Module5_OddsAndEnds/WorkingWithFiles.md @@ -14,7 +14,7 @@ jupyter: .. meta:: - :description: Topic: Working with aths and files, Difficulty: Medium, Category: Section + :description: Topic: Working with paths and files, Difficulty: Medium, Category: Section :keywords: open file, read file, pathlib, join directory, context manager, close file, rb, binary file, utf-8, encoding, pickle, numpy, load, archive, npy, npz, pkl, glob, read lines, write, save @@ -283,6 +283,8 @@ data/*.txt The `pathlib` module provides convenient functionality for globbing files. Once we have a `Path` object, we can simply call `glob()` on it and pass in a glob string. This will return a [generator](http://www.pythonlikeyoumeanit.com/Module2_EssentialsOfPython/Generators_and_Comprehensions.html#Introducing-Generators) that will yield each of the globbed files. + + ``` python # glob all of the text files in the present directory # that start with 'test' and end with '.txt' @@ -303,6 +305,8 @@ The `pathlib` module provides convenient functionality for globbing files. Once ... pass ``` + + For more details on globbing, see [the documentation](https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob).
From 569cc5dc30216cd99a38368e656f85eb01f6b3e2 Mon Sep 17 00:00:00 2001 From: Ryan Soklaski Date: Sat, 11 Apr 2020 10:40:39 -0400 Subject: [PATCH 2/5] bump build environment dependencies to use sphinx 3.0 and nbsphinx 0.6; fix deprecated sphinx configs --- Python/conf.py | 6 +- plymi.yml | 165 ++++++++++++++++++++++++++----------------------- 2 files changed, 89 insertions(+), 82 deletions(-) diff --git a/Python/conf.py b/Python/conf.py index 854b5f32..36e9c0b9 100644 --- a/Python/conf.py +++ b/Python/conf.py @@ -99,9 +99,9 @@ html_theme = "sphinx_rtd_theme" def setup(app): - app.add_stylesheet('my_theme.css') - app.add_javascript("https://www.googletagmanager.com/gtag/js?id=UA-115029372-1") - app.add_javascript("gtag.js") + app.add_css_file('my_theme.css') + app.add_js_file("https://www.googletagmanager.com/gtag/js?id=UA-115029372-1") + app.add_js_file("gtag.js") # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. diff --git a/plymi.yml b/plymi.yml index acf43f56..278eeffd 100644 --- a/plymi.yml +++ b/plymi.yml @@ -5,120 +5,127 @@ channels: dependencies: - alabaster=0.7.12=py_0 - asn1crypto=0.24.0=py37_1003 - - attrs=19.1.0=py37_1 - - backcall=0.1.0=py37_0 + - attrs=19.3.0=py_0 + - backcall=0.1.0=py_0 - blas=1.0=mkl - - bleach=3.1.0=py37_0 - - ca-certificates=2019.1.23=0 - - certifi=2019.3.9=py37_0 - - cffi=1.12.3=py37hb32ad35_0 - - colorama=0.4.1=py37_0 - - cryptography=2.6.1=py37hb32ad35_0 - - cycler=0.10.0=py37_0 - - decorator=4.4.0=py37_1 + - bleach=3.1.4=pyh9f0ad1d_0 + - ca-certificates=2020.4.5.1=hecc5488_0 + - certifi=2020.4.5.1=py37hc8dfbb8_0 + - cffi=1.14.0=py37ha419a9e_0 + - chardet=3.0.4=py37hc8dfbb8_1006 + - colorama=0.4.3=py_0 + - cryptography=2.8=py37hb32ad35_1 + - cycler=0.10.0=py_2 + - decorator=4.4.2=py_0 - defusedxml=0.6.0=py_0 - - entrypoints=0.3=py37_0 - - freetype=2.9.1=ha9979f8_1 + - entrypoints=0.3=py37hc8dfbb8_1001 + - freetype=2.10.1=ha9979f8_0 - icc_rt=2019.0.0=h0cc432a_1 - - icu=58.2=ha66f8fd_1 - - intel-openmp=2019.3=203 + - icu=64.2=he025d50_1 + - importlib-metadata=1.6.0=py37hc8dfbb8_0 + - importlib_metadata=1.6.0=0 + - intel-openmp=2019.4=245 - ipykernel=5.1.0=py37h39e3cac_0 - - ipython=7.5.0=py37h39e3cac_0 - - ipython_genutils=0.2.0=py37_0 - - ipywidgets=7.4.2=py37_0 - - jedi=0.13.3=py37_0 - - jinja2=2.10.1=py37_0 - - jpeg=9b=hb83a4c4_2 - - jsonschema=3.0.1=py37_0 + - ipython=7.13.0=py37hc8dfbb8_2 + - ipython_genutils=0.2.0=py_1 + - ipywidgets=7.5.1=py_0 + - jedi=0.16.0=py37hc8dfbb8_1 + - jinja2=2.11.1=py_0 + - jpeg=9c=hfa6e2cd_1001 + - jsonschema=3.2.0=py37hc8dfbb8_1 - jupyter=1.0.0=py37_7 - - jupyter_client=5.2.4=py37_0 - - jupyter_console=6.0.0=py37_0 - - jupyter_core=4.4.0=py37_0 - - kiwisolver=1.0.1=py37h6538335_0 - - libpng=1.6.37=h2a8f88b_0 - - libsodium=1.0.16=h9d3ae62_0 + - jupyter_client=6.1.2=py_0 + - jupyter_console=6.1.0=py_1 + - jupyter_core=4.6.3=py37hc8dfbb8_1 + - kiwisolver=1.2.0=py37heaa310e_0 + - libpng=1.6.37=hfe6a214_1 + - libsodium=1.0.17=h2fa13f4_0 - m2w64-gcc-libgfortran=5.3.0=6 - m2w64-gcc-libs=5.3.0=7 - m2w64-gcc-libs-core=5.3.0=7 - m2w64-gmp=6.1.0=2 - m2w64-libwinpthread-git=5.0.0.4634.697f757=2 - - markupsafe=1.1.1=py37he774522_0 + - markupsafe=1.1.1=py37h8055547_1 - matplotlib=3.0.3=py37hc8f65d3_0 - - mistune=0.8.4=py37he774522_0 + - mistune=0.8.4=py37hfa6e2cd_1000 - mkl=2019.3=203 - mkl_fft=1.0.10=py37h14836fe_0 - mkl_random=1.0.2=py37h343c172_0 - msys2-conda-epoch=20160418=1 - nbconvert=5.4.1=py37_3 - - nbformat=4.4.0=py37_0 + - nbformat=5.0.4=py_0 - nbsphinx=0.4.2=py_0 - notebook=5.7.8=py37_0 - numpy=1.16.3=py37h19fb1c0_0 - numpy-base=1.16.3=py37hc3f5095_0 - - openssl=1.1.1b=he774522_1 - - packaging=19.0=py_0 + - openssl=1.1.1f=hfa6e2cd_0 + - packaging=20.1=py_0 - pandoc=2.1.3=0 - - pandocfilters=1.4.2=py37_1 - - parso=0.4.0=py_0 - - pickleshare=0.7.5=py37_0 - - pip=19.1=py37_0 - - prometheus_client=0.6.0=py37_0 - - prompt_toolkit=2.0.9=py37_0 - - pycparser=2.19=py37_1 - - pygments=2.3.1=py37_0 - - pyopenssl=19.0.0=py37_0 - - pyparsing=2.4.0=py_0 - - pyqt=5.9.2=py37h6538335_2 - - pyrsistent=0.14.11=py37he774522_0 - - pysocks=1.6.8=py37_1002 - - python=3.7.3=h8c8aaf0_1 - - python-dateutil=2.8.0=py37_0 - - pytz=2019.1=py_0 - - pywinpty=0.5.5=py37_1000 - - pyzmq=18.0.0=py37ha925a31_0 - - qt=5.9.7=vc14h73c81de_0 - - qtconsole=4.4.3=py37_0 - - requests=2.21.0=py37_1000 - - send2trash=1.5.0=py37_0 - - setuptools=41.0.0=py37_0 + - pandocfilters=1.4.2=py_1 + - parso=0.6.2=py_0 + - pickleshare=0.7.5=py37hc8dfbb8_1001 + - pip=20.0.2=py_2 + - prometheus_client=0.7.1=py_0 + - prompt-toolkit=3.0.5=py_0 + - prompt_toolkit=3.0.5=0 + - pycparser=2.20=py_0 + - pygments=2.6.1=py_0 + - pyopenssl=19.1.0=py_1 + - pyparsing=2.4.7=pyh9f0ad1d_0 + - pyqt=5.9.2=py37h6538335_4 + - pyrsistent=0.16.0=py37h8055547_0 + - pysocks=1.7.1=py37hc8dfbb8_1 + - python=3.7.6=h60c2a47_5_cpython + - python-dateutil=2.8.1=py_0 + - python_abi=3.7=1_cp37m + - pytz=2019.3=py_0 + - pywin32=227=py37hfa6e2cd_0 + - pywinpty=0.5.7=py37_0 + - pyzmq=19.0.0=py37h8c16cda_1 + - qt=5.9.7=h506e8af_3 + - qtconsole=4.7.2=pyh9f0ad1d_0 + - qtpy=1.9.0=py_0 + - requests=2.23.0=pyh8c360ce_2 + - send2trash=1.5.0=py_0 + - setuptools=46.1.3=py37hc8dfbb8_0 - sip=4.19.8=py37h6538335_0 - - six=1.12.0=py37_0 - - sphinxcontrib-applehelp=1.0.1=py_0 - - sphinxcontrib-devhelp=1.0.1=py_0 - - sphinxcontrib-htmlhelp=1.0.2=py_0 + - six=1.14.0=py_1 + - sphinx=3.0.1=py_0 + - sphinxcontrib-applehelp=1.0.2=py_0 + - sphinxcontrib-devhelp=1.0.2=py_0 + - sphinxcontrib-htmlhelp=1.0.3=py_0 - sphinxcontrib-jsmath=1.0.1=py_0 - - sphinxcontrib-qthelp=1.0.2=py_0 - - sphinxcontrib-serializinghtml=1.1.1=py_0 - - sqlite=3.28.0=he774522_0 - - terminado=0.8.2=py37_0 - - testpath=0.4.2=py37_0 - - tornado=6.0.2=py37he774522_0 - - traitlets=4.3.2=py37_0 - - vc=14.1=h0510ff6_4 - - vs2015_runtime=14.15.26706=h3a45250_0 - - wcwidth=0.1.7=py37_0 - - webencodings=0.5.1=py37_1 - - wheel=0.33.1=py37_0 - - widgetsnbextension=3.4.2=py37_0 + - sphinxcontrib-qthelp=1.0.3=py_0 + - sphinxcontrib-serializinghtml=1.1.4=py_0 + - sqlite=3.30.1=hfa6e2cd_0 + - terminado=0.8.3=py37hc8dfbb8_1 + - testpath=0.4.4=py_0 + - tornado=6.0.4=py37hfa6e2cd_0 + - traitlets=4.3.3=py37hc8dfbb8_1 + - vc=14.1=h869be7e_1 + - vs2015_runtime=14.16.27012=h30e32a0_1 + - wcwidth=0.1.9=pyh9f0ad1d_0 + - webencodings=0.5.1=py_1 + - wheel=0.34.2=py_1 + - widgetsnbextension=3.5.1=py37_0 - win_inet_pton=1.1.0=py37_0 - - wincertstore=0.2=py37_0 + - wincertstore=0.2=py37_1003 - winpty=0.4.3=4 - - zeromq=4.3.1=h33f27b4_3 - - zlib=1.2.11=h62dcd97_3 + - zeromq=4.3.2=h6538335_2 + - zipp=3.1.0=py_0 + - zlib=1.2.11=h2fa13f4_1006 - pip: - babel==2.6.0 - - chardet==3.0.4 - docutils==0.14 - idna==2.8 - imagesize==1.1.0 - - jupytext-1.3.2 + - jupytext==1.4.2 - mock==2.0.0 - numpydoc==0.9.1 - pbr==5.2.0 - pyyaml==5.1 - snowballstemmer==1.2.1 - - sphinx==1.8.4 - sphinx-rtd-theme==0.4.3 - sphinxcontrib-websupport==1.1.0 - testfixtures==6.7.0 - - urllib3==1.24.2 \ No newline at end of file + - urllib3==1.24.2 From 53f5db1c6e98cf36cb93f375fc9be03d3a709151 Mon Sep 17 00:00:00 2001 From: Ryan Soklaski Date: Sat, 11 Apr 2020 10:40:56 -0400 Subject: [PATCH 3/5] fix inconsistent header in advanced indexing --- Python/Module3_IntroducingNumpy/AdvancedIndexing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/Module3_IntroducingNumpy/AdvancedIndexing.md b/Python/Module3_IntroducingNumpy/AdvancedIndexing.md index 101ed3d2..b8cb7492 100644 --- a/Python/Module3_IntroducingNumpy/AdvancedIndexing.md +++ b/Python/Module3_IntroducingNumpy/AdvancedIndexing.md @@ -402,7 +402,7 @@ Use boolean array-indexing and NumPy's [logical functions](https://docs.scipy.or -#### Converting a Boolean Index-Array to Integer index-arrays: numpy.where +### Converting a Boolean Index-Array to Integer index-arrays: numpy.where The function [numpy.where](https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html) can be used to take a boolean-valued array, and produce the *tuple* of index-arrays that access the `True` entries of that array, via integer array indexing (discussed at the beginning of this section). ```python From 261e195e0473eba42ee247c1e9c1d80660a8acf6 Mon Sep 17 00:00:00 2001 From: Ryan Soklaski Date: Sat, 11 Apr 2020 11:00:09 -0400 Subject: [PATCH 4/5] run black on conf.py --- Python/conf.py | 84 ++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/Python/conf.py b/Python/conf.py index 36e9c0b9..3176d7eb 100644 --- a/Python/conf.py +++ b/Python/conf.py @@ -31,46 +31,46 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.intersphinx', - 'nbsphinx', - 'sphinx.ext.todo', - 'sphinx.ext.mathjax', - 'sphinx.ext.githubpages'] +extensions = [ + "sphinx.ext.intersphinx", + "nbsphinx", + "sphinx.ext.todo", + "sphinx.ext.mathjax", + "sphinx.ext.githubpages", +] import jupytext -nbsphinx_custom_formats = { - '.md': lambda s: jupytext.reads(s, '.md'), -} +nbsphinx_custom_formats = {".md": lambda s: jupytext.reads(s, ".md")} nbsphinx_allow_errors = False # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'Python Like You Mean It' -copyright = '2019, Ryan Soklaski' -author = 'Ryan Soklaski' -html_title = 'Python Like You Mean It' +project = "Python Like You Mean It" +copyright = "2019, Ryan Soklaski" +author = "Ryan Soklaski" +html_title = "Python Like You Mean It" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '1.4' +version = "1.4" # The full version, including alpha/beta/rc tags. -release = '1.4.1' +release = "1.4.1" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -82,10 +82,10 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'default' +pygments_style = "default" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True @@ -98,10 +98,13 @@ # html_theme = "sphinx_rtd_theme" + def setup(app): - app.add_css_file('my_theme.css') + app.add_css_file("my_theme.css") app.add_js_file("https://www.googletagmanager.com/gtag/js?id=UA-115029372-1") app.add_js_file("gtag.js") + + # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. @@ -111,7 +114,7 @@ def setup(app): # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. @@ -119,12 +122,12 @@ def setup(app): # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars html_sidebars = { - '**': [ - 'about.html', - 'navigation.html', - 'relations.html', # needs 'show_related': True theme option to display - 'searchbox.html', - 'donate.html', + "**": [ + "about.html", + "navigation.html", + "relations.html", # needs 'show_related': True theme option to display + "searchbox.html", + "donate.html", ] } @@ -132,7 +135,7 @@ def setup(app): # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'BPLYMI' +htmlhelp_basename = "BPLYMI" # -- Options for LaTeX output --------------------------------------------- @@ -141,15 +144,12 @@ def setup(app): # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # # 'preamble': '', - # Latex figure (float) alignment # # 'figure_align': 'htbp', @@ -159,8 +159,7 @@ def setup(app): # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'BPLYMI.tex', 'BPython Like You Mean It', - 'Ryan Soklaski', 'manual'), + (master_doc, "BPLYMI.tex", "BPython Like You Mean It", "Ryan Soklaski", "manual") ] @@ -169,8 +168,7 @@ def setup(app): # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'bfundamentalsofpython', 'BPython Like You Mean It', - [author], 1) + (master_doc, "bfundamentalsofpython", "BPython Like You Mean It", [author], 1) ] @@ -180,13 +178,17 @@ def setup(app): # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'BPLYMI', 'BPython Like You Mean It', - author, 'BPLYMI', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "BPLYMI", + "BPython Like You Mean It", + author, + "BPLYMI", + "One line description of project.", + "Miscellaneous", + ) ] - - # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} +intersphinx_mapping = {"https://docs.python.org/": None} From 25d28e5ea1404269c7112e5f108db422b0dc25d5 Mon Sep 17 00:00:00 2001 From: Ryan Soklaski Date: Sat, 11 Apr 2020 13:09:09 -0400 Subject: [PATCH 5/5] actually upgrade nbsphinx --- Python/changes.rst | 7 +++++++ Python/conf.py | 6 +++--- plymi.yml | 3 +-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Python/changes.rst b/Python/changes.rst index c9d05a55..c5cb38de 100644 --- a/Python/changes.rst +++ b/Python/changes.rst @@ -7,6 +7,13 @@ in reverse chronological order. All previous releases should still be available on pip. +---------- +2020-04-11 +---------- + +Updated some of the "backend" technologies behind PLYMI: upgraded sphinx and nbsphinx. + + ---------- 2020-04-02 ---------- diff --git a/Python/conf.py b/Python/conf.py index 3176d7eb..34bd820e 100644 --- a/Python/conf.py +++ b/Python/conf.py @@ -39,9 +39,9 @@ "sphinx.ext.githubpages", ] -import jupytext - -nbsphinx_custom_formats = {".md": lambda s: jupytext.reads(s, ".md")} +nbsphinx_custom_formats = { + '.md': ['jupytext.reads', {'fmt': 'md'}], +} nbsphinx_allow_errors = False diff --git a/plymi.yml b/plymi.yml index 278eeffd..91360d32 100644 --- a/plymi.yml +++ b/plymi.yml @@ -4,7 +4,6 @@ channels: - defaults dependencies: - alabaster=0.7.12=py_0 - - asn1crypto=0.24.0=py37_1003 - attrs=19.3.0=py_0 - backcall=0.1.0=py_0 - blas=1.0=mkl @@ -54,7 +53,7 @@ dependencies: - msys2-conda-epoch=20160418=1 - nbconvert=5.4.1=py37_3 - nbformat=5.0.4=py_0 - - nbsphinx=0.4.2=py_0 + - nbsphinx=0.6.0=pyh9f0ad1d_0 - notebook=5.7.8=py37_0 - numpy=1.16.3=py37h19fb1c0_0 - numpy-base=1.16.3=py37hc3f5095_0