-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into separate_nufft_op
- Loading branch information
Showing
32 changed files
with
689 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Add a colab badge and pip install to notebooks.""" | ||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
extend = "../pyproject.toml" | ||
|
||
exclude = ["notebooks/*.ipynb"] | ||
lint.extend-ignore = [ | ||
"D100", #undocumented-public-module | ||
"T20", #print | ||
"E402", #module-import-not-at-top-of-file | ||
"S101", #assert | ||
"SIM115", #context manager for opening files | ||
"ERA001", #commented out code | ||
] |
Oops, something went wrong.