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

add overwrite and verbose params to info.save #13107

Merged
merged 4 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/devel/13107.newfeature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The :meth:`mne.Info.save` method now has an ``overwrite`` and a ``verbose`` parameter, by `Stefan Appelhoff`_.
13 changes: 11 additions & 2 deletions mne/_fiff/meas_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,15 +1935,24 @@ def _repr_html_(self):
info_template = _get_html_template("repr", "info.html.jinja")
return info_template.render(info=self)

def save(self, fname):
@verbose
def save(self, fname, *, overwrite=False, verbose=None):
"""Write measurement info in fif file.

Parameters
----------
fname : path-like
The name of the file. Should end by ``'-info.fif'``.
%(overwrite)s

.. versionadded:: 1.10
%(verbose)s

See Also
--------
mne.io.write_info
"""
write_info(fname, self)
write_info(fname, self, overwrite=overwrite)


def _simplify_info(info, *, keep=()):
Expand Down
2 changes: 1 addition & 1 deletion mne/_fiff/tests/test_meas_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def test_field_round_trip(tmp_path):
meas_date=_stamp_to_dt((1, 2)),
)
fname = tmp_path / "temp-info.fif"
write_info(fname, info)
info.save(fname)
info_read = read_info(fname)
assert_object_equal(info, info_read)
with pytest.raises(TypeError, match="datetime"):
Expand Down
Loading