-
-
Notifications
You must be signed in to change notification settings - Fork 411
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 None for fields not used in beanmachine converter #2154
Conversation
d2604da
to
5ea6a3c
Compare
Codecov Report
@@ Coverage Diff @@
## main #2154 +/- ##
==========================================
+ Coverage 87.73% 89.95% +2.22%
==========================================
Files 119 119
Lines 12394 12398 +4
==========================================
+ Hits 10874 11153 +279
+ Misses 1520 1245 -275
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Can you also add some tests or an issue so we remember we need to add them at some point? |
I'll add them to this issue. It needs to be done.
…On Sat, 5 Nov 2022, 22:56 Oriol Abril-Pla, ***@***.***> wrote:
Can you also add some tests or an issue so we remember we need to add them
at some point?
—
Reply to this email directly, view it on GitHub
<#2154 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACCUNWSF7LAON7CBMVUSTWG3JXZANCNFSM6AAAAAARWNI5SM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
9646758
to
5035989
Compare
cd29fdc
to
d68d9ce
Compare
Added tests |
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.
Thanks! I have added some comments to try and use check_multiple_attrs
if possible so tests are in line with the other libraries. But I am not sure if they'd be equivalent.
I couldn't use `check_multiple_attrs` since it assumes the variables are
strings. I could generalise it, but wasn't sure if that's the best option.
…On Tue, 6 Dec 2022, 12:06 Oriol Abril-Pla, ***@***.***> wrote:
***@***.**** commented on this pull request.
Thanks! I have added some comments to try and use check_multiple_attrs if
possible so tests are in line with the other libraries. But I am not sure
if they'd be equivalent.
------------------------------
In arviz/tests/external_tests/test_data_beanmachine.py
<#2154 (comment)>:
> @@ -0,0 +1,77 @@
+# pylint: disable=no-member, invalid-name, redefined-outer-name
+import numpy as np
+import pytest
+
+from ...data.io_beanmachine import from_beanmachine # pylint: disable=wrong-import-position
+from ..helpers import ( # pylint: disable=unused-import, wrong-import-position
+ chains,
+ check_multiple_attrs,
+ draws,
+ eight_schools_params,
+ importorskip,
+ load_cached_models,
+)
+
+# Skip all tests if pyro or pytorch not installed
⬇️ Suggested change
-# Skip all tests if pyro or pytorch not installed
+# Skip all tests if beanmachine or pytorch not installed
------------------------------
In arviz/tests/external_tests/test_data_beanmachine.py
<#2154 (comment)>:
> + assert mu in inference_data.posterior
+ assert tau in inference_data.posterior
+ assert eta in inference_data.posterior
+ assert obs in inference_data.posterior_predictive
⬇️ Suggested change
- assert mu in inference_data.posterior
- assert tau in inference_data.posterior
- assert eta in inference_data.posterior
- assert obs in inference_data.posterior_predictive
+ test_dict = {
+ "posterior": ["mu", "tau", "eta"],
+ # or
+ # "posterior": [mu, tau, eta], ?
+ "posterior_predictive": ["obs"],
+ # if we also want to assert other groups are missing
+ "~observed_data": [],
+ }
+ fails = check_multiple_attrs(test_dict, inference_data)
+ assert not fails
------------------------------
In arviz/tests/external_tests/test_data_beanmachine.py
<#2154 (comment)>:
> + assert obs in idata.log_likelihood
+ assert obs in idata.observed_data
⬇️ Suggested change
- assert obs in idata.log_likelihood
- assert obs in idata.observed_data
+ test_dict = {
+ "observed_data": ["obs"],
+ "log_likelihood": ["obs"],
+ }
+ fails = check_multiple_attrs(test_dict, idata)
+ assert not fails
------------------------------
In arviz/tests/external_tests/test_data_beanmachine.py
<#2154 (comment)>:
> + assert not model.obs() in inference_data.posterior
+ assert "observed_data" not in inference_data
⬇️ Suggested change
- assert not model.obs() in inference_data.posterior
- assert "observed_data" not in inference_data
+ test_dict = {
+ "posterior": ["~obs"],
+ "~observed_data": [],
+ }
+ fails = check_multiple_attrs(test_dict, inference_data1)
+ assert not fails
—
Reply to this email directly, view it on GitHub
<#2154 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACCUIZ2TKI6OFK6DGCOULWL4M3XANCNFSM6AAAAAARWNI5SM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
let's merge like this then, the goal of check_multiple_attrs is making it easier to write extensive tests but now they are already written and they do what they are supposed to do. Can you add to the changelog and fix the two unresolved comments? Otherwise I'll try to do it later today. |
Co-authored-by: Oriol Abril-Pla <oriol.abril.pla@gmail.com>
Co-authored-by: Oriol Abril-Pla <oriol.abril.pla@gmail.com>
Description
This is a bug fix to handle when observations and posterior_predictive is missing from the MonteCarloSamples object
Checklist
📚 Documentation preview 📚: https://arviz--2154.org.readthedocs.build/en/2154/