// 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 #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost; using namespace boost::accumulators; typedef accumulator_set< double , stats > > accumulator_type; template python::list listify_range(Range const &range) { python::list l; typedef typename boost::range_result_iterator::type iterator; iterator begin = range.begin(); iterator end = range.end(); for(; begin != end; ++begin) l.append(*begin); return l; } python::list listify_covariate1(accumulator_type const& acc) { return listify_range(order_variate(acc)); } 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", no_init) .def( py::init< mpl::vector1< accumulators::detail::cache_size_tag > , mpl::vector1 >() ) .def( py::call< mpl::vector2< tag::sample , tag::covariate1 > , mpl::vector3 >() ); def("covariate1", listify_covariate1); }