Changeset 1874


Ignore:
Timestamp:
Mar 17, 2009, 11:09:01 PM (13 years ago)
Author:
Peter
Message:

merge patch release 0.5.2 into trunk. Delta 0.5.2 - 0.5.1

Location:
trunk
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r1863 r1874  
    99  A complete list of closed tickets can be found here [[br]]
    1010  http://dev.thep.lu.se/yat/query?status=closed&milestone=yat+0.6
     11
     12Version 0.5.2 (released 17 March 2009)
     13
     14  - fixed compilation error in IGP (issue #503)
     15  - fixed incorrect error message from CommandLine (issue #508)
     16
     17  A complete list of closed tickets can be found here [[br]]
     18  http://dev.thep.lu.se/yat/query?status=closed&milestone=yat+0.5.2
    1119
    1220Version 0.5.1 (released 26 February 2009)
  • trunk/build_support/svn_support.am

    r1804 r1874  
    6868  esac
    6969
     70version-check:
     71  @case `sed 200q $(srcdir)/m4/version.m4` in \
     72  *yat-$(VERSION)*$(YAT_LT_VERSION)*);; \
     73  *) \
     74    echo "version.m4: YAT_LT_VERSION not updated;" 1>&2;\
     75    echo "  expected to find 'yat-$(VERSION)  $(YAT_LT_VERSION)'" 1>&2;\
     76    echo "  not releasing" 1>&2;\
     77    exit 1;; \
     78  esac
     79
    7080# check that wc is updated and pristine
    7181svn-check:
     
    7787  fi
    7888
    79 release: svn-check news-check maintainer-check
     89release: svn-check news-check version-check maintainer-check
    8090  md5sum $(distdir).tar.gz > $(distdir).tar.gz.MD5
  • trunk/m4/version.m4

    r1840 r1874  
    5656# yat-0.5    1:2:0*
    5757# yat-0.5.1  2:0:0
     58# yat-0.5.2  2:1:0
    5859#
    5960m4_define([YAT_LT_VERSION_INFO], [3:0:0])
  • trunk/test/Makefile.am

    r1861 r1874  
    5252  data_weight_test data_weight_proxy_test distance_test \
    5353  ensemble_test feature_selection_test fileutil_test \
    54   fisher_test index_test inputranker_test interpolation_test \
     54  fisher_test igp_test index_test inputranker_test interpolation_test \
    5555  iterator_test kernel_lookup_test kernel_test \
    5656  knn_test kolmogorov_smirnov_test large_file_test matrix_lookup_test \
     
    9797fileutil_test_SOURCES = fileutil_test.cc
    9898fisher_test_SOURCES = fisher_test.cc
     99igp_test_SOURCES = igp_test.cc
    99100index_test_SOURCES = index_test.cc
    100101inputranker_test_SOURCES = inputranker_test.cc
  • trunk/test/commandline_test.cc

    r1634 r1874  
    33/*
    44  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    56
    67  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3637bool test_switch(yat::test::Suite& error);
    3738bool test_arg(yat::test::Suite& error);
     39void test_exception_msg(yat::test::Suite& error);
    3840bool test_file(yat::test::Suite& error);
    3941bool test_failures(yat::test::Suite& error);
     
    5658    suite.add(test_option_name_clash(suite));
    5759    suite.add(test_free_arg(suite));
     60    test_exception_msg(suite);
    5861  }
    5962  catch (std::runtime_error& e) {
     
    8689}
    8790
     91
     92void test_exception_msg(yat::test::Suite& suite)
     93{
     94  // test for ticket 508
     95  using namespace theplu::yat::utility;
     96  CommandLine cmd;
     97  OptionHelp help(cmd, "h,help", "");
     98  OptionFile indata(cmd, "i,in", "input file", true, true,"r");
     99  OptionSwitch cmd_memory(cmd, "m", "transpose in a memory cheap manner");
     100  OptionArg<size_t> cmd_n(cmd, "n", "number of rows to print in each iteration");
     101  OptionSwitch cmd_numeric(cmd, "numeric",
     102                                         "input is a numeric matrix");
     103  OptionFile outdata(cmd, "o,out", "output file",true, false,"w");
     104  OptionSwitch verbose(cmd, "v,verbose", "display progress");
     105  int ac = 2;
     106  char* av[] = { "test_prog", "--haha" };
     107  try {
     108    cmd.parse(ac,av);
     109  }
     110  catch (std::runtime_error& e) {
     111    std::string msg(e.what());
     112    if (msg.size()<15) {
     113      suite.xadd(false);
     114      suite.err() << "Error: short exception message\n"
     115                  << "  exception message is: `" << msg
     116                  << "' that is " << msg.size() << " characters long.\n"
     117                  << "  expected at least 15 characters\n";
     118    }
     119  }
     120}
     121
     122
    88123bool test_switch(yat::test::Suite& suite)
    89124{
  • trunk/yat/classifier/IGP.h

    r1858 r1874  
    2525*/
    2626
    27 #include "DataLookup1D.h"
    2827#include "MatrixLookup.h"
    2928#include "Target.h"
     
    120119      size_t neighbor=i;
    121120      double mindist=std::numeric_limits<double>::max();
    122       const DataLookup1D a(matrix_,i,false);
    123121      for(size_t j=0; j<target_.size(); j++) {           
    124         DataLookup1D b(matrix_,j,false);
    125         double dist=distance_(a.begin, a.end(), b.begin());
    126         if(j!=i && dist<mindist) {
     122        if (i==j) // avoid self-self comparison
     123          continue;
     124        double dist = distance_(matrix_.begin_column(i), matrix_.end_column(i),
     125                                matrix_.begin_column(j));
     126        if(dist<mindist) {
    127127          mindist=dist;
    128128          neighbor=j;
  • trunk/yat/statistics/KolmogorovSmirnov.h

    r1797 r1874  
    159159       Same as score() but keeping the sign, in other words,
    160160       abs(signed_score())==score()
     161
     162       A positive score implies that values in class \c true \em on
     163       \em average are smaller than values in class \c false.
    161164
    162165       \since New in yat 0.5
  • trunk/yat/statistics/utility.h

    r1835 r1874  
    4848
    4949  /**
    50      \brief 50th percentile
    51      @see Percentiler
    52   */
    53   template <class T>
    54   double median(T first, T last, const bool sorted=false);
    55 
    56   /**
    57      \see Percentiler
    58   */
    59   template <class T>
    60   double percentile(T first, T last, double p, bool sorted=false) YAT_DEPRECATE;
    61  
    62   /**
    6350     Adding a range [\a first, \a last) into an object of type T. The
    6451     requirements for the type T is to have an add(double, bool, double)
     
    6754  template <typename T, typename ForwardIterator>
    6855  void add(T& o, ForwardIterator first, ForwardIterator last,
    69            const classifier::Target& target)
    70   {
    71     for (size_t i=0; first!=last; ++i, ++first)
    72       o.add(utility::iterator_traits<ForwardIterator>().data(first),
    73             target.binary(i),
    74             utility::iterator_traits<ForwardIterator>().weight(first));
    75   }
     56           const classifier::Target& target);
    7657
    7758  ///
     
    123104  ///
    124105  template <class T>
     106  double mad(T first, T last, const bool sorted=false);
     107
     108
     109  ///
     110  /// Median is defined to be value in the middle. If number of values
     111  /// is even median is the average of the two middle values.  the
     112  /// median value is given by p equal to 50. If \a sorted is false
     113  /// (default), the range is copied, the copy is sorted, and then
     114  /// used to calculate the median.
     115  ///
     116  /// Function is a non-mutable function, i.e., \a first and \a last
     117  /// can be const_iterators.
     118  ///
     119  /// Requirements: T should be an iterator over a range of doubles (or
     120  /// any type being convertable to double).
     121  ///
     122  /// @return median of range
     123  ///
     124  template <class T>
     125  double median(T first, T last, const bool sorted=false);
     126
     127
     128  /**
     129     The percentile is determined by the \a p, a number between 0 and
     130     100. The percentile is found by interpolation, using the formula
     131     \f$ percentile = (1 - \delta) x_i + \delta x_{i+1} \f$ where \a
     132     p is floor\f$((n - 1)p/100)\f$ and \f$ \delta \f$ is \f$
     133     (n-1)p/100 - i \f$.Thus the minimum value of the vector is given
     134     by p equal to zero, the maximum is given by p equal to 100 and
     135     the median value is given by p equal to 50. If @a sorted
     136     is false (default), the vector is copied, the copy is sorted,
     137     and then used to calculate the median.
     138
     139     Function is a non-mutable function, i.e., \a first and \a last
     140     can be const_iterators.
     141     
     142     Requirements: RandomAccessIterator is an iterator over a range of
     143     doubles (or any type being convertable to double).
     144     
     145     @return \a p'th percentile of range
     146
     147     \deprecated percentile2 will replace this function in the future
     148
     149     \note the definition of percentile used here is not identical to
     150     that one used in percentile2 and Percentile. The difference is
     151     smaller for large ranges.
     152  */
     153  template <class RandomAccessIterator>
     154  double percentile(RandomAccessIterator first, RandomAccessIterator last,
     155                    double p, bool sorted=false) YAT_DEPRECATE;
     156 
     157
     158  /**
     159     \see Percentiler
     160     
     161     \since new in yat 0.5
     162   */
     163  template <class RandomAccessIterator>
     164  double percentile2(RandomAccessIterator first, RandomAccessIterator last,
     165                     double p, bool sorted=false)
     166  {
     167    Percentiler percentiler(p, sorted);
     168    return percentiler(first, last);
     169  }
     170
     171  ///
     172  /// @brief Computes the skewness of the data in a vector.
     173  ///
     174  /// The skewness measures the asymmetry of the tails of a
     175  /// distribution.
     176  ///
     177  double skewness(const utility::VectorBase&);
     178 
     179
     180  //////// template implementations ///////////
     181
     182  template <typename T, typename ForwardIterator>
     183  void add(T& o, ForwardIterator first, ForwardIterator last,
     184           const classifier::Target& target)
     185  {
     186    for (size_t i=0; first!=last; ++i, ++first)
     187      o.add(utility::iterator_traits<ForwardIterator>().data(first),
     188            target.binary(i),
     189            utility::iterator_traits<ForwardIterator>().weight(first));
     190  }
     191
     192
     193  template <class T>
    125194  double mad(T first, T last, const bool sorted=false)
    126195  {
    127196    double m = median(first, last, sorted);
    128 
    129197    typedef std::vector<typename std::iterator_traits<T>::value_type> Vec;
    130198    Vec ad;
     
    142210 
    143211
    144   ///
    145   /// Median is defined to be value in the middle. If number of values
    146   /// is even median is the average of the two middle values.  the
    147   /// median value is given by p equal to 50. If \a sorted is false
    148   /// (default), the range is copied, the copy is sorted, and then
    149   /// used to calculate the median.
    150   ///
    151   /// Function is a non-mutable function, i.e., \a first and \a last
    152   /// can be const_iterators.
    153   ///
    154   /// Requirements: T should be an iterator over a range of doubles (or
    155   /// any type being convertable to double).
    156   ///
    157   /// @return median of range
    158   ///
    159212  template <class T>
    160213  double median(T first, T last, const bool sorted=false)
    161   { return percentile2(first, last, 50.0, sorted); }
    162 
    163   /**
    164      The percentile is determined by the \a p, a number between 0 and
    165      100. The percentile is found by interpolation, using the formula
    166      \f$ percentile = (1 - \delta) x_i + \delta x_{i+1} \f$ where \a
    167      p is floor\f$((n - 1)p/100)\f$ and \f$ \delta \f$ is \f$
    168      (n-1)p/100 - i \f$.Thus the minimum value of the vector is given
    169      by p equal to zero, the maximum is given by p equal to 100 and
    170      the median value is given by p equal to 50. If @a sorted
    171      is false (default), the vector is copied, the copy is sorted,
    172      and then used to calculate the median.
    173 
    174      Function is a non-mutable function, i.e., \a first and \a last
    175      can be const_iterators.
    176      
    177      Requirements: T should be an iterator over a range of doubles (or
    178      any type being convertable to double).
    179      
    180      @return \a p'th percentile of range
    181 
    182      \deprecated percentile2 will replace this function in the future
    183 
    184      \note the definition of percentile used here is not identical to
    185      that one used in percentile2 and Percentile. The difference is
    186      smaller for large ranges.
    187   */
     214  {
     215    return percentile2(first, last, 50.0, sorted);
     216  }
     217
     218
    188219  template <class RandomAccessIterator>
    189220  double percentile(RandomAccessIterator first, RandomAccessIterator last,
     
    216247
    217248
    218   /**
    219      \see Percentiler
    220      
    221      \since new in yat 0.5
    222    */
    223   template <class RandomAccessIterator>
    224   double percentile2(RandomAccessIterator first, RandomAccessIterator last,
    225                      double p, bool sorted=false)
    226   {
    227     Percentiler percentiler(p, sorted);
    228     return percentiler(first, last);
    229   }
    230 
    231   ///
    232   /// @brief Computes the skewness of the data in a vector.
    233   ///
    234   /// The skewness measures the asymmetry of the tails of a
    235   /// distribution.
    236   ///
    237   double skewness(const utility::VectorBase&);
    238  
    239249}}} // of namespace statistics, yat, and theplu
    240250
  • trunk/yat/utility/CommandLine.cc

    r1797 r1874  
    122122        if (is_long_option(*arg)) {
    123123          std::string key(arg->substr(2));
    124           std::stringstream ss(key);
    125           getline(ss, key, '=');
     124          std::stringstream ss2(key);
     125          getline(ss2, key, '=');
    126126          std::string value;
    127           getline(ss, value, '\0');
     127          getline(ss2, value, '\0');
    128128          if (!value.empty()){
    129129            *arg = value;
     
    142142          }           
    143143          else if (iter==long_options_.end()) {
    144             ss.str("");
    145             ss << ": unrecognized option `" << key << "'\n" << try_help();
    146             throw cmd_error(ss.str());
     144            std::stringstream ss3;
     145            ss3 << ": unrecognized option `" << key << "'\n" << try_help();
     146            throw cmd_error(ss3.str());
    147147          }
    148148        }
     
    153153              iter(short_options_.find((*arg)[i]));
    154154            if (iter==short_options_.end()) {
    155               std::stringstream ss;
    156               ss << ": invalid option -- " << (*arg)[i] << "\n"
    157                  << try_help() << "\n";
    158               throw cmd_error(ss.str());
     155              std::stringstream ss2;
     156              ss2 << ": invalid option -- " << (*arg)[i] << "\n"
     157                  << try_help() << "\n";
     158              throw cmd_error(ss2.str());
    159159            }       
    160160            else
     
    165165          free_arg_.push_back(*arg);
    166166          if (free_arg_.size()>free_arg_max_) {
    167             std::stringstream ss;
    168             ss << ": invalid option -- " << *arg << "\n"
    169                << try_help() << "\n";
    170             throw cmd_error(ss.str());
     167            std::stringstream ss2;
     168            ss2 << ": invalid option -- " << *arg << "\n"
     169                << try_help() << "\n";
     170            throw cmd_error(ss2.str());
    171171          }
    172172        }
     
    176176    }
    177177    catch (cmd_error& e){
    178       std::stringstream ss;
    179       ss << program_name_ << ": " << e.what();
    180       throw cmd_error(ss.str());
     178      std::stringstream ss2;
     179      ss2 << program_name_ << ": " << e.what();
     180      throw cmd_error(ss2.str());
    181181    }
    182182     
Note: See TracChangeset for help on using the changeset viewer.