Skip to content

Add warning if observed in DensityDist is dict #6292

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

Merged
merged 4 commits into from
Nov 15, 2022

Conversation

symeneses
Copy link
Contributor

What is this PR about?
It adds a warning if the observed parameter is a dictionary.

Checklist

Major / Breaking Changes

  • ...

Bugfixes / New features

Docs / Maintenance

  • ...

@codecov
Copy link

codecov bot commented Nov 12, 2022

Codecov Report

Merging #6292 (e933fea) into main (5d7283e) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6292      +/-   ##
==========================================
+ Coverage   94.12%   94.17%   +0.05%     
==========================================
  Files         111      111              
  Lines       23861    23921      +60     
==========================================
+ Hits        22458    22528      +70     
+ Misses       1403     1393      -10     
Impacted Files Coverage Δ
pymc/distributions/distribution.py 95.06% <100.00%> (+0.04%) ⬆️
pymc/tests/distributions/test_distribution.py 98.21% <100.00%> (+0.04%) ⬆️
pymc/step_methods/hmc/quadpotential.py 80.62% <0.00%> (-0.07%) ⬇️
pymc/distributions/discrete.py 99.22% <0.00%> (ø)
pymc/tests/sampling/test_jax.py 100.00% <0.00%> (ø)
pymc/distributions/continuous.py 97.50% <0.00%> (ø)
pymc/variational/opvi.py 87.08% <0.00%> (+0.02%) ⬆️
pymc/step_methods/hmc/nuts.py 97.31% <0.00%> (+0.05%) ⬆️
pymc/sampling/jax.py 97.34% <0.00%> (+0.14%) ⬆️
pymc/variational/callbacks.py 96.22% <0.00%> (+0.22%) ⬆️
... and 7 more

@fonnesbeck
Copy link
Member

LGTM. Thanks for contributing!

Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

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

just some code style simplifications/FYI

looks good!

Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

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

This is a great start but misses the most important point of the original issue.

DensityDist is defined differently than how it was in V3 where a dictionary with the other parameters besides data could be used. The error message should address this change in API more than what types of observed data are allowed (that's not what users find confusing).

symeneses and others added 2 commits November 12, 2022 12:46
Co-authored-by: Michael Osthege <[email protected]>
Co-authored-by: Michael Osthege <[email protected]>
@symeneses
Copy link
Contributor Author

Based on this item in the Release notes:

pm.DensityDist now accepts distribution parameters as positional arguments. Passing them as a dictionary in the observed keyword argument is no longer supported and will raise an error (see 5026).

I am suggesting this new error message:

Since v4.0.0 the observed parameter should be of type pd.Series, np.array, or pm.Data.
Previous versions allowed passing distribution parameters as a dictionary in observed, in the current version these parameters are positional arguments.

Let me know if this message can be further improved.

@ricardoV94
Copy link
Member

@symeneses that sounds good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants