-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix for issue 7369 #7514
base: main
Are you sure you want to change the base?
Fix for issue 7369 #7514
Conversation
] |
pymc/backends/ndarray.py
Outdated
@@ -115,6 +115,8 @@ def record(self, point, sampler_stats=None) -> None: | |||
if sampler_stats is not None: | |||
for data, vars in zip(self._stats, sampler_stats): | |||
for key, val in vars.items(): | |||
if isinstance(val, np.ndarray) and val.shape[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.
Can val have more than one dim? More importantly it would be good if we didn't need this check in every iteration/ for every stat.
Can we solve it from another angle?
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.
none of the tests passed in any values of greater than one dimension -- but noted on the point about trying to solve this outside the loop!
@ricardoV94 -- spent a little time looking at this and i think this problem is hard to solve outside the loop context given the setup of the let me know what you think |
What happens if val has Taking a step back, the problem here seems to be the buffer was allocated with the wrong shape? If a stat has shape (1,) in every draw, the buffer should have (draws, 1) shape, not (draws,) and no coercing to scalar would be needed. Am I off track here? |
okay yea that makes sense -- i'm not sure if there's a better way to coerce here than trying to find arrays of shape (1,) because i don't think it makes sense to traverse the |
We should look at the code where the stats arrays are allocated to see how it's deciding on the shape |
The assumption that stats are scalars happens here: Line 90 in 45069a9
If that's a requirement, then the problem is in Metropolis not respecting it. If that's not a requirement, the problem is in assuming the stats will be scalars. Which statistic from Metropolis step sampler is not respecting the scalar shape? |
Fix for numpy deprecation warning (#7369)
Description
Small PR that addresses the numpy deprecation warnings that are seen when running tests:
Change looks at the type of the
val
and if it is anp.ndarray
and has.shape[0]
== 1, then we pop the item out to prevent the deprecation warning.Related Issue
test_metropolis.py
#7369Checklist
Type of change
📚 Documentation preview 📚: https://pymc--7514.org.readthedocs.build/en/7514/