Changeset 1947


Ignore:
Timestamp:
May 6, 2009, 4:23:51 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #535. NaNs? are replaced with Inf in sorting in qQuantileNormalizer.

Location:
branches/0.5-stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/0.5-stable/test/Makefile.am

    r1943 r1947  
    77# Copyright (C) 2005 Jari Häkkinen, Peter Johansson
    88# Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
    9 # Copyright (C) 2009 Peter Johansson
     9# Copyright (C) 2009 Jari Häkkinen, Peter Johansson
    1010#
    1111# This file is part of the yat library, http://dev.thep.lu.se/yat
     
    6565
    6666# tests not passing through yet
    67 XFAIL_TESTS = normalization_test
     67XFAIL_TESTS =
    6868
    6969TESTS += documentation_test.sh
  • branches/0.5-stable/yat/normalizer/qQuantileNormalizer.h

    r1944 r1947  
    261261
    262262    std::vector<size_t> sorted_index(last-first);
    263     utility::sort_index(first, last, sorted_index);
     263    // Code to avoid problems with NaN (ticket:535)
     264    // utility::sort_index(first, last, sorted_index);
     265    // ... above statement replaced below code block
     266    {
     267      utility::Vector vec(std::distance(first, last));
     268      std::copy(first, last, vec.begin());
     269      for (utility::Vector::iterator i(vec.begin()); i!=vec.end(); ++i)
     270        if (std::isnan((*i)))
     271          *i = std::numeric_limits<double>::infinity();
     272      utility::sort_index(vec.begin(), vec.end(), sorted_index);
     273    }
     274    // end Code to avoid problems with NaN (ticket:535)
    264275
    265276    utility::Vector diff(source.averages());
     
    322333
    323334    std::vector<size_t> sorted_index(last-first);
    324     utility::sort_index(utility::data_iterator(first),
    325                         utility::data_iterator(last), sorted_index);
     335    // Code to avoid problems with NaN (ticket:535)
     336    // utility::sort_index(utility::data_iterator(first),
     337    //                     utility::data_iterator(last), sorted_index);
     338    // ... above statement replaced below code block
     339    {
     340      using namespace utility;
     341      std::vector<DataWeight> vec;
     342      vec.reserve(std::distance(first, last));
     343      std::back_insert_iterator<std::vector<DataWeight> > inserter(vec);
     344      std::copy(first, last, inserter);
     345      for (std::vector<DataWeight>::iterator i(vec.begin()); i!=vec.end(); ++i)
     346        if (std::isnan((i->data())))
     347          i->data() = std::numeric_limits<double>::infinity();
     348      utility::sort_index(utility::data_iterator(vec.begin()),
     349                          utility::data_iterator(vec.end()), sorted_index);
     350    }
     351    // end Code to avoid problems with NaN (ticket:535)
    326352
    327353    utility::Vector diff(source.averages());
     
    377403    utility::Vector vec(std::distance(first, last));
    378404    std::copy(first, last, vec.begin());
     405    // Code to avoid problems with NaN (ticket:535)
     406    for (utility::Vector::iterator i(vec.begin()); i!=vec.end(); ++i)
     407      if (std::isnan((*i)))
     408        *i = std::numeric_limits<double>::infinity();
     409    // end Code to avoid problems with NaN (ticket:535)
    379410    std::sort(vec.begin(), vec.end());
    380411    init(vec, N);
     
    388419                                               utility::weighted_iterator_tag)
    389420  {
    390     std::vector<utility::DataWeight> vec;
     421    using namespace utility;
     422    std::vector<DataWeight> vec;
    391423    vec.reserve(std::distance(first, last));
    392     std::back_insert_iterator<std::vector<utility::DataWeight> > inserter(vec);
     424    std::back_insert_iterator<std::vector<DataWeight> > inserter(vec);
    393425    std::copy(first, last, inserter);
     426    // Code to avoid problems with NaN (ticket:535)
     427    for (std::vector<DataWeight>::iterator i(vec.begin()); i!=vec.end(); ++i)
     428      if (std::isnan((i->data())))
     429        i->data() = std::numeric_limits<double>::infinity();
     430    // end Code to avoid problems with NaN (ticket:535)
    394431    std::sort(vec.begin(), vec.end());
    395432    init(vec, N);
Note: See TracChangeset for help on using the changeset viewer.