Skip to content

Commit 2cdce8e

Browse files
committed
Oops - columns are 0-indexed, not 1-indexed.
What was I thinking?
1 parent a2e966e commit 2cdce8e

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

mainframe/grouped_frame.hpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -342,38 +342,38 @@ struct get_aggregate_frame<frame<Ts...>, index_defn<Inds...>, Ops...>
342342
namespace agg
343343
{
344344
template<size_t Ind>
345-
detail::sum_op<Ind-1>
345+
detail::sum_op<Ind>
346346
sum( columnindex<Ind> )
347347
{
348-
return detail::sum_op<Ind-1>{};
348+
return detail::sum_op<Ind>{};
349349
}
350350

351351
template<size_t Ind>
352-
detail::min_op<Ind-1>
352+
detail::min_op<Ind>
353353
min( columnindex<Ind> )
354354
{
355-
return detail::min_op<Ind-1>{};
355+
return detail::min_op<Ind>{};
356356
}
357357

358358
template<size_t Ind>
359-
detail::max_op<Ind-1>
359+
detail::max_op<Ind>
360360
max( columnindex<Ind> )
361361
{
362-
return detail::max_op<Ind-1>{};
362+
return detail::max_op<Ind>{};
363363
}
364364

365365
template<size_t Ind>
366-
detail::mean_op<Ind-1>
366+
detail::mean_op<Ind>
367367
mean( columnindex<Ind> )
368368
{
369-
return detail::mean_op<Ind-1>{};
369+
return detail::mean_op<Ind>{};
370370
}
371371

372372
template<size_t Ind>
373-
detail::stddev_op<Ind-1>
373+
detail::stddev_op<Ind>
374374
stddev( columnindex<Ind> )
375375
{
376-
return detail::stddev_op<Ind-1>{};
376+
return detail::stddev_op<Ind>{};
377377
}
378378

379379
detail::count_op
@@ -451,16 +451,6 @@ class grouped_frame<index_defn<GroupInds...>, Ts...>
451451
}
452452

453453
private:
454-
template<size_t ColInd, typename... Ops, typename... Us>
455-
void
456-
aggregate_rename_result_columns( std::tuple<series<Us>...>& result_columns ) const
457-
{
458-
aggregate_rename_result_columns_args<0, ColInd, Ops...>( result_columns );
459-
if constexpr (ColInd+1 < sizeof...(Ts)) {
460-
aggregate_rename_result_columns<ColInd+1, Ops...>( result_columns );
461-
}
462-
}
463-
464454
template<size_t ColInd>
465455
std::string
466456
get_op_name( detail::sum_op<ColInd> ) const
@@ -496,13 +486,23 @@ class grouped_frame<index_defn<GroupInds...>, Ts...>
496486
return "stddev";
497487
}
498488

