-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve documentation #598
base: main
Are you sure you want to change the base?
Changes from 49 commits
470f1a2
4398a11
f3a6e16
9f500fb
f1e5d1e
9d07935
466ab3c
3420fc6
e395218
e00b6a7
6606672
df51ecf
eab0395
f6f0502
a92877b
47ad68e
31bf097
a72d095
0af3338
a26a559
6a5ef6b
7a3cf18
cfb20b0
7caf514
e51b7c7
2571ae3
48e3125
132637c
d4f7fb2
66a4d4e
7cc6587
93ad440
f94a177
5d21424
8453798
5311951
ba5b484
408022b
09c6b97
7684724
871cdd2
71943e0
433649e
df16dd9
929aa0d
3dbd1d6
54114aa
644cce9
4d497e7
688a55c
457787c
d0baf78
75b7633
2156518
ac37591
2b3faf1
337a514
e6ab0db
b8907ca
17b03ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All changes here are due to basing upon #537 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All changes here are due to basing upon #537 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Add a colab badge and pip install to notebooks.""" | ||
fzimmermann89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import sys | ||
from pathlib import Path | ||
|
||
# the filename is the name of temp file created by jupytext, not an original notebook | ||
file = Path(sys.argv[1]) | ||
# the temp filename for "iteratitive_sense_reconstruction.py" is like "iterative_sense_reconstruction-42_5f4kv.py" | ||
basename = file.stem.rpartition('-')[0] | ||
|
||
badge_svg = 'https://colab.research.google.com/assets/colab-badge.svg' | ||
ipynb_link = f'https://colab.research.google.com/github/PTB-MR/mrpro/blob/main/examples/notebooks/{basename}.ipynb' | ||
badge_markdown = f'[![Open In Colab]({badge_svg})]({ipynb_link})' | ||
badge_pyprocent = f'# %% [markdown]\n# {badge_markdown}\n' | ||
import_python = """# %% tags=["remove-cell"] | ||
import importlib | ||
|
||
if not importlib.util.find_spec('mrpro'): | ||
%pip install mrpro[notebook] | ||
""" | ||
|
||
# the temp files of jupytext have the header which looks like: | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# multiple lines... | ||
# --- | ||
# we need to insert the #markdown cell after the header | ||
# insert the badge_pyprocent string after the second occurrence of '# ---' | ||
split_sequence = '# ---\n' | ||
old = file.read_text() | ||
split_text = old.split(split_sequence) | ||
new = ''.join( | ||
[split_text[0], split_sequence, split_text[1], split_sequence, badge_pyprocent, import_python, *split_text[2:]] | ||
) | ||
file.write_text(new) |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. white line removed. looks a bit cleaner in the docu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All changes here are due to basing upon #537