This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wpk-
Recipients wpk-
Date 2020-05-25.09:28:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590398910.64.0.370990898211.issue40764@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2020-05-25 09:28:30wpk-setrecipients: + wpk-
2020-05-25 09:28:30wpk-setmessageid: <1590398910.64.0.370990898211.issue40764@roundup.psfhosted.org>
2020-05-25 09:28:30wpk-linkissue40764 messages
2020-05-25 09:28:30wpk-create