Message253930
| Author |
rmalouf |
| Recipients |
rmalouf |
| Date |
2015年11月02日.16:35:19 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1446482119.59.0.839988363019.issue25535@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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'> |
|
History
|
|---|
| 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 |
|