Skip to content

Commit

Permalink
⏪ Make notebook colab startable again (#6)
Browse files Browse the repository at this point in the history
* 🐛 start tutorial on colab via launch button in docs
revert changes from previous commit

* 📝 reference and second requirements option
  • Loading branch information
enryH authored Oct 31, 2024
1 parent b24e810 commit 8ac3af4
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 3 deletions.
6 changes: 4 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
from importlib import metadata


# -- Project information -----------------------------------------------------

project = "mockup"
Expand Down Expand Up @@ -57,7 +56,10 @@
nb_merge_streams = True

# https://myst-nb.readthedocs.io/en/latest/authoring/custom-formats.html#write-custom-formats
nb_custom_formats = {".py": ["jupytext.reads", {"fmt": "py:percent"}]}
# ! if you use it, then you cannot directly execute the notebook in the browser in colab
# (the file needs to be fetched from the repository)
# just keep both syncing it using papermill
# nb_custom_formats = {".py": ["jupytext.reads", {"fmt": "py:percent"}]}

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
2 changes: 2 additions & 0 deletions docs/tutorial/.jupytext
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# all notebooks in this directory are in the percent format
formats = "ipynb,py:percent"
78 changes: 78 additions & 0 deletions docs/tutorial/tutorial.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "62cb84c2",
"metadata": {},
"source": [
"# Mockup tutorial"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "825cc996",
"metadata": {},
"outputs": [],
"source": [
"from mockup import mockup"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d3ac73ba",
"metadata": {},
"outputs": [],
"source": [
"mockup.add_one(-11)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f3a3d02a",
"metadata": {},
"outputs": [],
"source": [
"list(mockup.flatten_ints([[9, 11], [12], [4, 5]]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9cf7157d",
"metadata": {},
"outputs": [],
"source": [
"c2 = mockup.Circle.from_circumference(100)\n",
"round(c2.radius, 3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4ae5341c",
"metadata": {},
"outputs": [],
"source": [
"c2 # repr"
]
},
{
"cell_type": "markdown",
"id": "1bc4ca39",
"metadata": {},
"source": []
}
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all",
"main_language": "python",
"notebook_metadata_filter": "-all"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ref: https://setuptools.pypa.io/en/stable/userguide/pyproject_config.html
[project]
authors = [
{ name = "Jakob Nybo Nissen", email = "[email protected]" },
Expand All @@ -17,8 +18,13 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
# # add dependencies here:
# # add dependencies here: (use one of the two)
# dependencies = ["numpy", "pandas", "scipy", "matplotlib", "seaborn"]
# use requirements.txt instead of pyproject.toml for dependencies
# https://stackoverflow.com/a/73600610/9684872
# [tool.setuptools.dynamic]
# dependencies = {file = ["requirements.txt"]}


[project.urls]
"Bug Tracker" = "https://github.com/RasmussenLab/python_package/issues"
Expand Down

0 comments on commit 8ac3af4

Please sign in to comment.