Re: [Python-ideas] Support floating-point values in collections.Counter

2017-12-19 Thread Søren Pilgård
On Tue, Dec 19, 2017 at 12:51 AM, Joel Croteau wrote: > It would be useful in many scenarios for values in collections.Counter to be > allowed to be floating point. I know that Counter nominally emulates a > multiset, which would suggest only integer values, but in a more general > sense, it could

Re: [Python-ideas] Support floating-point values in collections.Counter

2017-12-19 Thread Steven D'Aprano
On Mon, Dec 18, 2017 at 11:51:46PM +, Joel Croteau wrote: > It would be useful in many scenarios for values in collections.Counter to > be allowed to be floating point. Can you give a concrete example? > I know that Counter nominally emulates a multiset, > which would suggest only integer v

Re: [Python-ideas] Support floating-point values in collections.Counter

2017-12-19 Thread Paul Moore
On 18 December 2017 at 23:51, Joel Croteau wrote: > It would be useful in many scenarios for values in collections.Counter to be > allowed to be floating point. Do you have any evidence of this? Code examples that would be significantly improved by such a change? I can't think of any myself. I

Re: [Python-ideas] Support floating-point values in collections.Counter

2017-12-19 Thread Joel Croteau
Well here is some code I wrote recently to build a histogram over a weighted graph, before becoming aware that Counter existed (score is a float here): from collections import defaultdict total_score_by_depth = defaultdict(float) total_items_by_depth = defaultdict(int) num_nodes_by_score = defaul