Skip to content

Commit

Permalink
use preliz style (#509)
Browse files Browse the repository at this point in the history
* use preliz style

* small fix
  • Loading branch information
aloctavodia authored Aug 5, 2024
1 parent ce64174 commit 4f376fc
Show file tree
Hide file tree
Showing 121 changed files with 329 additions and 234 deletions.
6 changes: 3 additions & 3 deletions docs/examples/gallery/asymmetric_laplace.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ mystnb:
alt: AsymmetricLaplace Distribution PDF
---
import arviz as az
from preliz import AsymmetricLaplace
az.style.use('arviz-doc')
from preliz import AsymmetricLaplace, style
style.use('preliz-doc')
kappas = [1., 2., .5]
mus = [0., 0., 3.]
bs = [1., 1., 1.]
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/gallery/beta.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ mystnb:
---
import matplotlib.pyplot as plt
import arviz as az
from preliz import Beta
az.style.use('arviz-doc')
from preliz import Beta, style
style.use('preliz-doc')
alphas = [.5, 5., 2.]
betas = [.5, 5., 5.]
for alpha, beta in zip(alphas, betas):
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/beta_scaled.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ mystnb:
alt: Beta Scaled Distribution PDF
---
import arviz as az
from preliz import BetaScaled
az.style.use('arviz-doc')
from preliz import BetaScaled, style
style.use('preliz-doc')
alphas = [2, 2]
betas = [2, 5]
lowers = [-0.5, -1]
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/cauchy.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ tags: [remove-input]
mystnb: image
---
import matplotlib.pyplot as plt
import arviz as az
from preliz import Cauchy
az.style.use('arviz-doc')
from preliz import Cauchy, style
style.use('preliz-doc')
alphas = [0., 0., -2.]
betas = [1, 0.5, 1]
for alpha, beta in zip(alphas, betas):
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/censored.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ mystnb:
alt: Censored Distribution PDF
---
import arviz as az
from preliz import Normal, Censored
az.style.use('arviz-doc')
from preliz import Normal, Censored, style
style.use('preliz-doc')
Censored(Normal(0, 1), -1, 1).plot_pdf(support=(-4, 4))
Normal(0, 1).plot_pdf(alpha=0.5);
```
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/chisquared.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ mystnb:
---
import numpy as np
import arviz as az
from preliz import ChiSquared
az.style.use('arviz-doc')
from preliz import ChiSquared, style
style.use('preliz-doc')
nus = [1, 3, 9]
for nu in nus:
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/exponential.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ mystnb:
---
import matplotlib.pyplot as plt
import arviz as az
from preliz import Exponential
az.style.use('arviz-doc')
from preliz import Exponential, style
style.use('preliz-doc')
lambdas = [0.5, 1., 2.]
for lam in lambdas:
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/gamma.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ mystnb:
alt: Gamma Distribution PDF
---
import arviz as az
from preliz import Gamma
az.style.use('arviz-doc')
from preliz import Gamma, style
style.use('preliz-doc')
alphas = [1, 3, 7.5]
betas = [0.5, 1., 1.]
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/gallery/log_normal.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ mystnb:
---
import matplotlib.pyplot as plt
import arviz as az
from preliz import LogNormal
az.style.use('arviz-doc')
from preliz import style, LogNormal
style.use('preliz-doc')
mus = [0., 0., 0.]
sigmas = [0.25, 0.5, 1.]
for mu, sigma in zip(mus, sigmas):
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/logistic.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ mystnb:
---
import matplotlib.pyplot as plt
import arviz as az
from preliz import Logistic
az.style.use('arviz-doc')
from preliz import Logistic, style
style.use('preliz-doc')
mus = [0., 0., -2.]
ss = [1., 2., .4]
for mu, s in zip(mus, ss):
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/normal.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ mystnb:
---
import matplotlib.pyplot as plt
import arviz as az
from preliz import Normal
az.style.use('arviz-doc')
from preliz import Normal, style
style.use('preliz-doc')
mus = [0., 0., -2.]
sigmas = [1, 0.5, 1]
for mu, sigma in zip(mus, sigmas):
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/poisson.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ mystnb:
alt: Poisson Distribution PDF
---
import arviz as az
from preliz import Poisson
az.style.use('arviz-doc')
from preliz import Poisson, style
style.use('preliz-doc')
for mu in [0.5, 3, 8]:
Poisson(mu).plot_pdf();
```
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/students_t.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ mystnb:
---
import matplotlib.pyplot as plt
import arviz as az
from preliz import StudentT
az.style.use('arviz-doc')
from preliz import StudentT, style
style.use('preliz-doc')
nus = [2., 5., 5.]
mus = [0., 0., -4.]
sigmas = [1., 1., 2.]
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/truncated.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ mystnb:
alt: Truncated Distribution PDF
---
import arviz as az
from preliz import Gamma, Truncated
az.style.use('arviz-doc')
from preliz import Gamma, Truncated, style
style.use('preliz-doc')
Truncated(Gamma(mu=2, sigma=1), 1, 4.5).plot_pdf()
Gamma(mu=2, sigma=1).plot_pdf();
```
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/gallery/uniform.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ mystnb:
---
import matplotlib.pyplot as plt
import arviz as az
from preliz import Uniform
az.style.use('arviz-doc')
from preliz import Uniform, style
style.use('preliz-doc')
ls = [1, -2]
us = [6, 2]
for l, u in zip(ls, us):
Expand Down
Binary file modified docs/examples/img/AsymmetricLaplace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Bernoulli.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Beta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/BetaBinomial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/BetaScaled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Binomial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Categorical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Cauchy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Censored.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/ChiSquared.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/DiscreteUniform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/DiscreteWeibull.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/ExGaussian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Exponential.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Gamma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Geometric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Gumbel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/HalfCauchy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/HalfNormal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/HalfStudentT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Hurdle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/HyperGeometric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/InverseGamma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Kumaraswamy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Laplace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/LogLogistic.png
Binary file modified docs/examples/img/LogNormal.png
Binary file modified docs/examples/img/Logistic.png
Binary file modified docs/examples/img/LogitNormal.png
Binary file modified docs/examples/img/Moyal.png
Binary file modified docs/examples/img/NegativeBinomial.png
Binary file modified docs/examples/img/Normal.png
Binary file modified docs/examples/img/Pareto.png
Binary file modified docs/examples/img/Poisson.png
Binary file modified docs/examples/img/Rice.png
Binary file modified docs/examples/img/SkewNormal.png
Binary file modified docs/examples/img/SkewStudentT.png
Binary file modified docs/examples/img/StudentT.png
Binary file modified docs/examples/img/Triangular.png
Binary file modified docs/examples/img/Truncated.png
Binary file modified docs/examples/img/TruncatedNormal.png
Binary file modified docs/examples/img/Uniform.png
Binary file modified docs/examples/img/VonMises.png
Binary file modified docs/examples/img/Wald.png
Binary file modified docs/examples/img/Weibull.png
Binary file modified docs/examples/img/ZeroInflatedBinomial.png
Binary file modified docs/examples/img/ZeroInflatedNegativeBinomial.png
Binary file modified docs/examples/img/ZeroInflatedPoisson.png
8 changes: 4 additions & 4 deletions docs/examples/observed_space_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ Predictive Elicitation

.. code-block:: python
import arviz as az
import preliz as pz
import numpy as np
import pandas as pd
.. code-block:: python
az.style.library["arviz-doc"]["figure.dpi"] = 100
az.style.library["arviz-doc"]["figure.figsize"] = (10, 4)
az.style.use("arviz-doc")
pz.style.library["preliz-doc"]["figure.dpi"] = 100
pz.style.library["preliz-doc"]["figure.figsize"] = (10, 4)
pz.style.use("preliz-doc")
Predictive elicitation refers to the elicitation of priors by making evaluations on the observed space, instead of the parameters space. The advantage of the former is that generally it is easier to think about observations than parameters, specially for domain experts. If you are a forest engineer, you may be more familiar with the expected rate of wildfires in an area than with the ``rho`` parameter of a model.

Expand Down
50 changes: 25 additions & 25 deletions docs/examples/param_space_1d_examples.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions docs/get_cover_gallery.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# pylint: disable=invalid-name
import matplotlib.pyplot as plt
import arviz as az

import numpy as np
from preliz import Gamma
from preliz import distributions
from preliz import style
from preliz.internal.distribution_helper import init_vals


az.style.use("arviz-doc")
style.use("preliz-doc")
rng = np.random.default_rng(247)

init_vals["Hurdle"] = None
Expand Down
6 changes: 3 additions & 3 deletions docs/get_cover_gallery_multivariate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# pylint: disable=invalid-name
import matplotlib.pyplot as plt
import arviz as az

import numpy as np
from preliz import Dirichlet, MvNormal
from preliz import style, Dirichlet, MvNormal

az.style.use("arviz-doc")
style.use("preliz-doc")

w = 1834 / 300
h = 1234 / 300
Expand Down
8 changes: 8 additions & 0 deletions preliz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
Tools to help you pick a prior
"""
import logging
from os import path as os_path

from matplotlib import rcParams
from matplotlib import style

from .distributions import *
from .predictive import *
Expand All @@ -27,3 +29,9 @@
# Allow legend outside plot in maxent to be included when saving a figure
# We may want to make this more explicit by having preliz.rcParams
rcParams["savefig.bbox"] = "tight"


# add PreliZ's styles to matplotlib's styles
_preliz_style_path = os_path.join(os_path.dirname(__file__), "styles")
style.core.USER_LIBRARY_PATHS.append(_preliz_style_path)
style.core.reload_library()
6 changes: 3 additions & 3 deletions preliz/distributions/asymmetric_laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class AsymmetricLaplace(Continuous):
.. plot::
:context: close-figs
import arviz as az
from preliz import AsymmetricLaplace
az.style.use('arviz-doc')
from preliz import AsymmetricLaplace, style
style.use('preliz-doc')
kappas = [1., 2., .5]
mus = [0., 0., 3.]
bs = [1., 1., 1.]
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/bernoulli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class Bernoulli(Discrete):
.. plot::
:context: close-figs
import arviz as az
from preliz import Bernoulli
az.style.use('arviz-doc')
from preliz import Bernoulli, style
style.use('preliz-doc')
for p in [0, 0.5, 0.8]:
Bernoulli(p).plot_pdf()
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class Beta(Continuous):
.. plot::
:context: close-figs
import arviz as az
from preliz import Beta
az.style.use('arviz-doc')
from preliz import Beta, style
style.use('preliz-doc')
alphas = [.5, 5., 2.]
betas = [.5, 5., 5.]
for alpha, beta in zip(alphas, betas):
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/betabinomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class BetaBinomial(Discrete):
.. plot::
:context: close-figs
import arviz as az
from preliz import BetaBinomial
az.style.use('arviz-doc')
from preliz import BetaBinomial, style
style.use('preliz-doc')
alphas = [0.5, 1, 2.3]
betas = [0.5, 1, 2]
n = 10
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/betascaled.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class BetaScaled(Continuous):
.. plot::
:context: close-figs
import arviz as az
from preliz import BetaScaled
az.style.use('arviz-doc')
from preliz import BetaScaled, style
style.use('preliz-doc')
alphas = [2, 2]
betas = [2, 5]
lowers = [-0.5, -1]
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/binomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class Binomial(Discrete):
.. plot::
:context: close-figs
import arviz as az
from preliz import Binomial
az.style.use('arviz-doc')
from preliz import Binomial, style
style.use('preliz-doc')
ns = [5, 10, 10]
ps = [0.5, 0.5, 0.7]
for n, p in zip(ns, ps):
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Categorical(Discrete):
.. plot::
:context: close-figs
import arviz as az
from preliz import Categorical
az.style.use('arviz-doc')
from preliz import Categorical, style
style.use('preliz-doc')
ps = [[0.1, 0.6, 0.3], [0.3, 0.1, 0.1, 0.5]]
for p in ps:
Categorical(p).plot_pdf()
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/cauchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Cauchy(Continuous):
.. plot::
:context: close-figs
import arviz as az
from preliz import Cauchy
az.style.use('arviz-doc')
from preliz import Cauchy, style
style.use('preliz-doc')
alphas = [0., 0., -2.]
betas = [.5, 1., 1.]
for alpha, beta in zip(alphas, betas):
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/censored.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class Censored(DistributionTransformer):
.. plot::
:context: close-figs
import arviz as az
from preliz import Normal, Censored
az.style.use('arviz-doc')
from preliz import Normal, Censored, style
style.use('preliz-doc')
Censored(Normal(0, 1), -1, 1).plot_pdf(support=(-4, 4))
Normal(0, 1).plot_pdf(alpha=0.5)
Expand Down
6 changes: 3 additions & 3 deletions preliz/distributions/chi_squared.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class ChiSquared(Continuous):
.. plot::
:context: close-figs
import arviz as az
from preliz import ChiSquared
az.style.use('arviz-doc')
from preliz import ChiSquared, style
style.use('preliz-doc')
nus = [1., 3., 9.]
for nu in nus:
ax = ChiSquared(nu).plot_pdf(support=(0,20))
Expand Down
Loading

0 comments on commit 4f376fc

Please sign in to comment.