-
Notifications
You must be signed in to change notification settings - Fork 21
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
Mismatch of docs and definition of postTools.sample_prob #348
Comments
Try getting rid of the line and seeing if all the tests still pass? |
I reread the comment in the function, here is my idea.
I can get the test pass, but I am not sure if I missed something or I misunderstood the point of this function. |
looking at it more closely now... yeah, I see what you mean. If Looking at the docstring, I see that indices is actually supposed to be passed to the function. My guess, and @eecsu can weigh in, is that this was simply omitted accidentally, and that
Then everything seems to fall into place and makes more sense. It makes sense to make the change I mentioned above, so the documentation aligns with the definition. But thinking more about how this function should work, I think we can also do this:
This should also allow the tests to pass. What is currently Line 146 should stay in. |
Alternative: add functionality by allowing sorting on a subset of indices, but in that case we'll need to trim the sample set before passing to |
Line 146: indices is not defined if sort is False. My guess is that 'if descending' might be within 'if sort'
Line 139: it seems to me that 'if descending' should return sample by the descending order of the probability. But when I checked the code of the function 'sort_by_rho',
Line 59: indices = np.argsort(P_samples)[::-1][0:nnz]
[::-1] will make it return the indices in descending order. This means that 'indices' in Line 128 is the descending index, so I think there is no need of Line 146. Then Line 140-145 will also make those terms sort by ascending order.
The text was updated successfully, but these errors were encountered: