-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Thomas Hoffmann <[email protected]> Co-authored-by: Dimitri Kartsaklis <[email protected]> Co-authored-by: Charles London <[email protected]>
- Loading branch information
1 parent
54b5bfa
commit 7027843
Showing
24 changed files
with
533 additions
and
316 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,35 @@ | ||
from pathlib import Path | ||
from itertools import chain | ||
import nbformat as nbf | ||
|
||
|
||
print("Cleaning notebooks...") | ||
|
||
nbs_path = Path("examples") | ||
tut_path = Path("tutorials") | ||
useful_metadata = ["nbsphinx", "raw_mimetype"] | ||
|
||
for file in chain(nbs_path.iterdir(), tut_path.iterdir()): | ||
if not (file.is_file() and file.suffix == ".ipynb"): | ||
continue | ||
|
||
ntbk = nbf.read(file, nbf.NO_CONVERT) | ||
|
||
for cell in ntbk.cells: | ||
# Delete cell ID if it's there | ||
cell.pop("id", None) | ||
|
||
# Keep only useful metadata | ||
new_metadata = {x: cell.metadata[x] | ||
for x in useful_metadata | ||
if x in cell.metadata} | ||
cell.metadata = new_metadata | ||
|
||
ntbk.metadata = {"language_info": {"name": "python"}} | ||
|
||
# We need the version of nbformat to be x.4, otherwise cells IDs | ||
# are regenerated automatically | ||
ntbk.nbformat = 4 | ||
ntbk.nbformat_minor = 4 | ||
|
||
nbf.write(ntbk, file, version=nbf.NO_CONVERT) |
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 |
---|---|---|
|
@@ -64,5 +64,5 @@ | |
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
"nbformat_minor": 4 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -137,5 +137,5 @@ | |
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
"nbformat_minor": 4 | ||
} |
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 |
---|---|---|
|
@@ -816,5 +816,5 @@ | |
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
"nbformat_minor": 4 | ||
} |
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 |
---|---|---|
|
@@ -154,5 +154,5 @@ | |
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
"nbformat_minor": 4 | ||
} |
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 |
---|---|---|
|
@@ -101,5 +101,5 @@ | |
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
"nbformat_minor": 4 | ||
} |
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
Oops, something went wrong.