From cb7f2f04006aed291fa0010eb67b67f09f560d04 Mon Sep 17 00:00:00 2001
From: Felix Fischer <f.fischer@ifas.rwth-aachen.de>
Date: Tue, 25 Feb 2025 11:41:28 +0100
Subject: [PATCH] Supress all warnings by the secondary plot functions
---
src/scientific_plots/__init__.py | 2 +-
src/scientific_plots/plot_settings.py | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/scientific_plots/__init__.py b/src/scientific_plots/__init__.py
index c500bae..d607b78 100644
--- a/src/scientific_plots/__init__.py
+++ b/src/scientific_plots/__init__.py
@@ -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
functions."""
-__version__ = "1.8.6"
+__version__ = "1.8.7"
diff --git a/src/scientific_plots/plot_settings.py b/src/scientific_plots/plot_settings.py
index 9c59947..50538ab 100644
--- a/src/scientific_plots/plot_settings.py
+++ b/src/scientific_plots/plot_settings.py
@@ -506,6 +506,20 @@ def supress_warnings(plot_function: Callable[Params, None])\
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
def apply_styles(plot_function: Callable[Params, None], *,
three_d: bool = False,
@@ -567,6 +581,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *,
errors = (OSError, FileNotFoundError, ThreeDPlotException,
FallBackException)
+ @supress_all_warnings
def journal() -> None:
"""Create a plot for journals."""
set_rwth_colors(three_d)
@@ -576,6 +591,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *,
_plot_function(*args, **kwargs)
plt.close("all")
+ @supress_all_warnings
def sans_serif() -> None:
"""
Create a plot for journals with sans-serif-fonts.
@@ -587,6 +603,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *,
_plot_function(*args, **kwargs)
plt.close("all")
+ @supress_all_warnings
def grayscale() -> None:
"""
Create a plot in grayscales for disserations.
@@ -605,6 +622,7 @@ def apply_styles(plot_function: Optional[Callable[Params, None]] = None, *,
_plot_function(*args, **new_kwargs)
plt.close("all")
+ @supress_all_warnings
def presentation() -> None:
"""
Create a plot for presentations.
--
GitLab