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

Make quartile_int a class #570

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/examples/param_space_1d_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@
"id": "e963626e-24fb-4a62-8825-cdfeb038e43e",
"metadata": {},
"source": [
"You can use `pz.quartile_int` to specify a list of distribution names to be used in the elicitation."
"You can use `pz.QuartileInt` to specify a list of distribution names to be used in the elicitation."
]
},
{
Expand Down Expand Up @@ -835,7 +835,7 @@
"\n",
"We can pass values for the quartiles, and the function will return the closest 1D distribution to that input. We can select one or more distributions from a menu by clicking or by passing a list of strings when calling the function. Additionally, we can optionally parameterize distributions. This is useful, for example, to set 'nu' for `pz.StudentT` or boundaries for distributions such as `pz.TruncatedNormal` and `pz.BetaScaled`.\n",
"\n",
"Similar to `pz.roulette()`, `the pz.quartile_int()` function utilizes matplotlib interactively. For this to function properly, it is necessary to invoke the magic command `%matplotlib widget` and ensure that ipywidgets is installed, as it is a requirement for PreliZ."
"Similar to `pz.Roulette()`, `the pz.QuartileInt()` function utilizes matplotlib interactively. For this to function properly, it is necessary to invoke the magic command `%matplotlib widget` and ensure that ipywidgets is installed, as it is a requirement for PreliZ."
]
},
{
Expand Down Expand Up @@ -888,7 +888,7 @@
],
"source": [
"%matplotlib widget\n",
"pz.quartile_int(1, 2, 3, [\"StudentT\", \"TruncatedNormal\", \"BetaScaled\"], None)"
"pz.QuartileInt(1, 2, 3, [\"StudentT\", \"TruncatedNormal\", \"BetaScaled\"], None)"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions preliz/internal/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def fit_to_sample(selected_distributions, sample, x_min, x_max):

def fit_to_quartile(dist_names, q1, q2, q3, extra_pros):
error = np.inf
fitted_dist = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case we are not able to fit a thing (for instance a domain error)


for distribution in get_distributions(dist_names):
if distribution.__class__.__name__ in extra_pros:
Expand Down
4 changes: 2 additions & 2 deletions preliz/tests/quartile_int.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"import ipytest\n",
"ipytest.autoconfig()\n",
"\n",
"from preliz import quartile_int"
"from preliz import QuartileInt"
]
},
{
Expand All @@ -30,7 +30,7 @@
" (-1, 2, 3, None, (10, 8)), # Test custom figsize\n",
"])\n",
"def test_quartile_int(q1, q2, q3, dist_names, figsize):\n",
" quartile_int(q1, q2, q3, dist_names, figsize)"
" QuartileInt(q1, q2, q3, dist_names, figsize)"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions preliz/unidimensional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .maxent import maxent
from .mle import mle
from .quartile import quartile
from .quartile_int import quartile_int
from .quartile_int import QuartileInt
from .roulette import Roulette

__all__ = [
Expand All @@ -15,5 +15,5 @@
"mle",
"Roulette",
"quartile",
"quartile_int",
"QuartileInt",
]
Loading
Loading