Skip to content
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

Merged

Conversation

MarcoGorelli
Copy link
Contributor

people understand concepts better by example than through accurate explanations

The mixture examples aren't the most straightforward, so here's a simple Gaussian mixture example:

image

While I'm here, am also fixing up the check_toc script to use ast.literval_eval instead of json.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

@@ -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
Copy link
Contributor Author

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)

Comment on lines -8 to +10
import json
from pathlib import Path
import argparse
import ast
Copy link
Contributor Author

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
Copy link

codecov bot commented Dec 4, 2020

Codecov Report

Merging #4294 (ed1dfe6) into master (198d13e) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4294   +/-   ##
=======================================
  Coverage   87.65%   87.65%           
=======================================
  Files          88       88           
  Lines       14341    14341           
=======================================
  Hits        12570    12570           
  Misses       1771     1771           
Impacted Files Coverage Δ
pymc3/distributions/mixture.py 88.31% <ø> (ø)


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("{") :]),
Copy link
Member

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?

Copy link
Contributor Author

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

@twiecki
Copy link
Member

twiecki commented Dec 4, 2020

This is great - thanks!

@michaelosthege michaelosthege merged commit df3ae60 into pymc-devs:master Dec 5, 2020
@MarcoGorelli MarcoGorelli deleted the normal-mixture-example branch December 5, 2020 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants