Message369867
The collections docs state: "Several mathematical operations are provided for combining Counter objects to produce multisets (counters that have counts greater than zero)."
I am surprised at the clear level of decision into conflating counters with multisets. Why break all functionality for negative counts in favour of multisets? Why not create a Multiset object for multisets?
One example use of negative counts is in factorisation (https://bugs.python.org/msg368298 will be surprised counters don't count)
18 = 2**1 * 3**2 --> x18 = Counter({2: 1, 3: 2})
4 = 2**2 --> x4 = Counter({2: 2})
To compute 18/4 in this representation (which I believe is exactly precisely a count), one would expect
18/4 = 2**-1 * 3**2 --> x4_5 = x18 - x4 = Counter({2: -1, 3: 2})
But instead,
x18 - x4 = Counter({3: 2}) = 9 ???
This is just an example. The use case for negative counts is plain and obvious. The question is: why does collections break counter behaviour in favour of conflation with multisets? Why not have two objects: Counter for counters and Multiset for multisets? |
|
Date |
User |
Action |
Args |
2020-05-25 09:28:30 | wpk- | set | recipients:
+ wpk- |
2020-05-25 09:28:30 | wpk- | set | messageid: <1590398910.64.0.370990898211.issue40764@roundup.psfhosted.org> |
2020-05-25 09:28:30 | wpk- | link | issue40764 messages |
2020-05-25 09:28:30 | wpk- | create | |
|