-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Use revised Pareto k threshold #2349
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
"""Pareto tail indices plot.""" | ||
|
||
import logging | ||
import warnings | ||
|
||
import numpy as np | ||
from xarray import DataArray | ||
|
@@ -40,10 +41,8 @@ def plot_khat( | |
|
||
Parameters | ||
---------- | ||
khats : ELPDData or array-like | ||
The input Pareto tail indices to be plotted. It can be an ``ELPDData`` object containing | ||
Pareto shapes or an array. In this second case, all the values in the array are interpreted | ||
as Pareto tail indices. | ||
khats : ELPDData | ||
The input Pareto tail indices to be plotted. | ||
color : str or array_like, default "C0" | ||
Colors of the scatter plot, if color is a str all dots will have the same color, | ||
if it is the size of the observations, each dot will have the specified color, | ||
|
@@ -165,15 +164,29 @@ def plot_khat( | |
color = "C0" | ||
|
||
if isinstance(khats, np.ndarray): | ||
warnings.warn( | ||
"support for arrays will be deprecated, please use ELPDData." | ||
"The reason for this, is that we need to know the numbers of draws" | ||
"sampled from the posterior", | ||
FutureWarning, | ||
) | ||
khats = khats.flatten() | ||
xlabels = False | ||
legend = False | ||
dims = [] | ||
good_k = None | ||
else: | ||
if isinstance(khats, ELPDData): | ||
good_k = khats.good_k | ||
khats = khats.pareto_k | ||
if not isinstance(khats, DataArray): | ||
raise ValueError("Incorrect khat data input. Check the documentation") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The valueerror is a different if altogether, not the else branch of the one above. It is reached if the input isn't one of numpy array, dataarray or elpddata, or if the elpddata for some reason doesn't store the khat data as a dataarray |
||
good_k = None | ||
warnings.warn( | ||
"support for DataArrays will be deprecated, please use ELPDData." | ||
"The reason for this, is that we need to know the numbers of draws" | ||
"sampled from the posterior", | ||
FutureWarning, | ||
) | ||
|
||
khats = get_coords(khats, coords) | ||
dims = khats.dims | ||
|
@@ -192,6 +205,7 @@ def plot_khat( | |
figsize=figsize, | ||
xdata=xdata, | ||
khats=khats, | ||
good_k=good_k, | ||
kwargs=kwargs, | ||
threshold=threshold, | ||
coord_labels=coord_labels, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should be something like this instead. Right now, dataarrays are also valid input as they are array-like, but we have more info than we do for numpy arrays, so they are treated more similarly to elpddata input. I think this is a reason for some of the test failures.
Note: also rebase on main to avoid unrelated failures that have been fixed already.