Repository navigation
Add MATLAB-style implementations of the quantile and IQR functions - #57
Conversation
|
+1 for individual tests , at least at this stage. If you do a test comparing the saved matlab result (of only these functions) against this implementation and they come out as working better than before then I think that is enough; we are getting closer to matlab. As you say a full pipeline test matlab vs python would be another PR . Thats a separate issue on its own. +1 to private functions, I think this is too deep inside the code to be public, nor we are developing specifically these statistical functions. |
agreed
docstrings are almost always a good idea - even if it's not public-facing, the documentation will help us (the developers) in the future. Following the numpydoc convention makes the whole thing well structured and easy to read for us --> even if it does not end up being rendered as html on our docs page.
agreed |
cdedd39 to
f28a8bb
Compare
|
@yjmantilla @sappelhoff Thanks for reviewing this! I've updated the pull request accordingly, and have also rebased to the current master branch. |
sappelhoff
left a comment
There was a problem hiding this comment.
looks great :) some minor questions/clarifications
| ---------- | ||
| arr : np.ndarray | ||
| Input array containing samples from the distribution to summarize. | ||
| axis : {int, tuple of int, None}, optional |
There was a problem hiding this comment.
where did you get the idea to document the different options in curly brackets?
I usually do: axis : int | tuple of int | None, and then write what it defaults to in the description string below (not writing "optional" explicitly)
which doesn't mean that that's better (hence my question).
There was a problem hiding this comment.
Oh, I just copy/pasted that bit directly from the docstring of numpy.quantile since that arguments getting passed unmodified to that function anyway. No rationale whatsoever on my part, just figured I'd go with whatever the Numpy maintainers thought was the correct format (I'm new to Numpy docstrings, I've previously only used Google-style ones for Python).
If you'd like I can change it to your preferred format for the sake of consistency across PyPREP!
There was a problem hiding this comment.
ah thanks, I read the numpydoc styleguide again, and it seems like the curly brackets is advertised. I think I picked up the | style from MNE-Python. Let's stick with the curly braces here and in general slowly convert to that style whenever we touch (git diff) a line that still uses the | style in the remaining codebase.
|
Thanks @a-hurst :-) on a roll with these PRs |
PR Description
Closes #56. As mentioned in that issue, MATLAB's quantile and IQR functions calculate quantiles slightly differently than Numpy and SciPy, leading to higher sensitivity to differences in channel correlation than in the original MATLAB PREP. This PR adds new
mat_quantileandmat_iqrfunctions that match MATLAB's quantile logic and make PyPREP's internal correlation matrix forNoisyChannels.find_bad_by_correlationmatch the values in MATLAB PREP's equivalent matrix exactly.TODO
_mat_irqand_mat_quantile) so I held off on writing docstrings.Merge Checklist
closes #<issue-number>to automatically close an issue