Ignore:
Timestamp:
Dec 22, 2008, 4:00:06 AM (13 years ago)
Author:
Peter
Message:

refs #470: nni_test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/nni_test.cc

    r1554 r1669  
    7272  std::ifstream control_stream(knni_result.c_str());
    7373  utility::Matrix control(control_stream);
    74   control-=knni.imputed_data();
    75   // error_bound is arbitrarily selected
    76   double error_bound = std::numeric_limits<double>::epsilon()*1e4;
     74  double error_bound = 1e-11;
    7775  for (unsigned int i=0; i<control.rows(); i++)
    7876    for (unsigned int j=0; j<control.columns(); j++)
    79       if (std::abs(control(i,j))>error_bound) {
     77      if (!suite.equal_fix(knni.imputed_data()(i,j),control(i,j),error_bound)) {
    8078        suite.err() << "kNNI FAILED, error on row " << i << " and "
    81                     << "column " << j << " is " << std::abs(control(i,j))
    82                     << ". Expected less than " << error_bound << std::endl;
     79                    << "column " << j << " is" << std::endl;
    8380        suite.add(false); // calculation result out of accepted error bounds
    8481      }
    85       else
    86         if (!((control(i,j)==control(i,j)))) {
    87           suite.err() << "kNNI FAILED, nan (not a number) "
    88                       << "encountered in test on row " << i
    89                       << " and column " << j << std::endl;
    90           suite.add(false); // calucaltion error detected
    91         }
    9282  control_stream.close();
    9383  data_stream.close();
     
    10393  control_stream.open(wenni_result.c_str());
    10494  control=utility::Matrix(control_stream);
    105   control-=wenni.imputed_data();
    10695  for (unsigned int i=0; i<control.rows(); i++)
    10796    for (unsigned int j=0; j<control.columns(); j++)
    108       if (std::abs(control(i,j))>error_bound) {
     97      if (!suite.equal_fix(wenni.imputed_data()(i,j),control(i,j),error_bound)){
    10998        suite.err() << "WeNNI FAILED, error on row " << i << " and "
    110                     << "column " << j << " is " << std::abs(control(i,j))
    111                     << ". Expected less than " << error_bound << std::endl;
     99                    << "column " << j << std::endl;
    112100        suite.add(false); // calculation result out of accepted error bounds
    113101      }
    114       else
    115         if (!((control(i,j)==control(i,j)))) {
    116           suite.err() << "WeNNI FAILED, nan (not a number) "
    117                       << "encountered in test on row " << i
    118                       << " and column " << j << std::endl;
    119           suite.add(false); // calucaltion error detected
    120         }
    121102  control_stream.close();
    122103  data_stream.close();
     
    132113  control_stream.open(knni_result.c_str());
    133114  control=utility::Matrix(control_stream);
    134   control-=wenni2.imputed_data();
    135115  for (unsigned int i=0; i<control.rows(); i++)
    136116    for (unsigned int j=0; j<control.columns(); j++)
    137       if (std::abs(control(i,j))>error_bound) {
     117      if (!suite.equal_fix(wenni2.imputed_data()(i,j),control(i,j),error_bound)){
    138118        suite.err() << "WeNNI binary weight test FAILED.\nError on row " << i
    139                     << " and column " << j << " is " << std::abs(control(i,j))
    140                     << ". Expected less than " << error_bound << std::endl;
     119                    << " and column " << j << std::endl;
    141120        suite.add(false); // calculation result out of accepted error bounds
    142121      }
    143       else
    144         if (!((control(i,j)==control(i,j)))) {
    145           suite.err() << "WeNNI binary wieght test FAILED.\n"
    146                       << "nan (not a number) encountered in test on row " << i
    147                       << " and column " << j << std::endl;
    148           suite.add(false); // calucaltion error detected
    149         }
    150122  control_stream.close();
    151123  data_stream.close();
Note: See TracChangeset for help on using the changeset viewer.