Skip to content
Snippets Groups Projects
Commit e02aaba0 authored by Ludovic Hussonnois's avatar Ludovic Hussonnois
Browse files

REFAC: Remove some copy/paste, and change convention name.

parent 474676f1
Branches
Tags
No related merge requests found
...@@ -217,7 +217,7 @@ private: ...@@ -217,7 +217,7 @@ private:
{ {
std::ofstream outFile; std::ofstream outFile;
outFile.open( this->GetParameterString( "out" ).c_str() ); outFile.open( this->GetParameterString( "out" ).c_str() );
outFile << contingencyTable->to_csv(); outFile << contingencyTable->ToCsv();
outFile.close(); outFile.close();
} }
......
...@@ -113,7 +113,7 @@ protected: ...@@ -113,7 +113,7 @@ protected:
// Write contingency table // Write contingency table
std::ofstream outFile; std::ofstream outFile;
outFile.open( this->GetParameterString( "io.confmatout" ).c_str() ); outFile.open( this->GetParameterString( "io.confmatout" ).c_str() );
outFile << table->to_csv(); outFile << table->ToCsv();
} }
} }
......
...@@ -66,23 +66,8 @@ public: ...@@ -66,23 +66,8 @@ public:
// Retrieve the maximal width from the matrix and the labels // Retrieve the maximal width from the matrix and the labels
size_t maxWidth = 6; size_t maxWidth = 6;
for( size_t i = 0; i << contingencyTable.m_ProdLabels.size(); ++i ) maxWidth = GetLabelsMaximumLength(contingencyTable.m_ProdLabels, maxWidth);
{ maxWidth = GetLabelsMaximumLength(contingencyTable.m_RefLabels, maxWidth);
std::ostringstream oss;
oss << contingencyTable.m_ProdLabels[i];
size_t length = oss.str().length();
if( length > maxWidth )
maxWidth = length;
}
for( size_t i = 0; i << contingencyTable.m_RefLabels.size(); ++i )
{
std::ostringstream oss;
oss << contingencyTable.m_RefLabels[i];
size_t length = oss.str().length();
if( length > maxWidth )
maxWidth = length;
}
for( unsigned int i = 0; i < contingencyTable.matrix.Rows(); ++i ) for( unsigned int i = 0; i < contingencyTable.matrix.Rows(); ++i )
{ {
...@@ -120,7 +105,7 @@ public: ...@@ -120,7 +105,7 @@ public:
return o; return o;
} }
std::string to_csv() const std::string ToCsv() const
{ {
const char separator = ','; const char separator = ',';
...@@ -162,6 +147,20 @@ private: ...@@ -162,6 +147,20 @@ private:
ContingencyTable(const Self &); //purposely not implemented ContingencyTable(const Self &); //purposely not implemented
void operator=(const Self &); //purposely not implemented void operator=(const Self &); //purposely not implemented
static size_t GetLabelsMaximumLength(const LabelList& labels, size_t maxWidth)
{
size_t tmpMaxWidth = maxWidth;
for( size_t i = 0; i < labels.size(); ++i )
{
std::ostringstream oss;
oss << labels[i];
size_t length = oss.str().length();
if( length > tmpMaxWidth )
tmpMaxWidth = length;
}
return tmpMaxWidth;
}
LabelList m_RefLabels; LabelList m_RefLabels;
LabelList m_ProdLabels; LabelList m_ProdLabels;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment