-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fixed error introduced by 6f58dbf #2419
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
Conversation
…itialized as an array instead of a dict. This commit maintains the intentions of the 6f58dbf commit by initializing 'scaling' to a dict of arrays of identity with type floatX.
this is related to #2413 right? |
correct |
@ctm22396 Thanks for the pull request. You are right that the current behaviour is wrong. But the original intension of 6f58dbf was to avoid using |
Oh I see. So perhaps the code could take the subset of the test point dictionary containing the requisite variables and build the array of ones from that?
|
@ctm22396 I think changing it to |
The length of 'vars' will not be the same as the size of the array form of the dictionary if the model has random variables that have shapes > 1. Perhaps cutting out the dict to array function and doing this is better: if scaling is None and potential is None:
varnames = [var.name for var in vars]
size = sum(v.size for k, v in model.test_point.items() if k in varnames)
scaling = floatX(np.ones(size)) I was curious, and the native python sum function is faster on python objects (i.e. this iterator) according to https://stackoverflow.com/questions/10922231/pythons-sum-vs-numpys-numpy-sum . The decrease in performance in np.sum is due to the overhead of converting the iterable into a numpy array before summing. |
I believe I correctly reran the tests that it had previously failed on (test_leapfrog_reversible and test_leap_reversible_single). There were no errors this time. Also, this syntax is compatible with python 2.7 |
@ctm22396 Yep you are right, please go ahead and push the new change. |
This commit is actually preserves the intention of the previous commit as it avoids the guess_scaling function. It still maintains that the shape of scaling must be the size of the specified variables instead of the whole model.
…y used for dict to array bijection
Thanks for the help! |
@ctm22396 Thanks for the fix. |
In which the 'scaling' variable is initialized as an array of ones instead of a dict that matches variables with arrays of ones with the shape of the variable. This resulted in the 'scaling' variable have the shape of entire model. So, if a user set the step method manually for a variable, the shape of the '
This commit preserves the intentions of the 6f58dbf commit by initializing 'scaling' to a dict of arrays of ones with type floatX. As a result, the function "guess_scaling" will be able to create a scaling array with the correct shape.