Skip to main content

BinderBuild StatusPyPI versionPyPI - Python VersionPyPI - Format

pip install nostalgiaforever

A Notebook is a Hypothesis

If 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.


@docfast presenting behalf of deathbeds

See deathbeds present @ JupyterCon

    from nostalgiaforever import importing, testing, reuse

Key Technologies

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.

Order

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

Before the talk

  • Restart your machine

  • Start the watcher

      source activate p6 && cd ahypothesis/nostalgiaforever && watchmedo tricks tricks.yml
    
  • Prepare the Fira Code fonts https://github.com/deathbeds/jupyterlab-fonts.

  • Hey art nerd! Turn the color on!

  • Cut the release.

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__':
        from IPython import get_ipython
        !jupyter nbconvert --to markdown readme.ipynb
        for path in Path('.').rglob('*.ipynb'):

            if all(not part.startswith('.') for part in path.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"*2 if len(path.parts) > 1 else "") + 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.ipynb

Watcher with watchdog

source activate p6 && cd ahypothesis/nostalgiaforever/ && watchmedo tricks tricks.yml

Run unit tests.

    if __name__ == '__main__':
        try:
            __import__('unittest').main('test', argv='--verbose'.split())
        except SystemExit: ...
.
----------------------------------------------------------------------
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

Metadata

Release files for nostalgiaforever 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nostalgiaforever 0.0.3
File Size Uploaded
nostalgiaforever-0.0.3.tar.gz 26.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nostalgiaforever 0.0.3
File Interpreter ABI Platform
nostalgiaforever-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 55.8 kB

Release files / nostalgiaforever-0.0.3.tar.gz

Download URL nostalgiaforever-0.0.3.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0d95841c60f4fe9c31318ae9a0e5f613bc655eb015199ade6385be9f0590d401
BLAKE2b-256 checksum
How to use checksums
18ecc6caa9eeddcbd3e2c847d49f2c35b9c787272f9c7318299ccecef8a9a95b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / nostalgiaforever-0.0.3-py3-none-any.whl

Download URL nostalgiaforever-0.0.3-py3-none-any.whl
Size 29.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b47b61169bd65a34c1d30a749f2407692b8a642b3cab199c9c47cc4bdfdd3f2f
BLAKE2b-256 checksum
How to use checksums
a9ed043ce9d9189a6606be0c5747739b3faea93ff475901b10d1bac6cb16308c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page