From 79b22049a604a74c6eb262c9f599a15f91566d95 Mon Sep 17 00:00:00 2001 From: Minna Win-Gildenmeister Date: Fri, 27 Oct 2023 09:32:21 -0600 Subject: [PATCH 1/4] Fix title to reflect the actual data used --- test/roc_diagram/custom_roc_diagram.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/roc_diagram/custom_roc_diagram.yaml b/test/roc_diagram/custom_roc_diagram.yaml index 9fd19135..a942fcac 100644 --- a/test/roc_diagram/custom_roc_diagram.yaml +++ b/test/roc_diagram/custom_roc_diagram.yaml @@ -10,7 +10,7 @@ dump_points_1: 'False' # points_path: '/dir_to_save_points1_file' # Title settings -title: "Custom: ROC PCT 20200507_074426 " +title: "Custom: ROC CTC 20200507_074426 " # value of 0.5 centers the title, smaller values moves text to the left title_align: 0.3 # -2 locates title at top, -1.5 puts title inside plotting region From 745d71601ca347d91bf6ff8e3312677888d22ad0 Mon Sep 17 00:00:00 2001 From: Minna Win-Gildenmeister Date: Fri, 27 Oct 2023 09:33:23 -0600 Subject: [PATCH 2/4] Change title to reflect the data used --- test/roc_diagram/PCT_ROC.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/roc_diagram/PCT_ROC.yaml b/test/roc_diagram/PCT_ROC.yaml index 29e272c3..5a8e2103 100644 --- a/test/roc_diagram/PCT_ROC.yaml +++ b/test/roc_diagram/PCT_ROC.yaml @@ -90,7 +90,8 @@ show_signif: - 'False' stat_input: PCT_ROC.data sync_yaxes: 'False' -title: test title +title: test title PCT ROC data + title_align: 0.5 title_offset: -2 title_size: 1.4 From f1eb04fc12a72a765afc709728ab74b81605ce0c Mon Sep 17 00:00:00 2001 From: bikegeek Date: Wed, 1 Nov 2023 15:44:46 -0600 Subject: [PATCH 3/4] Issue #394 Suppress deprecation warning emanating from python-kaleido/plotly --- metplotpy/plots/base_plot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/metplotpy/plots/base_plot.py b/metplotpy/plots/base_plot.py index 5f7496bb..106bf3a1 100644 --- a/metplotpy/plots/base_plot.py +++ b/metplotpy/plots/base_plot.py @@ -16,6 +16,7 @@ import os import logging +import warnings import numpy as np import yaml from typing import Union @@ -343,6 +344,9 @@ def save_to_file(self): image_name = self.get_config_value('plot_filename') + # Suppress deprecation warnings from third-party packages that are not in our control. + warnings.filterwarnings("ignore", category=DeprecationWarning) + # Create the directory for the output plot if it doesn't already exist dirname = os.path.dirname(os.path.abspath(image_name)) if not os.path.exists(dirname): @@ -354,9 +358,12 @@ def save_to_file(self): self.logger.error(f"FileNotFoundError: Cannot save to file" f" {image_name}") # print("Can't save to file " + image_name) + except ResourceWarning: + self.logger.warning(f"ResourceWarning: in _kaleido" + f" {image_name}") + except ValueError as ex: self.logger.error(f"ValueError: Could not save output file.") - # print(ex) else: self.logger.error(f"The figure {dirname} cannot be saved.") print("Oops! The figure was not created. Can't save.") From 11f7d8fe430becc98315d6dca6864b99e2e93d2a Mon Sep 17 00:00:00 2001 From: bikegeek Date: Wed, 1 Nov 2023 15:45:51 -0600 Subject: [PATCH 4/4] Remove save_to_file(), use version in base_plot --- metplotpy/plots/roc_diagram/roc_diagram.py | 27 ++++++---------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/metplotpy/plots/roc_diagram/roc_diagram.py b/metplotpy/plots/roc_diagram/roc_diagram.py index 0041a125..3103db80 100644 --- a/metplotpy/plots/roc_diagram/roc_diagram.py +++ b/metplotpy/plots/roc_diagram/roc_diagram.py @@ -18,6 +18,11 @@ import yaml import re import sys +import warnings +# with warnings.catch_warnings(): +# warnings.simplefilter("ignore", category="DeprecationWarning") +# warnings.simplefilter("ignore", category="ResourceWarning") + import pandas as pd import plotly.graph_objects as go from plotly.subplots import make_subplots @@ -29,6 +34,7 @@ import metcalcpy.util.utils as calc_util + class ROCDiagram(BasePlot): """ Creates a ROC diagram based on settings in a config file and @@ -154,6 +160,7 @@ def remove_file(self): """ image_name = self.get_config_value('plot_filename') + warnings.filterwarnings("ignore", category=DeprecationWarning) # remove the old file if it exist if os.path.exists(image_name): @@ -363,27 +370,7 @@ def add_trace_copy(trace): return fig - def save_to_file(self): - """Saves the image to a file specified in the config file. - Prints a message if fails - - Args: - - Returns: - """ - image_name = self.get_config_value('plot_filename') - if self.figure: - try: - self.figure.write_image(image_name) - - except FileNotFoundError: - self.logger.error(f"FileNotFoundError: Cannot save " - f"{image_name} to file.") - except ValueError as ex: - self.logger.error(f"ValueError: {ex}") - else: - self.logger.warning("Oops! The figure wasn't created. Cannot save file.") def write_output_file(self): """