From 7b5c61cd951e5071170995fa885151711e8f48c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20H=C3=B6chenberger?= Date: Wed, 1 Dec 2021 12:33:29 +0100 Subject: [PATCH] MRG: Don't overwrite Report.fname upon saving (#9998) (#10066) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Don't overwrite Report.fname upon saving * Add changelog entry * Fix pickling Co-authored-by: Richard Höchenberger --- doc/changes/0.24.inc | 2 ++ mne/report/report.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/changes/0.24.inc b/doc/changes/0.24.inc index 08899b35bfe..6e36c0c03d0 100644 --- a/doc/changes/0.24.inc +++ b/doc/changes/0.24.inc @@ -45,6 +45,8 @@ Version 0.24.1 (2021-12-01) - Fix automatic channel type detection from channel labels in :func:`mne.io.read_raw_edf` and :func:`mne.io.read_raw_bdf` (and disable this functionality from :func:`mne.io.read_raw_gdf`) (:gh:`10058` by `Clemens Brunner`_) +- When opening a saved report and saving it to a different filename again, don't change ``Report.fname`` to avoid a regression when using :func:`~mne.open_report` as a context manager (:gh:`9998` by `Marijn van Vliet`_) + .. _changes_0_24_0: Version 0.24.0 (2021-11-03) diff --git a/mne/report/report.py b/mne/report/report.py index 1998cfce0dd..d79203e0094 100644 --- a/mne/report/report.py +++ b/mne/report/report.py @@ -741,7 +741,8 @@ def _get_state_params(): return ( 'baseline', 'cov_fname', 'include', '_content', 'image_format', 'info_fname', '_dom_id', 'raw_psd', 'projs', - 'subjects_dir', 'subject', 'title', 'data_path', 'lang', 'verbose' + 'subjects_dir', 'subject', 'title', 'data_path', 'lang', 'verbose', + 'fname' ) def _get_dom_id(self): @@ -2843,7 +2844,8 @@ def save(self, fname=None, open_browser=True, overwrite=False, if open_browser and not is_hdf5 and not building_doc: webbrowser.open_new_tab('file://' + fname) - self.fname = fname + if self.fname is None: + self.fname = fname return fname def __enter__(self):