Repository navigation
[MRG] Improve ICA docstring - #5114
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5114 +/- ##
==========================================
+ Coverage 88.14% 88.17% +0.03%
==========================================
Files 356 358 +2
Lines 65774 65899 +125
Branches 11193 11203 +10
==========================================
+ Hits 57978 58108 +130
+ Misses 4959 4956 -3
+ Partials 2837 2835 -2 |
|
Quick question, what do the numbers Also, shouldn't the reference list be at the very end of the description? Currently, they are placed right after the parameters, before the attributes. |
|
it pionts you to where the refs are mentioned.
|
|
in the docstring the shape of the attributes should be mentioned. it
will help to understand the underlying algebra too.
|
|
In the code it looks like the refs are below I have no idea how it ends up above |
|
@agramfort each ref is only mentioned once. |
|
indeed my bad. i don't know then...
|
|
@larsoner I think you're looking at the right lines. Maybe this is a Sphinx setting? It's not specific to this class. |
|
I've created a separate issue #5118 for these docs issues. Let's focus on improving the ICA docs here. |
|
@agramfort regarding the shapes, do you really want me to add this information for all attributes? I agree that this would be nice, but the shape of e.g. the unmixing matrix depends on specific parameters (e.g. whether you're using |
| pca_components_ : ndarray | ||
| If fit, the PCA components | ||
| ``pca_mean_`` : ndarray | ||
| pca_mean_ : ndarray |
There was a problem hiding this comment.
I really think you should document the shapes using n_channels and the other attributes such as n_components_
There was a problem hiding this comment.
| References | ||
| ---------- | ||
| .. [1] Hyvarinen, A., 1999. Fast and robust fixed-point algorithms for | ||
| .. [1] Hyvärinen, A., 1999. Fast and robust fixed-point algorithms for |
There was a problem hiding this comment.
This might necessitate using u""" above
| The number of components used for PCA dimensionality reduction. | ||
| verbose : bool, str, int, or None | ||
| See above. | ||
| pre_whitener_ : ndarray |
There was a problem hiding this comment.
you really don't want to add the shapes here?
There was a problem hiding this comment.
I do want to add the shapes eventually, I was just saying that this might be better implemented in #4856 once we've sorted out all open issues there. However, if you insist I can also add them here. Let me know.
|
i think it would be great to have the shapes for the release
|
|
OK, I will do this tomorrow! |
|
I did some more spring cleaning, please review if these changes are OK. I've also added shapes for ndarrays. Some things are still unclear, especially everything related to the However, I'd like to address the following open issues here:
Other more general things to discuss:
|
|
OK, and now we have the problem that Sphinx renders things with underscores as links. I tried to escape them with backslashes, but it doesn't seem to work (unless raw strings do the trick, but I doubt that). Any ideas? It works fine in the parameters list, but not in the attributes: https://7784-1301584-gh.circle-artifacts.com/0/html/generated/mne.preprocessing.ICA.html#mne.preprocessing.ICA |
|
The linked attributes list looks okay, where should I see the problem? I also don't see any related warnings in the CircleCI build. |
|
If you like how it uses You might also be able to get away with single-backticks if you want to keep the italic formatting |
|
OK, single backticks work and look better than double backticks. |
|
In addition to my questions above, there's one more thing I don't understand: why is the |
|
We request for it to be added to classes if it exists: https://github.com/mne-tools/mne-python/blob/master/mne/utils.py#L74 But in retrospect this is an advanced use case, so +1 for removing it from our list |
|
Where is the |
|
I don't know actually. Maybe there is some built-in hash function |
| The number of components used for PCA decomposition. If None, no | ||
| dimension reduction will be applied and max_pca_components will equal | ||
| the number of channels supplied on decomposing data. Defaults to None. | ||
| dimension reduction will be applied and `max_pca_components` will equal |
| Infomax and Picard differ, making it hard to compare different | ||
| tolerance levels, but a rule of thumb is | ||
| `tol_fastica = tol_picard ** 2`. Reducing the tolerance speeds up | ||
| estimation but the consistency of the obtained results decreases. |
There was a problem hiding this comment.
This comment on Picard must have been recent. Why is it not good?
There was a problem hiding this comment.
Yes, I think this comment is too specific for the ICA docstring.
There was a problem hiding this comment.
sorry but I don't see the comment anywhere. Do I miss something?
There was a problem hiding this comment.
I just looked and I can't find it either! @cbrnr can you move this to the Notes section
There was a problem hiding this comment.
Notes of the ICA class (if it doesn't exist, add it)
There was a problem hiding this comment.
OK, I'll create one, but is anyone up to rephrasing it? I think Picard is more or less an Extended FastICA, so I'm not sure if the tolarance can really be compared with Infomax?
There was a problem hiding this comment.
Reducing the tolerance speeds up estimation at the cost of consistency of the obtained results. It is difficult to directly compare tolerance levels between Infomax and Picard, but for Picard and FastICA a good rule of thumb is tol_fastica = tol_picard ** 2.
There was a problem hiding this comment.
Thanks, I like it! Moving that to the Notes section.
There was a problem hiding this comment.
Sounds good to me as well!
|
Looks good otherwise. Thank you Clemens! |
|
@larsoner is an Do you have time to help me with these open questions concerning the ICA docstring? I'd like to fix this for this PR.
|
|
I don't think we are consistent about all attributes being shown. In principle, though, not all parameters passed to the class constructor will be turned into attributes (they can be stored privately or used immediately to make some other var instead), so it might be a good idea to list them if they do turn into attributes. I'm fine with it either way |
|
As far as |
|
@larsoner it's just weird that |
|
OK, if CIs are happy this is ready to merge. I'll leave the list of attributes without the parameters for now because it is a bit redundant. But of course you are right, |
|
thx @cbrnr |
* Docstring cosmetics; rename _pre_whitener to pre_whitener_ * Add pre_whitener_ to list of attributes * Rename all _pre_whitener -> pre_whitener_ * Update tests * Fix Python 2 encoding issue * Unicode str for Python 2 * Cleanup and add shapes * Escape training underscores * Try single backticks * dimension -> dimensionality * Move Picard comment to Notes section, remove refs to non-existing methods

Fixes #4882.