-
Notifications
You must be signed in to change notification settings - Fork 2
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
Function To Cast InferenceData Into tidy_draws
Format
#36
base: main
Are you sure you want to change the base?
Function To Cast InferenceData Into tidy_draws
Format
#36
Conversation
…nferencedata-into-tidy_draws-format
…nferencedata-into-tidy_draws-format
…nferencedata-into-tidy_draws-format
…nferencedata-into-tidy_draws-format
…nferencedata-into-tidy_draws-format
…nferencedata-into-tidy_draws-format
…nferencedata-into-tidy_draws-format
Requested review from @dylanhmorris. Once a review is received, the author will request another review from Damon. Beyond the |
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 @AFg6K7h4fhy2. Getting close but needs a few tweaks.
((pl.col(".chain") - 1) * pl.col("draws_per_chain")) | ||
+ pl.col(".iteration") | ||
).alias(".draw") | ||
) |
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.
Need to drop "draws_per_chain"
, but also it's not a given that all chains will have the same number of draws. Instead, more robust do compute this as .iteration + <n_draws_in_all_previous_chains>
. Many ways to do that in polars.
|
||
@pytest.fixture | ||
def mock_inference_data(): | ||
np.random.seed(42) |
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.
Running np.random.seed
changes global state. Better practice to do something like this https://builtin.com/data-science/numpy-random-seed
posterior_predictive = xr.Dataset( | ||
{ | ||
"observed_hospital_admissions": ("chain", np.random.randn(2, 100)), | ||
}, | ||
coords={"chain": [0, 1]}, | ||
) |
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.
Why not run the test on the provided inference_data_1.nc
? Or are you planning to remove it?
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.
I am on the fence about removing it. Seems good to have a canonical pyrenew-hew
.nc
file on hand esp. given that forecasttools-py
does / will even more so interface abundantly with pyrenew
models. On the other hand, having adequate and general idata
/ xarray
representations seems good for testing too. I do not know if the latter must exist at the cost of the former. I lean towards having both, with the .nc
file perhaps being used in notebooks and the "fake" idata
s being used for testing.
col in df.columns | ||
for col in [".chain", ".draw", ".iteration", "variable", "value"] | ||
) | ||
|
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.
Would be good to check that individual values are as expected, not just that the draws are unique and one for each row.
…nferencedata-into-tidy_draws-format
Co-authored-by: Dylan H. Morris <[email protected]>
Co-authored-by: Dylan H. Morris <[email protected]>
…nferencedata-into-tidy_draws-format
@@ -42,6 +43,8 @@ patsy = "^0.5.6" | |||
nbformat = "^5.10.4" | |||
nbclient = "^0.10.0" | |||
jupyter = "^1.1.1" | |||
pandas = "^2.2.3" | |||
metaflow = "^2.13.9" |
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.
Do you want this?
…nferencedata-into-tidy_draws-format
For the scope of this PR, please refer to issue #18 .