Message253930
Several collections.Counter methods return Counter objects, which is leads to wrong or at least confusing behavior when Counter is subclassed. For example, nltk.FreqDist is a subclass of Counter:
>>> x = nltk.FreqDist(['a','a','b','b','b'])
>>> y = nltk.FreqDist(['b','b','b','b','b'])
>>> z = x + y
>>> z.__class__
<class 'collections.Counter'>
This applies to __add__(), __sub__(), __or__(), __and__(), __pos__(), and __neg__().
In contrast, the copy() method does (what I think is) the right thing:
>>> x.copy().__class__
<class 'nltk.probability.FreqDist'> |
|
Date |
User |
Action |
Args |
2015-11-02 16:35:19 | rmalouf | set | recipients:
+ rmalouf |
2015-11-02 16:35:19 | rmalouf | set | messageid: <1446482119.59.0.839988363019.issue25535@psf.upfronthosting.co.za> |
2015-11-02 16:35:19 | rmalouf | link | issue25535 messages |
2015-11-02 16:35:19 | rmalouf | create | |
|