Skip to content

FIX: Warn on rank estimate with too few samples #13350

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

emmanuel-ferdman
Copy link

@emmanuel-ferdman emmanuel-ferdman commented Jul 24, 2025

PR Summary

This small PR warns on rank estimate with too few samples.

Copy link

welcome bot commented Jul 24, 2025

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx !

@drammock
Copy link
Member

Wow, this causes more than 30 tests to fail. Will need some investigation as to which ones are legitimate failures and how to correct them

@larsoner
Copy link
Member

We should probably turn it into a warning instead

@emmanuel-ferdman emmanuel-ferdman changed the title FIX: Raise exception on rank estimate with too few samples FIX: Warn on rank estimate with too few samples Jul 25, 2025
@emmanuel-ferdman
Copy link
Author

@drammock @larsoner I changed it to throw a warning and fixed the tests 😄

@@ -184,7 +184,7 @@ def _estimate_rank_meeg_signals(
"""
picks_list = _picks_by_type(info)
if data.shape[1] < data.shape[0]:
ValueError(
warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From talking to @drammock today, it might actually be safest to have a on_few_samples="raise" option in public-facing functions/APIs that eventually gets passed to this function. Then you can use _on_missing(...) helper function to throw an error or emit a warning. Would you be up for trying this?

Then in the tests below you should be able to pass on_few_samples="ignore" rather than adding a pytest warning ignore decorator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants