Author rhettinger
Recipients Windson Yang, cheryl.sabella, francismb, rhettinger, steven.daprano
Date 2019-02-26.01:58:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1551146286.98.0.91337972212.issue35892@roundup.psfhosted.org>
In-reply-to
Content
>  If others agree that it is sufficiently easy, we can assign 
> the task to Cheryl.

It's only easy if we clearly specify what we want to occur.  Deciding what the right behavior should be is not a beginner skill.

Proposed spec:
'''
Modify the API statistics.mode to handle multimodal cases so that the first mode encountered is the one returned.  If the input is empty, raise a StatisticsError.

TestCases:
    mode([])   --> StatisticsError
    mode('aabbbcc') --> 'c'
    mode(iter('aabbbcc')) --> 'c'
    mode('eeffddddggaaaa') --> 'a'

Implementation:
    * Discard the internal _counts function.
    * Instead use Counter(data).most_common(1)[0][0]
      because that makes only a single pass over the data

Documentation:
    * Update statistics.rst and include a versionchanged directive

    * In the Whatsnew compatibility section, note this is a behavior change.
      Code that used to raise StatisticsError will now return a useful value.
      Note that the rationale for the change is that the current mode()
      behavior would unexpectedly fail when given multimodal data.

When: 
    * We want this for 3.8 so it can't wait very long
'''
History
Date User Action Args
2019-02-26 01:58:06rhettingersetrecipients: + rhettinger, steven.daprano, francismb, cheryl.sabella, Windson Yang
2019-02-26 01:58:06rhettingersetmessageid: <1551146286.98.0.91337972212.issue35892@roundup.psfhosted.org>
2019-02-26 01:58:06rhettingerlinkissue35892 messages
2019-02-26 01:58:06rhettingercreate