Skip to content
Snippets Groups Projects
Commit cb7f2f04 authored by Felix Fischer's avatar Felix Fischer :shrimp:
Browse files

Supress all warnings by the secondary plot functions

parent dbcaa7f6
No related branches found
No related tags found
1 merge request!58Supress all warnings by the secondary plot functions
Pipeline #1625856 passed with warnings
...@@ -5,4 +5,4 @@ useful across several different projects and repositories. It also contains ...@@ -5,4 +5,4 @@ useful across several different projects and repositories. It also contains
stub-files with several data-type annotations for scipy and matplot-lib stub-files with several data-type annotations for scipy and matplot-lib
functions.""" functions."""
__version__ = "1.8.6" __version__ = "1.8.7"
...@@ -506,6 +506,20 @@ def supress_warnings(plot_function: Callable[Params, None])\ ...@@ -506,6 +506,20 @@ def supress_warnings(plot_function: Callable[Params, None])\
return wrapped_function return wrapped_function
def supress_all_warnings(plot_function: Callable[Params, None])\
-> Callable[Params, None]:
"""Supress all warnings given by the called function."""
@wraps(plot_function)
def wrapped_function(
*args: Params.args, **kwargs: Params.kwargs) -> None:
"""Wrapped function without all of the warnings."""
with catch_warnings():
simplefilter("ignore")
plot_function(*args, **kwargs)
return wrapped_function
@overload @overload
def apply_styles(plot_function: Callable[Params, None], *, def apply_styles(plot_function: Callable[Params, None], *,
three_d: bool = False, three_d: bool = False,
...@@ -567,6 +581,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *, ...@@ -567,6 +581,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *,
errors = (OSError, FileNotFoundError, ThreeDPlotException, errors = (OSError, FileNotFoundError, ThreeDPlotException,
FallBackException) FallBackException)
@supress_all_warnings
def journal() -> None: def journal() -> None:
"""Create a plot for journals.""" """Create a plot for journals."""
set_rwth_colors(three_d) set_rwth_colors(three_d)
...@@ -576,6 +591,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *, ...@@ -576,6 +591,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *,
_plot_function(*args, **kwargs) _plot_function(*args, **kwargs)
plt.close("all") plt.close("all")
@supress_all_warnings
def sans_serif() -> None: def sans_serif() -> None:
""" """
Create a plot for journals with sans-serif-fonts. Create a plot for journals with sans-serif-fonts.
...@@ -587,6 +603,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *, ...@@ -587,6 +603,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *,
_plot_function(*args, **kwargs) _plot_function(*args, **kwargs)
plt.close("all") plt.close("all")
@supress_all_warnings
def grayscale() -> None: def grayscale() -> None:
""" """
Create a plot in grayscales for disserations. Create a plot in grayscales for disserations.
...@@ -605,6 +622,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *, ...@@ -605,6 +622,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *,
_plot_function(*args, **new_kwargs) _plot_function(*args, **new_kwargs)
plt.close("all") plt.close("all")
@supress_all_warnings
def presentation() -> None: def presentation() -> None:
""" """
Create a plot for presentations. Create a plot for presentations.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment