cleanup-2008 2230: Make the tests in tests/accu work.

https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Nicolas Ballas <ballas@lrde.epita.fr> Make the tests in tests/accu work. * tests/accu/Makefile.am, * tests/accu/all_accus.cc, * tests/accu/histo.cc, * tests/accu/rank.cc: Update. * tests/accu/median.cc, * tests/accu/median_h.cc: Move, rename median to median_h and update. * mln/accu/min_h.hh, * mln/accu/max_h.hh: Update licenses. * mln/accu/rank.hh: Update. * mln/accu/median.hh, * mln/accu/median_h.hh: Move, rename to median_h and update. * mln/accu/all.hh: Rename median to median_h. mln/accu/all.hh | 2 - mln/accu/max_h.hh | 2 - mln/accu/median_h.hh | 89 +++++++++++++++++++++--------------------------- mln/accu/min_h.hh | 2 - mln/accu/rank.hh | 16 +------- tests/accu/Makefile.am | 6 ++- tests/accu/all_accus.cc | 2 - tests/accu/histo.cc | 2 - tests/accu/median_h.cc | 10 ++--- tests/accu/rank.cc | 16 ++++---- 10 files changed, 64 insertions(+), 83 deletions(-) Index: tests/accu/rank.cc --- tests/accu/rank.cc (revision 2229) +++ tests/accu/rank.cc (working copy) @@ -54,42 +54,42 @@ { accu::rank_<value::int_u8> accu(0, 8); fill(accu); - mln_assertion(accu.to_result() == 1); + mln_assertion(accu.to_result() == 1u); } { accu::rank_<value::int_u8> accu(1, 8); fill(accu); - mln_assertion(accu.to_result() == 2); + mln_assertion(accu.to_result() == 2u); } { accu::rank_<value::int_u8> accu(2, 8); fill(accu); - mln_assertion(accu.to_result() == 2); + mln_assertion(accu.to_result() == 2u); } { accu::rank_<value::int_u8> accu(3, 8); fill(accu); - mln_assertion(accu.to_result() == 3); + mln_assertion(accu.to_result() == 3u); } { accu::rank_<value::int_u8> accu(4, 8); fill(accu); - mln_assertion(accu.to_result() == 4); + mln_assertion(accu.to_result() == 4u); } { accu::rank_<value::int_u8> accu(5, 8); fill(accu); - mln_assertion(accu.to_result() == 5); + mln_assertion(accu.to_result() == 5u); } { accu::rank_<value::int_u8> accu(6, 8); fill(accu); - mln_assertion(accu.to_result() == 5); + mln_assertion(accu.to_result() == 5u); } { accu::rank_<value::int_u8> accu(7, 8); fill(accu); - mln_assertion(accu.to_result() == 5); + mln_assertion(accu.to_result() == 5u); } { accu::rank_<bool> accu_bool(1, 5); Index: tests/accu/median_h.cc --- tests/accu/median_h.cc (revision 2228) +++ tests/accu/median_h.cc (working copy) @@ -25,22 +25,22 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/accu/median.cc +/*! \file tests/accu/median_h.cc * - * \brief Tests on mln::accu::median. + * \brief Tests on mln::accu::median_h. */ #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> -#include <mln/accu/median.hh> +#include <mln/accu/median_h.hh> int main() { using namespace mln; { - accu::median< value::set<value::int_u8> > med; + accu::median_h<value::int_u8> med; med.take(10); med.take(9); @@ -58,7 +58,7 @@ } { - accu::median< value::set<value::int_u8> > med; + accu::median_h<value::int_u8> med; med.take(10); med.take(7); Property changes on: tests/accu/median_h.cc ___________________________________________________________________ Added: svn:mergeinfo Index: tests/accu/Makefile.am --- tests/accu/Makefile.am (revision 2229) +++ tests/accu/Makefile.am (working copy) @@ -11,12 +11,13 @@ max \ max_h \ mean \ - median \ + median_h \ min \ min_h \ min_max \ nil \ pair \ + rank \ tuple all_accus_SOURCES = all_accus.cc @@ -27,12 +28,13 @@ max_SOURCES = max.cc max_h_SOURCES = max_h.cc mean_SOURCES = mean.cc -median_SOURCES = median.cc +median_h_SOURCES = median_h.cc min_SOURCES = min.cc min_h_SOURCES = min_h.cc min_max_SOURCES = min_max.cc nil_SOURCES = nil.cc pair_SOURCES = pair.cc +rank_SOURCES = rank.cc tuple_SOURCES = tuple.cc TESTS = $(check_PROGRAMS) Index: tests/accu/all_accus.cc --- tests/accu/all_accus.cc (revision 2229) +++ tests/accu/all_accus.cc (working copy) @@ -40,7 +40,7 @@ bbox<point2d> b; count_<int> c; - histo< value::set<bool> > h; + mln::accu::histo<bool> h; max_<int> ma; mean_<int> me; // median< value::set<bool> > med; // FIXME: bool has no min so workaround! Index: tests/accu/histo.cc --- tests/accu/histo.cc (revision 2229) +++ tests/accu/histo.cc (working copy) @@ -40,7 +40,7 @@ using namespace mln; using namespace mln::value; - accu::histo< set<int_u8> > a; + accu::histo<int_u8> a; a.take(1); a.take(1); Index: mln/accu/min_h.hh --- mln/accu/min_h.hh (revision 2229) +++ mln/accu/min_h.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms Index: mln/accu/rank.hh --- mln/accu/rank.hh (revision 2229) +++ mln/accu/rank.hh (working copy) @@ -53,13 +53,12 @@ * The parameter \c T is the type of values. */ template <typename T> - struct rank_ : public mln::accu::internal::base_< T, rank_<T> > + struct rank_ : public mln::accu::internal::base< T, rank_<T> > { typedef T argument; typedef T result; typedef mln::value::set<T> S; - rank_(unsigned k, unsigned n, const Value_Set<S>& s); rank_(unsigned k, unsigned n); void init(); @@ -76,7 +75,7 @@ unsigned k_; // 0 <= k_ < n unsigned n_; - mutable accu::histo<S> h_; + mutable accu::histo<T> h_; const S& s_; // derived from h_ mutable std::size_t sum_minus_, sum_plus_; @@ -127,17 +126,6 @@ } - template <typename T> - inline - rank_<T>::rank_(unsigned k, unsigned n, const Value_Set<mln::value::set<T> >& s) - : k_(k), - n_(n), - h_(s), - s_(h_.vset()) - { - mln_assertion(k_ < n_); - init(); - } template <typename T> inline Index: mln/accu/max_h.hh --- mln/accu/max_h.hh (revision 2229) +++ mln/accu/max_h.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms Index: mln/accu/median_h.hh --- mln/accu/median_h.hh (revision 2228) +++ mln/accu/median_h.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -25,16 +25,17 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_ACCU_MEDIAN_HH -# define MLN_ACCU_MEDIAN_HH +#ifndef MLN_ACCU_MEDIAN_H_HH +# define MLN_ACCU_MEDIAN_H_HH -/*! \file mln/accu/median.hh +/*! \file mln/accu/median_h.hh * * \brief Define a generic median accumulator class. */ # include <mln/accu/internal/base.hh> # include <mln/accu/histo.hh> +# include <mln/value/set.hh> namespace mln @@ -45,38 +46,37 @@ /*! \brief Generic median function based on histogram over a value - * set with type \c S. + * set with type \c V. */ - template <typename S> - struct median : public mln::accu::internal::base< mln_value(S), median<S> > - { // FIXME: Should median be named 'median_' like other accumulators ? - typedef mln_value(S) argument; + template <typename V> + struct median_h : public mln::accu::internal::base< V, median_h<V> > + { + typedef V argument; typedef argument result; - median(const Value_Set<S>& s); - median(); + median_h(); void init(); void take(const argument& t); - void take(const median<S>& other); + void take(const median_h<V>& other); void untake(const argument& t); unsigned card() const { return h_.sum(); } argument to_result() const; - const accu::histo<S>& histo() const; + const accu::histo<V>& histo() const; protected: - mutable accu::histo<S> h_; - const S& s_; // derived from h_ + mutable accu::histo<V> h_; + const value::set<V>& s_; // derived from h_ mutable std::size_t sum_minus_, sum_plus_; mutable bool valid_; - mutable std::size_t i_; // the median index - mutable argument t_; // the median value + mutable std::size_t i_; // the median_h index + mutable argument t_; // the median_h value // Auxiliary methods void update_() const; @@ -87,28 +87,19 @@ # ifndef MLN_INCLUDE_ONLY - template <typename S> - inline - median<S>::median(const Value_Set<S>& s) - : h_(s), - s_(h_.vset()) - { - init(); - } - - template <typename S> + template <typename V> inline - median<S>::median() + median_h<V>::median_h() : h_(), s_(h_.vset()) { init(); } - template <typename S> + template <typename V> inline void - median<S>::take(const argument& t) + median_h<V>::take(const argument& t) { h_.take(t); @@ -121,10 +112,10 @@ valid_ = false; } - template <typename S> + template <typename V> inline void - median<S>::take(const median<S>& other) + median_h<V>::take(const median_h<V>& other) { // h_ h_.take(other.h_); @@ -141,10 +132,10 @@ valid_ = false; } - template <typename S> + template <typename V> inline void - median<S>::untake(const argument& t) + median_h<V>::untake(const argument& t) { mln_precondition(h_(t) != 0); h_.untake(t); @@ -158,10 +149,10 @@ valid_ = false; } - template <typename S> + template <typename V> inline void - median<S>::update_() const + median_h<V>::update_() const { valid_ = true; @@ -184,10 +175,10 @@ } } - template <typename S> + template <typename V> inline void - median<S>::go_minus_() const + median_h<V>::go_minus_() const { do { @@ -201,10 +192,10 @@ t_ = s_[i_]; } - template <typename S> + template <typename V> inline void - median<S>::go_plus_() const + median_h<V>::go_plus_() const { do { @@ -218,10 +209,10 @@ t_ = s_[i_]; } - template <typename S> + template <typename V> inline void - median<S>::init() + median_h<V>::init() { h_.init(); sum_minus_ = 0; @@ -232,20 +223,20 @@ valid_ = true; } - template <typename S> + template <typename V> inline - typename median<S>::argument - median<S>::to_result() const + typename median_h<V>::argument + median_h<V>::to_result() const { if (! valid_) update_(); return t_; } - template <typename S> + template <typename V> inline - const accu::histo<S>& - median<S>::histo() const + const accu::histo<V>& + median_h<V>::histo() const { return h_; } @@ -257,4 +248,4 @@ } // end of namespace mln -#endif // ! MLN_ACCU_MEDIAN_HH +#endif // ! MLN_ACCU_MEDIAN_H_HH Property changes on: mln/accu/median_h.hh ___________________________________________________________________ Added: svn:mergeinfo Index: mln/accu/all.hh --- mln/accu/all.hh (revision 2229) +++ mln/accu/all.hh (working copy) @@ -58,7 +58,7 @@ # include <mln/accu/histo.hh> # include <mln/accu/max.hh> # include <mln/accu/mean.hh> -# include <mln/accu/median.hh> +# include <mln/accu/median_h.hh> # include <mln/accu/min.hh> # include <mln/accu/min_h.hh> # include <mln/accu/min_max.hh>
participants (1)
-
Nicolas Ballas