Skip to content

Commit

Permalink
Per issue #2425, moved setup_stat_file to TCStatJobRIRW class. SL ci-…
Browse files Browse the repository at this point in the history
…skip-all
  • Loading branch information
Seth Linden committed Apr 11, 2023
1 parent 557b855 commit 5a7979a
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 122 deletions.
236 changes: 115 additions & 121 deletions src/tools/tc_utils/tc_stat/tc_stat_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1201,127 +1201,6 @@ void TCStatJob::close_stat_file() {
return;
}

////////////////////////////////////////////////////////////////////////

void TCStatJob::setup_stat_file(int n_row, int n) {
STATLineType cur_lt, out_lt;
StringArray out_sa;
int i, c, n_col;

//
// Nothing to do if no output STAT file stream is defined
//
if(!StatOut) return;

//
// Check for a single output line type
//
//out_sa = (OutLineType.n() > 0 ?
// OutLineType : LineType);

// SL
out_sa = LineType;

out_lt = (out_sa.n() == 1 ?
string_to_statlinetype(out_sa[0].c_str()) : no_stat_line_type);

//
// Loop through the output line types and determine the number of
// output columns
//
for(i=0, c=0, n_col=0; i<out_sa.n(); i++) {
cur_lt = string_to_statlinetype(out_sa[i].c_str());
switch(cur_lt) {
case stat_ctc: c = n_ctc_columns; break;
case stat_cts: c = n_cts_columns; break;
default:
mlog << Error << "\nSTATAnalysisJob::setup_stat_file() -> "
<< "unexpected stat line type \"" << statlinetype_to_string(cur_lt)
<< "\"!\n\n";
exit(1);
}
if(c > n_col) n_col = c;
}

//
// Add the header columns
//
n_col += n_header_columns;

//
// Create table from scratch
//
if(stat_row == 0) {

//
// Multiply the number of rows by the number of
// output line types to avoid resizing later
//
n_row *= max(1, out_sa.n());

//
// Setup the STAT table
//
stat_at.set_size(n_row, n_col);
justify_stat_cols(stat_at);
stat_at.set_precision(Precision);
stat_at.set_bad_data_value(bad_data_double);
stat_at.set_bad_data_str(na_str);
stat_at.set_delete_trailing_blank_rows(1);

//
// Write the STAT header row
//
switch(out_lt) {
case stat_ctc: write_header_row (ctc_columns, n_ctc_columns, 1, stat_at, 0, 0); break;
case stat_cts: write_header_row (cts_columns, n_cts_columns, 1, stat_at, 0, 0); break;

//
// Write only header columns for unspecified line type
//
case no_stat_line_type:
write_header_row ((const char **) 0, 0, 1, stat_at, 0, 0); break;

default:
mlog << Error << "\nSTATAnalysisJob::setup_stat_file() -> "
<< "unexpected stat line type \"" << statlinetype_to_string(out_lt)
<< "\"!\n\n";
exit(1);
}
//
// Increment row counter
//
stat_row++;
}
//
// Expand the table, if needed
//
else {

//
// Determine the required dimensions
//
int need_rows = max(stat_at.nrows(), stat_row + n_row);
int need_cols = max(stat_at.ncols(), n_col);

if(need_rows > stat_at.nrows() || need_cols > stat_at.ncols()) {

//
// Resize the STAT table
//
stat_at.expand(need_rows, need_cols);
justify_stat_cols(stat_at);
stat_at.set_precision(Precision);
stat_at.set_bad_data_value(bad_data_double);
stat_at.set_bad_data_str(na_str);
stat_at.set_delete_trailing_blank_rows(1);
}
}

return;
}


////////////////////////////////////////////////////////////////////////

