Skip to content

Commit

Permalink
and more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed May 1, 2024
1 parent 10aada1 commit 0b243ca
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions include/timbl/MBLClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ namespace Timbl {
bool writeWeights( std::ostream& ) const;
bool readWeights( std::istream&, WeightType );
bool writeNamesFile( std::ostream& ) const;
bool ShowOptions( std::ostream& ) const;
bool ShowSettings( std::ostream& ) const;
virtual bool ShowOptions( std::ostream& );
virtual bool ShowSettings( std::ostream& );
void writePermutation( std::ostream& ) const;
void LearningInfo( std::ostream& );
virtual ~MBLClass() override;
Expand Down
2 changes: 2 additions & 0 deletions include/timbl/TimblAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ namespace Timbl{
class TimblAPI {
friend class TimblExperiment;
public:
// cppcheck-suppress noExplicitConstructor
TimblAPI( const TiCC::CL_Options&, const std::string& = "" );
// cppcheck-suppress noExplicitConstructor
TimblAPI( const std::string&, const std::string& = "" );
TimblAPI( const TimblAPI& );
~TimblAPI();
Expand Down
31 changes: 19 additions & 12 deletions include/timbl/TimblExperiment.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ namespace Timbl {
bool GetCurrentWeights( std::vector<double>& );
xmlNode *weightsToXML();
nlohmann::json weights_to_JSON();
bool ShowOptions( std::ostream& );
bool ShowSettings( std::ostream& );
bool ShowOptions( std::ostream& ) override;
bool ShowSettings( std::ostream& ) override;
xmlNode *settingsToXML();
nlohmann::json settings_to_JSON() override;
bool showBestNeighbors( std::ostream& ) const;
Expand Down Expand Up @@ -306,6 +306,7 @@ namespace Timbl {

class IB1_Experiment: public TimblExperiment {
public:
// cppcheck-suppress noExplicitConstructor
IB1_Experiment( const size_t N = DEFAULT_MAX_FEATS,
const std::string& s= "",
const bool init = true );
Expand All @@ -330,7 +331,8 @@ namespace Timbl {

class IB2_Experiment: public IB1_Experiment {
public:
IB2_Experiment( size_t N, const std::string& s="" ):
// cppcheck-suppress noExplicitConstructor
IB2_Experiment( size_t N, const std::string& s="" ):
IB1_Experiment( N, s ) {
IB2_offset( 0 );
};
Expand All @@ -351,6 +353,7 @@ namespace Timbl {

class LOO_Experiment: public IB1_Experiment {
public:
// cppcheck-suppress noExplicitConstructor
LOO_Experiment( int N, const std::string& s = "" ):
IB1_Experiment( N, s ) {
};
Expand All @@ -366,6 +369,7 @@ namespace Timbl {

class CV_Experiment: public IB1_Experiment {
public:
// cppcheck-suppress noExplicitConstructor
CV_Experiment( int N = DEFAULT_MAX_FEATS, const std::string& s = "" ):
IB1_Experiment( N, s ), CV_fileW(Unknown_w) { };
CV_Experiment( const CV_Experiment& ) = delete; // forbid copies
Expand All @@ -392,9 +396,10 @@ namespace Timbl {

class TRIBL_Experiment: public TimblExperiment {
public:
TRIBL_Experiment( const size_t N = DEFAULT_MAX_FEATS,
const std::string& s = "",
const bool init = true ):
// cppcheck-suppress noExplicitConstructor
TRIBL_Experiment( const size_t N = DEFAULT_MAX_FEATS,
const std::string& s = "",
const bool init = true ):
TimblExperiment( TRIBL_a, s ) {
if ( init ) init_options_table( N );
};
Expand All @@ -415,9 +420,10 @@ namespace Timbl {

class TRIBL2_Experiment: public TimblExperiment {
public:
TRIBL2_Experiment( const size_t N = DEFAULT_MAX_FEATS,
const std::string& s = "",
const bool init = true ):
// cppcheck-suppress noExplicitConstructor
TRIBL2_Experiment( const size_t N = DEFAULT_MAX_FEATS,
const std::string& s = "",
const bool init = true ):
TimblExperiment( TRIBL2_a, s ) {
if ( init ) init_options_table( N );
};
Expand All @@ -437,9 +443,10 @@ namespace Timbl {

class IG_Experiment: public TimblExperiment {
public:
IG_Experiment( const size_t N = DEFAULT_MAX_FEATS,
const std::string& s = "",
const bool init = true ):
// cppcheck-suppress noExplicitConstructor
IG_Experiment( const size_t N = DEFAULT_MAX_FEATS,
const std::string& s = "",
const bool init = true ):
TimblExperiment( IGTREE_a, s ) {
if ( init ) init_options_table( N );
};
Expand Down
8 changes: 4 additions & 4 deletions src/MBLClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,14 @@ namespace Timbl {
}
}

bool MBLClass::ShowOptions( ostream& os ) const {
bool MBLClass::ShowOptions( ostream& os ) {
os << "Possible Experiment Settings (current value between []):" << endl;
Options.Show_Options( os );
os << endl;
return true;
}

bool MBLClass::ShowSettings( ostream& os ) const{
bool MBLClass::ShowSettings( ostream& os ) {
os << "Current Experiment Settings :" << endl;
Options.Show_Settings( os );
os << endl;
Expand Down Expand Up @@ -975,7 +975,7 @@ namespace Timbl {

bool MBLClass::allocate_arrays(){
size_t Dim = targets.values_array.size();
for ( const auto& feat : features.feats ){
for ( auto *feat : features.feats ){
if ( !feat->Ignore() &&
!feat->isNumerical() ) {
if ( !feat->AllocSparseArrays( Dim ) ){
Expand Down Expand Up @@ -1541,7 +1541,7 @@ namespace Timbl {
double Entropy = 0.0;
// first get the Database Entropy
size_t totval = targets.TotalValues();
for ( const auto& it : targets.values_array ){
for ( const auto *it : targets.values_array ){
double Ratio = it->ValFreq() / (double)totval;
if ( Ratio > 0 ){
Entropy += Ratio * Log2(Ratio);
Expand Down

0 comments on commit 0b243ca

Please sign in to comment.