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

2017-12-20 Thread Franklin? Lee
On Mon, Dec 18, 2017 at 6:51 PM, 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-20 Thread Ned Batchelder
On 12/20/17 5:05 AM, Paul Moore wrote: On 20 December 2017 at 03:09, Joel Croteau wrote: 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_d

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

2017-12-20 Thread Paul Moore
On 20 December 2017 at 03:09, Joel Croteau wrote: > 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) > tota

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

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 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 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

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

2017-12-18 Thread Joel Croteau
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 be an accumulator of either floating point or integer data. As