Preserve observed_data coordinates in weight_predictions#285
Conversation
Documentation build overview
Show files changed (13 files in total): 📝 13 modified | ➕ 0 added | ➖ 0 deleted
|
|
Hi @aloctavodia , just a gentle follow-up on this PR. This fixes the issue where weight_predictions was dropping the original observed_data coordinates and replaces them with a dummy index. The change preserves the original coordinates (e.g. school in centered_eight) and adds a small regression test to lock in the behavior. All tests pass locally, and the change is isolated to weight_predictions. Whenever you have time, I’d appreciate a review — happy to adjust anything if needed. Thanks! |
OriolAbril
left a comment
There was a problem hiding this comment.
sorry for the slow review, let me know if there are any doubts about the comments
|
Thanks for the detailed review @OriolAbril,that clarifies the issue well. |
|
@OriolAbril ,I’ve updated the implementation to avoid reconstructing labeled objects with arviz_base.from_dict. Instead, the output is now built using xarray.DataTree.from_dict, which preserves both dimensions and non-index coordinates. |
|
RTD docs build failed; I’m looking into the Sphinx warning causing it (likely related to weight_predictions docstring / imports). |
|
The RTD failure is due to an incompatibility between Sphinx 9.1.0 and sphinx_autosummary_accessors |
OriolAbril
left a comment
There was a problem hiding this comment.
sorry about the slow review cadence. We have just released the 1.0 version so hopefully things will improve now, but probably not immediately, we do have a significant backlog to catch up with before that.
I also extended the tests to explicitly add non-index coordinates and assert that both observed_data and posterior_predictive coordinates are preserved after calling weight_predictions.
I have added a comment mentioning that, but this is not the case at all.
The RTD failure is due to an incompatibility between Sphinx 9.1.0 and sphinx_autosummary_accessors
This is unrelated to the changes in this PR. Happy to help pin Sphinx or adjust the docs setup if you’d like to handle it here.
We already included the pin. If you rebase on main the RTD build will go back to green again.
tests/test_manipulation.py
Outdated
|
|
||
| def test_weight_predictions_preserves_coords(): | ||
| idata = az.load_arviz_data("centered_eight") | ||
| dt = convert_to_datatree(idata) |
There was a problem hiding this comment.
| dt = convert_to_datatree(idata) |
idata variable is already a DataTree. We often use idata or dt but the type is always DataTree. The use of idata is mostly for historical reasons, but there is also no need to change that because a DataTree object can have an arbitrary schema regarding groups and variables while our variables and inputs follow a stricter set of conventions (defined here)
There was a problem hiding this comment.
I probably wasn't very clear so I'll try again. idata is already a DataTree so calling convert_to_datatree is useless and should not be done (hence the suggestion within the review comment to remove the line). The rest of the comment is because it doesn't matter if you keep idata = az.load_arviz_data then use idata later on or update to dt = az.load_arviz_data.
OriolAbril
left a comment
There was a problem hiding this comment.
there are still comments to address. I'd recommend going over all of them again, note you can mark them as resolved so it is easier to see what is still pending.
And all CI jobs are failing not sure if only due to but at least in part due to the imports in the test file. Look at what the file is already doing and at https://python.arviz.org/projects/stats/en/latest/contributing/testing.html
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #285 +/- ##
==========================================
+ Coverage 84.59% 84.85% +0.25%
==========================================
Files 43 43
Lines 5974 5974
==========================================
+ Hits 5054 5069 +15
+ Misses 920 905 -15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi! @OriolAbril I’ve applied all the requested changes and the tests and lint checks are passing now. The only remaining failure is the ReadTheDocs build. From the logs it looks like a Sphinx compatibility issue with Please let me know if there’s something I should modify on my side. Thanks! |
There was a problem hiding this comment.
I have unresolved this comment because it was not addressed.
Extra note: if you can please rebase on main. As I mentioned in another comment this will fix the RTD build.
|
Hi @OriolAbril, Sorry for missing that comment earlier. I’ve been in the middle of my mid-semester exams recently, so I wasn’t able to go through all the review comments as carefully as I should have. That’s my mistake. Thanks for pointing it out again. I’ll address the unresolved comment and rebase the branch on Appreciate your patience! |
a180e9e to
32b2e4f
Compare
|
Thanks @OriolAbril for pointing that out. I’ve updated the test to remove the unnecessary Happy to make further changes if needed. |
Closes #269