Changeset 1784


Ignore:
Timestamp:
Feb 8, 2009, 6:58:03 PM (11 years ago)
Author:
Peter
Message:

refs #478. Added test with weighted target, and made 'missing values' to be nan in tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/normalization_test.cc

    r1778 r1784  
    3737#include "yat/utility/WeightIterator.h"
    3838
     39#include <climits>
    3940#include <fstream>
    4041#include <limits>
     
    205206  suite.err() << "Testing with missing value in source\n";
    206207  // adding a missing value
    207   src_w.insert(src_w.begin(), DataWeight(5.2, 0.0));
     208  src_w.insert(src_w.begin(),
     209               DataWeight(std::numeric_limits<double>::quiet_NaN(), 0.0));
    208210  std::vector<utility::DataWeight> result_w2(src_w.size());
    209211  qQN(src_w.begin(), src_w.end(), result_w2.begin());
    210212  // excluding missing value (result_w[0])
    211213  suite.add(suite.equal_range(utility::data_iterator(result_w.begin()),
    212                                utility::data_iterator(result_w.end()),
    213                                ++utility::data_iterator(result_w2.begin())));
     214                              utility::data_iterator(result_w.end()),
     215                              ++utility::data_iterator(result_w2.begin())));
     216
     217  suite.err() << "testing with weighted target" << std::endl;
     218  std::vector<utility::DataWeight> target_w(target.size()+1, DataWeight(0, 1));
     219  target_w[0] = DataWeight(5.3, 0);
     220  std::copy(target.begin(), target.end(),
     221            utility::data_iterator(target_w.begin()+1));
     222  qQuantileNormalizer qQNw(target_w.begin(), target_w.end(), 4);
     223  std::vector<utility::DataWeight> result_w3(src_w.size());
     224  qQNw(src_w.begin(), src_w.end(), result_w3.begin());
     225  suite.add(suite.equal_range(++utility::data_iterator(result_w3.begin()),
     226                              utility::data_iterator(result_w3.end()),
     227                              ++utility::data_iterator(result_w2.begin())));
     228 
    214229}
    215230
Note: See TracChangeset for help on using the changeset viewer.