Package: nostalgiaforever
pip install nostalgiaforeverA Notebook is a HypothesisIf a notebook is a hypothesis then it can be tested.Modern scientists are transitioning to a generation where notebooks are common currency. Consider how testing and documentation are crucial aspect of reusable open source software. Those best practices evolved to support the communities developing that software. Generations of open source established idioms and style guides which enable software collaboration at global scale. Now, access to reusable software is blending with modern science, where both disciplines share similar global ambitions to solve increasing complex, multi-objective problems.Consequently, notebooks have evolved past being a medium for personal insight to become assets for community innovation. They represent extra-personal objects for scientists who have evaluated procedural "units of thought" as computational narratives. In a way, a notebook represents a modern form of hypothesis, and scientists must get comfortable sharing them rapidly. Unfortunately, new authors lack conventions for sharing notebooks as hypotheses within a scientific community. This talk presents tactics from literate programming to create readable, reusable, and reproducible notebooks. These notebook authoring practices promote improved documentation and unit testing.@docfastpresenting behalf ofdeathbedsimportnbjupyterlab-fontsjyveSeedeathbedspresent @ JupyterConfromnostalgiaforeverimportimporting,testing,reuseKey TechnologiesimportnbdoctestunittestpytestKey TakeawaysNotebooks can be used for testing and software.Best practices for composing testable computational essays.Existing testing frameworks can be used with notebooks.Orderreadme.ipynbimporting.ipynbtesting.ipynbreuse.ipynbBefore the talkRestart your machineStart the watchersource activate p6 && cd ahypothesis/nostalgiaforever && watchmedo tricks tricks.ymlPrepare the Fira Code fontshttps://github.com/deathbeds/jupyterlab-fonts.Hey art nerd! Turn the color on!Cut the release.Build the docs.Github Pagesfromnbconvert.exporters.markdownimportMarkdownExporterfromnbconvert.preprocessorsimportPreprocessorclassReplaceLinks(Preprocessor):defpreprocess_cell(self,cell,resources=None,index=0):ifcell['cell_type']=='markdown':ifisinstance(cell['source'],list):cell['source']=''.join(cell['source'])cell['source']=cell['source'].replace('.ipynb','')returncell,resourcesfrompathlibimportPathif__name__=='__main__':fromIPythonimportget_ipython!jupyternbconvert--tomarkdownreadme.ipynbforpathinPath('.').rglob('*.ipynb'):ifall(notpart.startswith('.')forpartinpath.parts):to=('docs'/path)print(path)to.parent.mkdir(exist_ok=True)MarkdownExporter(preprocessors=[ReplaceLinks()]).from_filename(path)[0]to.with_suffix('.md').write_text(("---\n"*2iflen(path.parts)>1else"")+MarkdownExporter(preprocess=[ReplaceLinks()]).from_filename(path)[0])[NbConvertApp] Converting notebook readme.ipynb to markdown
[NbConvertApp] Writing 5882 bytes to readme.md
readme.ipynb
nostalgiaforever/importing.ipynb
nostalgiaforever/plugin.ipynb
nostalgiaforever/reuse.ipynb
nostalgiaforever/testing.ipynb
nostalgiaforever/util.ipynb
test/test_nostalgia.ipynbWatcher withwatchdogsource activate p6 && cd ahypothesis/nostalgiaforever/ && watchmedo tricks tricks.ymlRun unit tests.if__name__=='__main__':try:__import__('unittest').main('test',argv='--verbose'.split())exceptSystemExit:....
----------------------------------------------------------------------
Ran 1 test in 0.001s

OK# Summary [clear all output then "Run All" -- or it didn't happen]Summary [clear all output then "Run All" -- or it didn't happen]if __name__ == '__main__':
    !source activate p6 && ipython --profile pidgin -m nostalgiaforever.importing
    !source activate p6 && ipython --profile pidgin -m nostalgiaforever.testing
    !source activate p6 && ipython --profile pidgin -m nostalgiaforever.reuse