Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 296 warnings #301

Merged
merged 9 commits into from
Jan 18, 2023
3 changes: 2 additions & 1 deletion metplotpy/plots/histogram/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def _perform_event_equalization(self):
if input_df_ee is None:
input_df_ee = series_data_after_ee
else:
input_df_ee = input_df_ee.append(series_data_after_ee).reindex()
# input_df_ee = input_df_ee.append(series_data_after_ee).reindex()
input_df_ee = pd.concat([input_df_ee, series_data_after_ee]).reindex()
else:
input_df_ee = event_equalize(self.input_df, "fcst_valid_beg", {}, fix_vals_keys,
fix_vals_permuted_list, True, False)
Expand Down
3 changes: 2 additions & 1 deletion metplotpy/plots/mpr_plot/mpr_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def _read_input_data(self) -> None:
if not self.input_df:
self.input_df = filtered
else:
self.input_df = self.input_df.append(filtered)
# self.input_df = self.input_df.append(filtered)
self.input_df = pd.concat([self.input_df, filtered])

def _create_figure(self) -> go.Figure:
"""
Expand Down
29 changes: 15 additions & 14 deletions metplotpy/plots/roc_diagram/roc_diagram_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"""
__author__ = 'Minna Win'

import sys

import warnings
import pandas as pd
import re
import metcalcpy.util.ctc_statistics as cstats
Expand Down Expand Up @@ -51,6 +50,8 @@ def _create_series_points(self):


"""
warnings.filterwarnings("error")

# Subset data based on self.all_series_vals that we acquired from the
# config file
input_df = self.input_data
Expand All @@ -74,27 +75,27 @@ def _create_series_points(self):
subset_df = self._add_ctc_columns(subset_df)
df_roc = cstats.calculate_ctc_roc(subset_df, ascending=self.config.ctc_ascending)
pody = df_roc['pody']
pody = pd.Series([1]).append(pody, ignore_index=True)
pody = pody.append(pd.Series([0]), ignore_index=True)
pody = pd.concat([pd.Series([1]), pody], ignore_index=True)
pody = pd.concat([pody, pd.Series([0])], ignore_index=True)
pofd = df_roc['pofd']
pofd = pd.Series([1]).append(pofd, ignore_index=True)
pofd = pofd.append(pd.Series([0]), ignore_index=True)
pofd = pd.concat([pd.Series([1]), pofd], ignore_index=True)
pofd = pd.concat([pofd, pd.Series([0])], ignore_index=True)
thresh = df_roc['thresh']
thresh = pd.Series(['']).append(thresh, ignore_index=True)
thresh = thresh.append(pd.Series(['']), ignore_index=True)
thresh = pd.concat([pd.Series(['']), thresh], ignore_index=True)
thresh = pd.concat([thresh, pd.Series([''])], ignore_index=True)
return pofd, pody, thresh

elif self.config.linetype_pct:
roc_df = pstats._calc_pct_roc(subset_df)
pody = roc_df['pody']
pody = pd.Series([1]).append(pody, ignore_index=True)
pody = pody.append(pd.Series([0]), ignore_index=True)
pody = pd.concat([pd.Series([1]), pody], ignore_index=True)
pody = pd.concat([pody, pd.Series([0])])
pofd = roc_df['pofd']
pofd = pd.Series([1]).append(pofd, ignore_index=True)
pofd = pofd.append(pd.Series([0]), ignore_index=True)
pofd = pd.concat([pd.Series([1]), pofd], ignore_index=True)
pofd = pd.concat([pofd, pd.Series([0])], ignore_index=True)
thresh = roc_df['thresh']
thresh = pd.Series(['']).append(thresh, ignore_index=True)
thresh = thresh.append(pd.Series(['']), ignore_index=True)
thresh = pd.concat([pd.Series(['']),thresh], ignore_index=True)
thresh = pd.concat([thresh, pd.Series([''])], ignore_index=True)
return pofd, pody, thresh
else:
raise ValueError('error neither ctc or pct linetype ')
Expand Down
61 changes: 61 additions & 0 deletions test/roc_diagram/PCT_ROC.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
model i_value thresh_i oy_i on_i fcst_valid_beg fcst_lead
WRF 1 0 351 1027 2005-08-08 00:00:00 1080000
WRF 2 0.1 336 522 2005-08-08 00:00:00 1080000
WRF 3 0.2 225 124 2005-08-08 00:00:00 1080000
WRF 4 0.3 97 16 2005-08-08 00:00:00 1080000
WRF 5 0.4 0 0 2005-08-08 00:00:00 1080000
WRF 6 0.5 0 0 2005-08-08 00:00:00 1080000
WRF 7 0.6 0 0 2005-08-08 00:00:00 1080000
WRF 8 0.7 0 0 2005-08-08 00:00:00 1080000
WRF 9 0.8 0 0 2005-08-08 00:00:00 1080000
WRF 10 0.9 0 0 2005-08-08 00:00:00 1080000
WRF 1 0 29 212 2005-08-08 00:00:00 1080000
WRF 2 0.1 615 1382 2005-08-08 00:00:00 1080000
WRF 3 0.2 544 634 2005-08-08 00:00:00 1080000
WRF 4 0.3 246 140 2005-08-08 00:00:00 1080000
WRF 5 0.4 1 4 2005-08-08 00:00:00 1080000
WRF 6 0.5 0 0 2005-08-08 00:00:00 1080000
WRF 7 0.6 0 0 2005-08-08 00:00:00 1080000
WRF 8 0.7 0 0 2005-08-08 00:00:00 1080000
WRF 9 0.8 0 0 2005-08-08 00:00:00 1080000
WRF 10 0.9 0 0 2005-08-08 00:00:00 1080000
WRF 1 0 351 1027 2005-08-08 00:00:00 1080000
WRF 2 0.1 336 522 2005-08-08 00:00:00 1080000
WRF 3 0.2 225 124 2005-08-08 00:00:00 1080000
WRF 4 0.3 97 16 2005-08-08 00:00:00 1080000
WRF 5 0.4 0 0 2005-08-08 00:00:00 1080000
WRF 6 0.5 0 0 2005-08-08 00:00:00 1080000
WRF 7 0.6 0 0 2005-08-08 00:00:00 1080000
WRF 8 0.7 0 0 2005-08-08 00:00:00 1080000
WRF 9 0.8 0 0 2005-08-08 00:00:00 1080000
WRF 10 0.9 0 0 2005-08-08 00:00:00 1080000
WRF 1 0 29 212 2005-08-08 00:00:00 1080000
WRF 2 0.1 615 1382 2005-08-08 00:00:00 1080000
WRF 3 0.2 544 634 2005-08-08 00:00:00 1080000
WRF 4 0.3 246 140 2005-08-08 00:00:00 1080000
WRF 5 0.4 1 4 2005-08-08 00:00:00 1080000
WRF 6 0.5 0 0 2005-08-08 00:00:00 1080000
WRF 7 0.6 0 0 2005-08-08 00:00:00 1080000
WRF 8 0.7 0 0 2005-08-08 00:00:00 1080000
WRF 9 0.8 0 0 2005-08-08 00:00:00 1080000
WRF 10 0.9 0 0 2005-08-08 00:00:00 1080000
WRF 1 0 351 1027 2005-08-08 00:00:00 1080000
WRF 2 0.1 336 522 2005-08-08 00:00:00 1080000
WRF 3 0.2 225 124 2005-08-08 00:00:00 1080000
WRF 4 0.3 97 16 2005-08-08 00:00:00 1080000
WRF 5 0.4 0 0 2005-08-08 00:00:00 1080000
WRF 6 0.5 0 0 2005-08-08 00:00:00 1080000
WRF 7 0.6 0 0 2005-08-08 00:00:00 1080000
WRF 8 0.7 0 0 2005-08-08 00:00:00 1080000
WRF 9 0.8 0 0 2005-08-08 00:00:00 1080000
WRF 10 0.9 0 0 2005-08-08 00:00:00 1080000
WRF 1 0 29 212 2005-08-08 00:00:00 1080000
WRF 2 0.1 615 1382 2005-08-08 00:00:00 1080000
WRF 3 0.2 544 634 2005-08-08 00:00:00 1080000
WRF 4 0.3 246 140 2005-08-08 00:00:00 1080000
WRF 5 0.4 1 4 2005-08-08 00:00:00 1080000
WRF 6 0.5 0 0 2005-08-08 00:00:00 1080000
WRF 7 0.6 0 0 2005-08-08 00:00:00 1080000
WRF 8 0.7 0 0 2005-08-08 00:00:00 1080000
WRF 9 0.8 0 0 2005-08-08 00:00:00 1080000
WRF 10 0.9 0 0 2005-08-08 00:00:00 1080000
140 changes: 140 additions & 0 deletions test/roc_diagram/PCT_ROC.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
add_point_thresholds: 'True'
alpha: 0.05
box_avg: 'False'
box_boxwex: 0.2
box_notch: 'False'
box_outline: 'True'
box_pts: 'False'
caption_align: 0.0
caption_col: '#333333'
caption_offset: 3.0
caption_size: 0.8
caption_weight: 1
cex: 1
circular_block_bootstrap: 'True'
colors:
- '#ff0000'
con_series:
- 1
create_html: 'True'
derived_series_1: []
derived_series_2: []
dump_points_1: 'False'
dump_points_2: 'False'
event_equal: 'False'
fcst_var_val_1: null
fcst_var_val_2: null
fixed_vars_vals_input: {}
grid_col: '#cccccc'
grid_lty: 3
grid_lwd: 1
grid_on: 'True'
grid_x: listX
indy_label: []
indy_stagger_1: 'False'
indy_stagger_2: 'False'
indy_vals: []
indy_var: ''
legend_box: o
legend_inset:
x: 0.0
y: -0.25
legend_ncol: 3
legend_size: 0.8
line_type: None
list_stat_1: []
list_stat_2: []
mar:
- 8
- 4
- 5
- 4
method: bca
mgp:
- 1
- 1
- 0
num_iterations: 1
num_threads: -1
plot_caption: ''
plot_ci:
- none
plot_disp:
- 'True'
plot_filename: ./PCT_ROC.png
plot_height: 8.5
plot_res: 72
plot_stat: median
plot_type: png16m
plot_units: in
plot_width: 11.0
random_seed: null
reverse_connection_order: 'False'
roc_ctc: false
roc_pct: true
series_line_style:
- '-'
series_line_width:
- 1
series_order:
- 1
series_symbols:
- .
series_type:
- b
series_val_1: {}
series_val_2: {}
show_nstats: 'False'
show_signif:
- 'False'
stat_input: PCT_ROC.data
sync_yaxes: 'False'
title: test title
title_align: 0.5
title_offset: -2
title_size: 1.4
title_weight: 2.0
user_legend: []
variance_inflation_factor: 'False'
vert_plot: 'False'
x2lab_align: 0.5
x2lab_offset: -0.5
x2lab_size: 0.8
x2lab_weight: 1
x2tlab_horiz: 0.5
x2tlab_orient: 1
x2tlab_perp: 1
x2tlab_size: 0.8
xaxis: test x_label
xaxis_reverse: 'False'
xlab_align: 0.5
xlab_offset: 2
xlab_size: 1
xlab_weight: 1
xlim: []
xtlab_decim: 0
xtlab_horiz: 0.5
xtlab_orient: 1
xtlab_perp: -0.75
xtlab_size: 1
y2lab_align: 0.5
y2lab_offset: 1
y2lab_size: 1
y2lab_weight: 1
y2lim: []
y2tlab_horiz: 0.5
y2tlab_orient: 1
y2tlab_perp: 1
y2tlab_size: 1.0
yaxis_1: test y_label
yaxis_2: ''
ylab_align: 0.5
ylab_offset: -2
ylab_size: 1
ylab_weight: 1
ylim: []
ytlab_horiz: 0.5
ytlab_orient: 1
ytlab_perp: 0.5
ytlab_size: 1
37 changes: 37 additions & 0 deletions test/roc_diagram/test_roc_diagram.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import pytest
import os
import pandas as pd
Expand Down Expand Up @@ -246,3 +248,38 @@ def test_images_match(setup):
# Typically when files have already been removed or
# don't exist. Ignore.
pass


def test_pct_plot_exists():
'''
Verify that the ROC diagram is generated
'''

custom_config_filename = "./PCT_ROC.yaml"
output_plot = "./PCT_ROC.png"

print("\n Testing for existence of PCT ROC plot...")
roc.main(custom_config_filename)
assert os.path.isfile(output_plot) == True
os.remove(os.path.join(output_plot))

def test_pct_no_warnings():
'''
Verify that the ROC diagram is generated without FutureWarnings
'''

custom_config_filename = "./PCT_ROC.yaml"
output_plot = "./PCT_ROC.png"

print("\n Testing for FutureWarning..")

try:
roc.main(custom_config_filename)
except FutureWarning:
print("FutureWarning generated")
# FutureWarning generated, test fails
assert False
else:
assert True
os.remove(os.path.join(output_plot))