Skip to main content

Import .ipynb files as modules in the system path.

Project description


pip install nostalgiaforever

A Notebook is a Hypothesis

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.

Key Takeaways

  • Notebooks can be used for testing and software.
  • Best practices for composing testable computational essays.
  • Existing testing frameworks can be used with notebooks.
    from IPython import get_ipython


  1. readme.ipynb
  2. importing.ipynb
  3. testing.ipynb
  4. reuse.ipynb

Before the talk

Build the docs.

Github Pages

    from nbconvert.exporters.markdown import MarkdownExporter
    from nbconvert.preprocessors import Preprocessor
    class ReplaceLinks(Preprocessor):
        def preprocess_cell(self, cell, resources=None, index=0):
            if cell['cell_type'] == 'markdown':
                if isinstance(cell['source'], list): 
                    cell['source'] = ''.join(cell['source'])
                cell['source'] = cell['source'].replace('.ipynb', '')
            return cell, resources
    from pathlib import Path
    if __name__ == '__main__':
        !jupyter nbconvert --to markdown readme.ipynb
        for path in Path('.').rglob('*.ipynb'):
            if all(not part.startswith('.') for part in
                to = ('docs' / path)
                    ("---\n"*2 if len( > 1 else "") + MarkdownExporter(preprocess=[ReplaceLinks()]).from_filename(path)[0])
[NbConvertApp] Converting notebook readme.ipynb to markdown
[NbConvertApp] Writing 3957 bytes to

Run unit tests.

    if __name__ == '__main__':
            __import__('unittest').main('test', argv='--verbose'.split())
        except SystemExit: ...
Ran 1 test in 0.002s


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

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nostalgiaforever-0.0.2.tar.gz (255.3 kB view hashes)

Uploaded source

Built Distribution

nostalgiaforever-0.0.2-py3-none-any.whl (6.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page