Skip to content

Commit

Permalink
Per #2542 develop gheidke (#2543)
Browse files Browse the repository at this point in the history
* Per #2542, in the ContingencyTable class, update gheidke(), gheidke_ec(), gkuiper(), and gerrity() to return bad data for empty contingency tables rather than erroring out.

* Per #2542, modify TC-Stat config file job number 8 that was added for #2425 by adding the  option. That produces output for both the AHWI and BCLP model names. The BCLP contingency table is empty which triggers this runtime error. Tweaking this newly added tests and confirming that it now runs without error demonstrate the fix.
  • Loading branch information
JohnHalleyGotway authored May 15, 2023
1 parent bfae0e4 commit caf4bd7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
2 changes: 1 addition & 1 deletion internal/test_unit/config/TCStatConfig_ALAL2010
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs = [
"-job filter -amodel AHWI -rirw_track BDECK -rirw_thresh <=-30 -rirw_exact TRUE -dump_row ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_AHWI_rw.tcst",
"-job rirw -rirw_window 00 -rirw_thresh <=-15 -out_line_type CTC,CTS,MPR",
"-job rirw -rirw_window 12 -rirw_thresh <=-15 -out_line_type CTC,CTS,MPR",
"-job rirw -rirw_window 12 -rirw_thresh <=-15 -out_line_type CTC,CTS -out_stat ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_rirw.stat"
"-job rirw -rirw_window 12 -rirw_thresh <=-15 -out_line_type CTC,CTS -by amodel -out_stat ${MET_TEST_OUTPUT}/tc_stat/ALAL2010_rirw.stat"
];

//
Expand Down
44 changes: 16 additions & 28 deletions src/libcode/vx_statistics/contable_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -811,14 +811,11 @@ if ( Nrows != Ncols ) {

const int N = total();

if ( N == 0 ) {

mlog << Error << "\nContingencyTable::gheidke() -> "
<< "table empty!\n\n";

exit ( 1 );
//
// MET #2542: return bad data for empty tables rather than erroring out
//

}
if ( N == 0 ) return ( bad_data_double );

const double DN = (double) N;
int j, k, m, n;
Expand Down Expand Up @@ -912,14 +909,11 @@ if ( ec_value < 0.0 || ec_value >= 1.0 ) {

const int N = total();

if ( N == 0 ) {

mlog << Error << "\nContingencyTable::gheidke_ec(double) -> "
<< "table empty!\n\n";

exit ( 1 );
//
// MET #2542: return bad data for empty tables rather than erroring out
//

}
if ( N == 0 ) return ( bad_data_double );

int j, sum;
double num, denom, ans;
Expand Down Expand Up @@ -977,14 +971,11 @@ if ( Nrows != Ncols ) {

const int N = total();

if ( N == 0 ) {

mlog << Error << "\nContingencyTable::gkuiper() -> "
<< "table empty!\n\n";

exit ( 1 );
//
// MET #2542: return bad data for empty tables rather than erroring out
//

}
if ( N == 0 ) return ( bad_data_double );

const double DN = (double) N;
int j, k, m, n;
Expand Down Expand Up @@ -1077,14 +1068,11 @@ if ( Nrows != Ncols ) {

const int N = total();

if ( N == 0 ) {

mlog << Error << "\nContingencyTable::gerrity() -> "
<< "table empty!\n\n";

exit ( 1 );
//
// MET #2542: return bad data for empty tables rather than erroring out
//

}
if ( N == 0 ) return ( bad_data_double );

int j, k, m, n;
const double DN = (double) N;
Expand Down

0 comments on commit caf4bd7

Please sign in to comment.