Skip to content
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

MAINT: Remove code using vulture confidence 60 #12575

Merged
merged 5 commits into from May 21, 2024

Conversation

larsoner
Copy link
Member

Turns out we had a bunch of dead code. We also had a bunch of unused global vars in our test files which this caught!

This also makes me think that we should maybe add a test that checks the inventory of the testing dataset to make sure all files are used. Given the removals here it's possible that some no longer are, and it's either a bug and we should add them back somehow or we should remove them from the testing dataset...

@hoechenberger
Copy link
Member

Wow this is massive

def _replace_md5(fname):
"""Replace a file based on MD5sum."""
# adapted from sphinx-gallery
assert fname.endswith(".new")
Copy link
Member

Choose a reason for hiding this comment

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

this won't work for Path objects, is that OK?

Copy link
Member Author

Choose a reason for hiding this comment

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

Must be, this is just copy-pasted 🙂

@larsoner
Copy link
Member Author

@drammock this one should be good to go now!

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

startling how much unused code in there. Some of it seems useful enough that I'm wondering if it should either get promoted to public API, or spun off into a utils-like section of mne-incubator. I'm thinking of things like

  • _is_scaled_mri_subject
  • _copy_channel
  • _ensure_image_in_surface_RAS
  • _pair_grad_sensors_* (for when info absent, e.g., projectors)

Feel free to merge if you disagree; I don't have time to do it myself ATM so I don't want to be a blocker.

@@ -1007,7 +1007,7 @@ def csd_array_multitaper(
n_times = len(times)
n_fft = n_times if n_fft is None else n_fft

window_fun, eigvals, mt_adaptive = _compute_mt_params(
window_fun, eigvals, adaptive = _compute_mt_params(
Copy link
Member

Choose a reason for hiding this comment

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

yikes, this was probably a bug

@larsoner
Copy link
Member Author

Some of it seems useful enough that I'm wondering if it should either get promoted to public API, or spun off into a utils-like section of mne-incubator

Perhaps. I'm happy to leave it out for now and see if people need it and assume YAGNI until then. Plus we don't know the extent to which those snippets of code still work with our codebase at this point since they haven't been tested. It's easy enough to find in the history especially knowing the lines were removed in this vulture PR, though, if we do want them.

@larsoner larsoner merged commit 2db23cd into mne-tools:main May 21, 2024
30 checks passed
@larsoner larsoner deleted the vulture branch May 21, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants