-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add Normal mixture example, fixup check_toc script #4294
Add Normal mixture example, fixup check_toc script #4294
Conversation
@@ -41,7 +41,6 @@ repos: | |||
entry: python scripts/check_toc_is_complete.py | |||
language: python | |||
name: Check all notebooks appear in table of contents | |||
pass_filenames: false |
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.
My bad here, I erroneously added this in #4262 😳 This script does take file names though (via argparse
)
import json | ||
from pathlib import Path | ||
import argparse | ||
import ast |
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.
these aren't sorted, but their order will be sorted out with #4239 (which needs to have upstream/master merged anyway)
Codecov Report
@@ Coverage Diff @@
## master #4294 +/- ##
=======================================
Coverage 87.65% 87.65%
=======================================
Files 88 88
Lines 14341 14341
=======================================
Hits 12570 12570
Misses 1771 1771
|
|
||
if __name__ == "__main__": | ||
toc_examples = (Path("docs") / "source/notebooks/table_of_contents_examples.js").read_text() | ||
toc_tutorials = (Path("docs") / "source/notebooks/table_of_contents_tutorials.js").read_text() | ||
toc_keys = { | ||
**json.loads(toc_examples[toc_examples.find("{") :]), |
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.
what was wrong with th eold way?
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.
if you included a trailing comma then you'd get a mysterious
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 69 column 1 (char 3689)
, while ast.literal_eval
can handle trailing commas
This is great - thanks! |
The mixture examples aren't the most straightforward, so here's a simple Gaussian mixture example:
While I'm here, am also fixing up the check_toc script to use
ast.literval_eval
instead ofjson.loads
, as the docs build fine with trailing commas in the js dicts and this way we won't get mysterious errors like this one @twiecki got when adding a trailing comma