Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On 17 Aug, 02:29, Raymond Hettinger pyt...@rcn.com wrote: [Paddy] Lets say you have two *sets* of integers representing two near-copies of some system, then a measure of their difference could be calculated as: len(X.symmetric_difference(Y)) / (len(X) + len(Y)) * 100 % If the two

Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On Aug 17, 10:47 pm, Paddy paddy3...@googlemail.com wrote: On 17 Aug, 02:29, Raymond Hettinger pyt...@rcn.com wrote: [Paddy] Lets say you have two *sets* of integers representing two near-copies of some system, then a measure of their difference could be calculated as:

Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On Aug 17, 2:29 am, Raymond Hettinger pyt...@rcn.com wrote: I would like to see someone post a subclass to the ASPN Cookbook that adds a number of interesting, though not common operations.  Your symmetric_difference() method could be one.  A dot_product() operation could be another.  

Re: EXOR or symmetric difference for the Counter class

2010-08-16 Thread Paddy
On 14 Aug, 18:14, Raymond Hettinger pyt...@rcn.com wrote: On Aug 12, 1:20 pm, Paddy paddy3...@googlemail.com wrote: I find myself needing to calculate the difference between two Counters or multisets or bags. I want those items that are unique to each bag. Tell us about your use cases.  

Re: EXOR or symmetric difference for the Counter class

2010-08-16 Thread Raymond Hettinger
[Paddy] Lets say you have two *sets* of integers representing two near-copies of some system, then a measure of their difference could be calculated as: len(X.symmetric_difference(Y)) / (len(X) + len(Y)) * 100 % If the two collections of integers are allowed duplicates then you need a

Re: EXOR or symmetric difference for the Counter class

2010-08-14 Thread Raymond Hettinger
On Aug 12, 1:20 pm, Paddy paddy3...@googlemail.com wrote: I find myself needing to calculate the difference between two Counters or multisets or bags. I want those items that are unique to each bag. Tell us about your use cases. I'm curious how a program would ascribe semantic meaning to the

Re: EXOR or symmetric difference for the Counter class

2010-08-13 Thread Chris Rebert
On Thu, Aug 12, 2010 at 10:36 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Thu, 12 Aug 2010 13:20:19 -0700, Paddy wrote: I find myself needing to calculate the difference between two Counters or multisets or bags. Is this collections.Counter from Python 3.1? Changed in

Re: EXOR or symmetric difference for the Counter class

2010-08-13 Thread Paddy
On Aug 13, 6:36 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Thu, 12 Aug 2010 13:20:19 -0700, Paddy wrote: I find myself needing to calculate the difference between two Counters or multisets or bags. Is this collections.Counter from Python 3.1? If so, you should say

EXOR or symmetric difference for the Counter class

2010-08-12 Thread Paddy
I find myself needing to calculate the difference between two Counters or multisets or bags. I want those items that are unique to each bag. I know how to calculate it: b = Counter(a=1, b=2) c = Counter(a=3, b=1) diff = (b - c) + (c - b) (b - c) Counter({'b': 1}) (c

Re: EXOR or symmetric difference for the Counter class

2010-08-12 Thread Steven D'Aprano
On Thu, 12 Aug 2010 13:20:19 -0700, Paddy wrote: I find myself needing to calculate the difference between two Counters or multisets or bags. Is this collections.Counter from Python 3.1? If so, you should say so, and if not, you should tell us which Counter class this is. It will save people