-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fixes behavior of stc.save() as mentioned in issue #13158 #13165
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI errors look related:
FAILED mne/tests/test_source_estimate.py::test_io_stc - OSError: SourceEstimate File(s) not found for: PosixPath('/private/var/folders/0j/bwqcs4y508s2n4ck4dhf3rpc0000gn/T/pytest-of-runner/pytest-0/test_io_stc0/tmp.stc')
Does mne/tests/test_source_estimate.py::test_io_stc pass for you locally?
else: | ||
raise ValueError("Cannot infer file type, please specify ftype.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the suggestion in the linked issue was to fall back to "stc"
if the file type could not be inferred (not raise an error).
File format to use. Allowed values are ``"stc"`` (default), | ||
``"w"``, and ``"h5"``. The ``"w"`` format only supports a single | ||
time point. | ||
ftype : str | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the suggestion in the linked issue was to use "auto"
(not None
) for the "infer-from-fname" behavior. I don't have very strong feelings one way or another, but @larsoner might?
@drammock I have changed ftype from None to auto coz it was fairly easy. But, while running tests, it shows the following error: which says: FAILED test_source_estimate.py::test_io_stc - OSError: SourceEstimate File(s) not found for: PosixPath('/tmp/pytest-of-shresth/pytest-1/test_io_stc0/tmp.stc') I'm not aware about how to fix this error. Please help. |
@@ -1884,7 +1884,7 @@ class SourceEstimate(_BaseSurfaceSourceEstimate): | |||
""" | |||
|
|||
@verbose | |||
def save(self, fname, ftype="stc", *, overwrite=False, verbose=None): | |||
def save(self, fname, ftype="auto", overwrite=False, verbose=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't remove the *
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thanks for pointing out,
I had noticed that a couple of days back, added "*" as suggested, but still, when I run pytest, it fails with the same message as mentioned above.
Well, if I test the function using a sample stc file, it works perfectly.
I guess the problem is not limited only to this, and needs some other tiny fix.
Fixes #13158 .
Doing stc.save("test.h5") saves a single test.h5 file, and doing stc.save("test.stc") saves to the two files test-lh.stc and test-rh.stc.
Please let me know if any more changes required in the current iteration.