historydag.counterops

Functions for manipulating collections.Counter objects.

Functions

counter_prod(counterlist, accumfunc)

'multiply' two Counters.

counter_sum(counterlist[, counter_type])

Sum a list of counters.

historydag.counterops.counter_prod(counterlist, accumfunc)[source]

‘multiply’ two Counters. Really a sort of cartesian product, which does accumfunc to keys and counts all the ways each result can be achieved using contents of counters in counterlist.

accumfunc must be a function like sum which acts on a list of arbitrary length. Probably should return an object of the same type.

historydag.counterops.counter_sum(counterlist, counter_type=Counter)[source]

Sum a list of counters.

Equivalent to concatenating their representative lists.