void TCStatJob::dump_pair(const TrackPairInfo &pair, ofstream *out) {
Expand Down Expand Up @@ -3763,6 +3642,121 @@ void TCStatJobRIRW::do_mpr_output(ostream &out) {
return;
}

////////////////////////////////////////////////////////////////////////

void TCStatJobRIRW::setup_stat_file(int n_row, int n) {
STATLineType cur_lt, out_lt;
StringArray out_sa;
int i, c, n_col;

//
// Nothing to do if no output STAT file stream is defined
//
if(!StatOut) return;

//
// Check for a single output line type
//
out_sa = (OutLineType.n() > 0 ?
OutLineType : LineType);

out_lt = (out_sa.n() == 1 ?
string_to_statlinetype(out_sa[0].c_str()) : no_stat_line_type);

//
// Loop through the output line types and determine the number of
// output columns
//
for(i=0, c=0, n_col=0; i<out_sa.n(); i++) {
cur_lt = string_to_statlinetype(out_sa[i].c_str());
switch(cur_lt) {
case stat_ctc: c = n_ctc_columns; break;
case stat_cts: c = n_cts_columns; break;
case stat_mpr: c = n_mpr_columns; break;
default:
mlog << Error << "\nSTATAnalysisJob::setup_stat_file() -> "
<< "unexpected stat line type \"" << statlinetype_to_string(cur_lt)
<< "\"!\n\n";
exit(1);
}
if(c > n_col) n_col = c;
}

//
// Add the header columns
//
n_col += n_header_columns;

//
// Create table from scratch
//
if(stat_row == 0) {

//
// Multiply the number of rows by the number of
// output line types to avoid resizing later
//
n_row *= max(1, out_sa.n());

//
// Setup the STAT table
//
stat_at.set_size(n_row, n_col);
justify_stat_cols(stat_at);
stat_at.set_precision(Precision);
stat_at.set_bad_data_value(bad_data_double);
stat_at.set_bad_data_str(na_str);
stat_at.set_delete_trailing_blank_rows(1);

//
// Write the STAT header row
//
switch(out_lt) {
case stat_ctc: write_header_row (ctc_columns, n_ctc_columns, 1, stat_at, 0, 0); break;
case stat_cts: write_header_row (cts_columns, n_cts_columns, 1, stat_at, 0, 0); break;
case stat_mpr: write_header_row (mpr_columns, n_mpr_columns, 1, stat_at, 0, 0); break;
// Write only header columns for unspecified line type
case no_stat_line_type:
write_header_row ((const char **) 0, 0, 1, stat_at, 0, 0); break;

default:
mlog << Error << "\nSTATAnalysisJob::setup_stat_file() -> "
<< "unexpected stat line type \"" << statlinetype_to_string(out_lt)
<< "\"!\n\n";
exit(1);
}
//
// Increment row counter
//
stat_row++;
}
//
// Expand the table, if needed
//
else {

//
// Determine the required dimensions
//
int need_rows = max(stat_at.nrows(), stat_row + n_row);
int need_cols = max(stat_at.ncols(), n_col);

if(need_rows > stat_at.nrows() || need_cols > stat_at.ncols()) {

//
// Resize the STAT table
//
stat_at.expand(need_rows, need_cols);
justify_stat_cols(stat_at);
stat_at.set_precision(Precision);
stat_at.set_bad_data_value(bad_data_double);
stat_at.set_bad_data_str(na_str);
stat_at.set_delete_trailing_blank_rows(1);
}
}

return;
}

////////////////////////////////////////////////////////////////////////

Expand Down
3 changes: 2 additions & 1 deletion src/tools/tc_utils/tc_stat/tc_stat_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ class TCStatJob {
void close_dump_file();

void open_stat_file();
void setup_stat_file(int n_row, int n);
void close_stat_file();

void dump_pair(const TrackPairInfo &, std::ofstream *);
Expand Down Expand Up @@ -489,6 +488,8 @@ class TCStatJobRIRW : public TCStatJob {

void add_map(std::map<ConcatString,RIRWMapData,cs_cmp>&);

void setup_stat_file(int n_row, int n);

void do_output (std::ostream &);
void do_ctc_output (std::ostream &);
void do_cts_output (std::ostream &);
Expand Down

0 comments on commit 5a7979a

Please sign in to comment.