489+
template<size_t ColInd, typename... Ops, typename... Us>
490+
void
491+
aggregate_rename_result_columns( std::tuple<series<Us>...>& result_columns ) const
492+
{
493+
aggregate_rename_result_columns_args<0, ColInd, Ops...>( result_columns );
494+
if constexpr (ColInd+1 < sizeof...(Ts)) {
495+
aggregate_rename_result_columns<ColInd+1, Ops...>( result_columns );
496+
}
497+
}
498+
499499
template<size_t ArgInd, size_t ColInd, typename... Ops, typename... Us>
500500
void
501501
aggregate_rename_result_columns_args( std::tuple<series<Us>...>& result_columns ) const
502502
{
503503
using OpsTup = std::tuple<Ops...>;
504504
if constexpr (detail::is_colind_at_argind<ColInd, ArgInd, OpsTup>::value) {
505-
columnindex<ColInd+1> ci;
505+
columnindex<ColInd> ci;
506506
auto name = m_frame.column_name(ci);
507507
auto& s = std::get<ArgInd>(result_columns);
508508
using Op = typename detail::pack_element<ArgInd, Ops...>::type;
@@ -578,7 +578,7 @@ class grouped_frame<index_defn<GroupInds...>, Ts...>
578578
series<T>& result_column ) const
579579
{
580580
T temp = static_cast<T>(0);
581-
columnindex<ColInd+1> ci;
581+
columnindex<ColInd> ci;
582582
for ( size_t rowind : rowinds ) {
583583
const auto& row = m_frame[rowind];
584584
const T& t = row.at( ci );
@@ -596,7 +596,7 @@ class grouped_frame<index_defn<GroupInds...>, Ts...>
596596
using std::max;
597597
using std::numeric_limits;
598598
T temp = numeric_limits<T>::lowest();
599-
columnindex<ColInd+1> ci;
599+
columnindex<ColInd> ci;
600600
for ( size_t rowind : rowinds ) {
601601
const auto& row = m_frame[rowind];
602602
const T& t = row.at( ci );
@@ -614,7 +614,7 @@ class grouped_frame<index_defn<GroupInds...>, Ts...>
614614
using std::min;
615615
using std::numeric_limits;
616616
T temp = numeric_limits<T>::max();
617-
columnindex<ColInd+1> ci;
617+
columnindex<ColInd> ci;
618618
for ( size_t rowind : rowinds ) {
619619
const auto& row = m_frame[rowind];
620620
const T& t = row.at( ci );
@@ -630,7 +630,7 @@ class grouped_frame<index_defn<GroupInds...>, Ts...>
630630
series<T>& result_column ) const
631631
{
632632
T temp = static_cast<T>(0);
633-
columnindex<ColInd+1> ci;
633+
columnindex<ColInd> ci;
634634
for ( size_t rowind : rowinds ) {
635635
const auto& row = m_frame[rowind];
636636
const T& t = row.at( ci );
@@ -647,7 +647,7 @@ class grouped_frame<index_defn<GroupInds...>, Ts...>
647647
series<T>& result_column ) const
648648
{
649649
T sum = static_cast<T>(0);
650-
columnindex<ColInd+1> ci;
650+
columnindex<ColInd> ci;
651651
for ( size_t rowind : rowinds ) {
652652
const auto& row = m_frame[rowind];
653653
const T& t = row.at( ci );

tests/mainframe_test_main.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,38 +1493,38 @@ TEST_CASE("aggregate", "[frame]")
14931493
// start with groupby( _5, _6 ).aggregate( sum( _1 ), sum( _2 ), count(), min( _4 ), sum( _3 ), sum( _1 ), max( _1 ) )
14941494
using F = frame<char, short, int, long, float, double>;
14951495
using RCFA = typename mf::detail::get_result_columns_from_args<F,
1496+
decltype(mf::agg::sum(_0)),
14961497
decltype(mf::agg::sum(_1)),
1497-
decltype(mf::agg::sum(_2)),
14981498
decltype(mf::agg::count()),
1499-
decltype(mf::agg::min(_4)),
1500-
decltype(mf::agg::sum(_3)),
1501-
decltype(mf::agg::sum(_1)),
1502-
decltype(mf::agg::max(_1))
1499+
decltype(mf::agg::min(_3)),
1500+
decltype(mf::agg::sum(_2)),
1501+
decltype(mf::agg::sum(_0)),
1502+
decltype(mf::agg::max(_0))
15031503
>::type;
15041504
RCFA rcfa;
15051505
(void)rcfa;
15061506
//TD<RCFA> foo;
15071507

15081508
using AF = typename mf::detail::get_aggregate_frame<F, index_defn<4, 5>,
1509+
decltype(mf::agg::sum(_0)),
15091510
decltype(mf::agg::sum(_1)),
1510-
decltype(mf::agg::sum(_2)),
15111511
decltype(mf::agg::count()),
1512-
decltype(mf::agg::min(_4)),
1513-
decltype(mf::agg::sum(_3)),
1514-
decltype(mf::agg::sum(_1)),
1515-
decltype(mf::agg::max(_1))
1512+
decltype(mf::agg::min(_3)),
1513+
decltype(mf::agg::sum(_2)),
1514+
decltype(mf::agg::sum(_0)),
1515+
decltype(mf::agg::max(_0))
15161516
>::type;
15171517
AF af;
15181518
(void)af;
15191519
//TD<AF> foo4;
15201520
using TUP = tuple<
1521+
decltype(mf::agg::sum(_0)),
15211522
decltype(mf::agg::sum(_1)),
1522-
decltype(mf::agg::sum(_2)),
15231523
decltype(mf::agg::count()),
1524-
decltype(mf::agg::min(_4)),
1525-
decltype(mf::agg::sum(_3)),
1526-
decltype(mf::agg::sum(_1)),
1527-
decltype(mf::agg::max(_1))
1524+
decltype(mf::agg::min(_3)),
1525+
decltype(mf::agg::sum(_2)),
1526+
decltype(mf::agg::sum(_0)),
1527+
decltype(mf::agg::max(_0))
15281528
>;
15291529
TUP tup;
15301530
(void)tup;

0 commit comments

Comments
 (0)