Changeset 1075


Ignore:
Timestamp:
Feb 12, 2008, 1:55:31 PM (13 years ago)
Author:
Markus Ringnér
Message:

Fixed bug in test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/ncc_test.cc

    r1052 r1075  
    8686  // A test of predictions using unweighted data
    8787  /////////////////////////////////////////////
     88  *error << "test of predictions using unweighted test data\n";
    8889  utility::matrix data1(3,4);
    8990  for(size_t i=0;i<3;i++) {
     
    119120  // A test of predictions using unweighted training and weighted test data
    120121  //////////////////////////////////////////////////////////////////////////
     122  *error << "test of predictions using unweighted training and weighted test data\n";
    121123  utility::matrix weights1(3,4,1.0);
    122124  weights1(0,0)=weights1(1,1)=weights1(2,2)=weights1(1,3)=0.0;
     
    137139  // A test of predictions using Sorlie data
    138140  //////////////////////////////////////////////////////////////////////////
     141  *error << "test with Sorlie data\n";
    139142  std::ifstream is("data/sorlie_centroid_data.txt");
    140143  utility::matrix data(is,'\t');
     
    150153     
    151154  classifier::MatrixLookupWeighted dataviewweighted(data,weights);
    152   classifier::NCC<statistics::EuclideanDistance> ncc(dataviewweighted,targets);
     155  classifier::NCC<statistics::PearsonDistance> ncc(dataviewweighted,targets);
    153156  *error << "training...\n";
    154157  ncc.train();
     
    200203  classifier::Kernel_MEV kernel(ml,kf);
    201204  classifier::DataLookup2D* dl_kernel = new classifier::KernelLookup(kernel);
     205  bool catch_error=false;
    202206  try {
    203     ok=0; // should catch error here
     207    catch_error=false; // should catch error here
    204208    *error << ncc.make_classifier(*dl_kernel,target) << std::endl;
    205209  }
    206210  catch (std::runtime_error) {   
    207211    *error << "caught expected bad cast runtime_error" << std::endl;
    208     ok=1;
     212    catch_error=true;
     213  }
     214  if(!catch_error) {
     215    ok=false;
    209216  }
    210217  try {
    211     ok=0; // should catch error here
     218    catch_error=false; // should catch error here
    212219    ncc.predict(*dl_kernel,prediction);
    213220  }
    214221  catch (std::runtime_error) {   
    215222    *error << "caught expected bad cast runtime_error" << std::endl;
    216     ok=1;
     223    catch_error=true;
     224  }
     225  if(!catch_error) {
     226    ok=false;
    217227  }
    218228  delete dl_kernel;
     
    220230  if(ok)
    221231    *error << "OK" << std::endl;
     232  else
     233    *error << "FAILED" << std::endl;
    222234
    223235  if (error!=&std::cerr)
Note: See TracChangeset for help on using the changeset viewer.