Skip to content

Commit

Permalink
[FIX] use parameter deprecation decorator (#4189)
Browse files Browse the repository at this point in the history
* use deprecation decorator

* Update nilearn/plotting/html_document.py

Co-authored-by: Jérôme Dockès <jerome@dockes.org>

* lint

---------

Co-authored-by: Jérôme Dockès <jerome@dockes.org>
  • Loading branch information
Remi-Gau and jeromedockes committed Jan 6, 2024
1 parent 310f5ca commit 2de0c82
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions nilearn/plotting/html_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from socketserver import TCPServer
from threading import Thread

from nilearn._utils import remove_parameters

MAX_IMG_VIEWS_BEFORE_WARNING = 10
BROWSER_TIMEOUT_SECONDS = 3.0

Expand Down Expand Up @@ -197,6 +199,14 @@ def save_as_html(self, file_name):
with open(file_name, "wb") as f:
f.write(self.get_standalone().encode("utf-8"))

@remove_parameters(
removed_params=["temp_file_lifetime"],
reason=(
"this function does not use a temporary file anymore "
"and 'temp_file_lifetime' has no effect."
),
end_version="0.13.0",
)
def open_in_browser(self, file_name=None, temp_file_lifetime="deprecated"):
"""Save the plot to a temporary HTML file and open it in a browser.
Expand All @@ -212,13 +222,6 @@ def open_in_browser(self, file_name=None, temp_file_lifetime="deprecated"):
The parameter is kept for backward compatibility and will be
removed in a future version. It has no effect.
"""
if temp_file_lifetime != "deprecated":
warnings.warn(
"temp_file_lifetime is deprecated. It has no "
"effect and passing a value for this parameter "
"will result in an error starting with nilearn version 0.13",
DeprecationWarning,
)
if file_name is None:
_open_in_browser(self.get_standalone().encode("utf-8"))
else:
Expand Down

0 comments on commit 2de0c82

Please sign in to comment.