// Copyright Daniel Wallin 2005. Use, modification and distribution is // subject to the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include #include "stats/accumulators.hpp" #include "stats/statistics/stats.hpp" #include "stats/statistics/count.hpp" #include "stats/statistics/min.hpp" #include "stats/statistics/mean.hpp" #include "stats/statistics/sum.hpp" #include "stats/statistics/weighted_mean.hpp" #include "stats/statistics/moment.hpp" #include "stats/statistics/order.hpp" #include "stats/statistics/order_variate.hpp" #include "stats/statistics/with_error.hpp" #include "stats/statistics/variates/weights.hpp" #include "stats/statistics/variates/covariate.hpp" using namespace boost; using namespace boost::accumulators; typedef accumulator_set< double , stats > > accumulator_type; template void output_range(Range const &range) { typedef typename boost::remove_reference< typename boost::iterator_reference< typename boost::range_result_iterator::type >::type >::type output_type; std::copy(range.begin(), range.end(), std::ostream_iterator(std::cout, " ")); std::cout.put('\n'); } void output(accumulator_type const& acc) { output_range(order_variate(acc)); } #include #include namespace boost { namespace accumulators { namespace tag { char const* keyword_name(sample*) { return "sample"; } char const* keyword_name(covariate1*) { return "covariate1"; } }}} // namespace boost::accumulators::tag namespace boost { namespace accumulators { namespace detail { char const* keyword_name(cache_size_tag*) { return "cache_size"; } }}} // namespace boost::accumulators::detail BOOST_PYTHON_MODULE(accumulator_set) { using namespace boost::python; namespace py = boost::parameter::python; class_("accumulator_set") .def( py::init< mpl::vector1< accumulators::detail::cache_size_tag > , mpl::vector1 >() ) .def( py::call< mpl::vector2< tag::sample , tag::covariate1 > , mpl::vector3 >() ); def("output", output); }