From 493a9388d0a46cc092f0bc5ca89c46c136287c31 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 4 Dec 2020 18:12:08 +0000 Subject: [PATCH 1/2] add gaussian mixture example --- pymc3/distributions/mixture.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/pymc3/distributions/mixture.py b/pymc3/distributions/mixture.py index 7f88acbb7e..dcfd823fa1 100644 --- a/pymc3/distributions/mixture.py +++ b/pymc3/distributions/mixture.py @@ -602,7 +602,29 @@ class NormalMixture(Mixture): of the mixture distribution, with one axis being the number of components. - Note: You only have to pass in sigma or tau, but not both. + Notes + ----- + You only have to pass in sigma or tau, but not both. + + Examples + -------- + .. code-block:: python + + n_components = 3 + + with pm.Model() as gauss_mix: + μ = pm.Normal( + "μ", + data.mean(), + 10, + shape=n_components, + transform=pm.transforms.ordered, + testval=[1, 2, 3], + ) + σ = pm.HalfNormal("σ", 10, shape=n_components) + weights = pm.Dirichlet("w", np.ones(n_components)) + + pm.NormalMixture("y", w=weights, mu=μ, sigma=σ, observed=data) """ def __init__(self, w, mu, sigma=None, tau=None, sd=None, comp_shape=(), *args, **kwargs): From ed1dfe6926ab1c6100432b97a471b3919b349e79 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 4 Dec 2020 18:17:58 +0000 Subject: [PATCH 2/2] update check-toc script --- .pre-commit-config.yaml | 1 - scripts/check_toc_is_complete.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e3b09244a..d41f6898e3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 types: [jupyter] - id: check-no-tests-are-ignored entry: python scripts/check_all_tests_are_covered.py diff --git a/scripts/check_toc_is_complete.py b/scripts/check_toc_is_complete.py index 7598d08e05..ea82ab1a3a 100644 --- a/scripts/check_toc_is_complete.py +++ b/scripts/check_toc_is_complete.py @@ -5,16 +5,16 @@ You can run it manually with `pre-commit run check-toc --all`. """ -import json from pathlib import Path import argparse +import ast 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("{") :]), - **json.loads(toc_tutorials[toc_tutorials.find("{") :]), + **ast.literal_eval(toc_examples[toc_examples.find("{") :]), + **ast.literal_eval(toc_tutorials[toc_tutorials.find("{") :]), }.keys() parser = argparse.ArgumentParser() parser.add_argument("filenames", nargs="*")