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 dictionary option for stat_funcs in summary #583

Merged
merged 1 commit into from
Feb 12, 2019

Conversation

ahartikainen
Copy link
Contributor

This PR enables one to use a dictionary in stat_funcs. This way the user can name the functions and use lambda with the correct name.

stat_funcs=[np.std]
stat_funcs={"std" : np.std, "std_ddof1" : lambda x: np.std(x, ddof=1)}

stat_funcs : None or list
A list of functions used to calculate statistics. By default, the mean, standard deviation,
simulation standard error, and highest posterior density intervals are included.
stat_funcs : dict
Copy link
Member

Choose a reason for hiding this comment

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

This can be a dict, or an iter right? It looks like if you pass a list or tuple you'll still hit this line

https://github.com/arviz-devs/arviz/pull/583/files#diff-f44bb9f0195d3e0d831b3e10ee0ae059R710

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, dict or sequence

def test_summary_stat_func(centered_eight):
assert summary(centered_eight, stat_funcs=[np.var]) is not None
@pytest.mark.parametrize(
"stat_funcs", [[np.var], {"var": np.var, "var2": lambda x: np.var(x) ** 2}]
Copy link
Member

Choose a reason for hiding this comment

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

In regards to the comment above this test seems to pass a list and still functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I wanted to keep original structure

@aloctavodia aloctavodia merged commit 2668799 into master Feb 12, 2019
@aloctavodia aloctavodia deleted the feature/dict_stat_funcs branch February 12, 2019 17:05
@ColCarroll ColCarroll mentioned this pull request Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants