[issue24068] statistics module - incorrect results with boolean input

2018-04-08 Thread Wolfgang Maier

Wolfgang Maier  added the comment:

Fixed as part of resolving issue 25177.

--
resolution:  -> fixed
stage: test needed -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-05-20 Thread Matteo Dell'Amico

Changes by Matteo Dell'Amico de...@linux.it:


--
nosy: +della

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-05-11 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-05-03 Thread Mark Dickinson

Mark Dickinson added the comment:

 I wonder if it would be better to reject Bool data in this context?

It's not uncommon (and quite useful) in NumPy world to compute basic statistics 
on arrays of boolean dtype: the sum of such an array gives a count of the 
`True`s, and the mean gives the proportion of `True` entries.  I think it would 
be handy to allow the statistics module to work with lists of bools, if 
possible.

--
nosy: +mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-05-02 Thread Wolfgang Maier

Wolfgang Maier added the comment:

uploading an alternate, possibly slightly clearer version of the patch

--
Added file: http://bugs.python.org/file39269/statistics._sum.v2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-05-01 Thread R. David Murray

R. David Murray added the comment:

I wonder if it would be better to reject Bool data in this context?  Bool is 
only a numeric type for historical reasons.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-05-01 Thread Steven D'Aprano

Steven D'Aprano added the comment:

The patch seems simple and straightforward enough. It just needs some tests, 
and a Round Tuit.

--
assignee:  - steven.daprano

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-05-01 Thread Steven D'Aprano

Changes by Steven D'Aprano steve+pyt...@pearwood.info:


--
stage:  - test needed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-04-28 Thread Wolfgang Maier

Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de:


Removed file: http://bugs.python.org/file39220/statistics._sum.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-04-28 Thread Wolfgang Maier

Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de:


Added file: http://bugs.python.org/file39221/statistics._sum.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24068] statistics module - incorrect results with boolean input

2015-04-28 Thread Wolfgang Maier

New submission from Wolfgang Maier:

the mean function in the statistics module gives nonsensical results with 
boolean values in the input, e.g.:

 mean([True, True, False, False])
0.25

 mean([True, 1027])
0.5

This is an issue with the module's internal _sum function that mean relies on. 
Other functions relying on _sum are affected more subtly, e.g.:

 variance([1, 1027, 0])
351234.33

 variance([True, 1027, 0])
351234.34

The problem with _sum is that it will try to coerce its result to any non-int 
type found in the input (so bool in the examples), but bool(1028) is just True 
so information gets lost.

I've attached a patch preventing the type cast when it would be to bool.
I don't have time to write a separate test though so if somebody wants to take 
over .. :)

--
components: Library (Lib)
files: statistics._sum.patch
keywords: patch
messages: 242169
nosy: steven.daprano, wolma
priority: normal
severity: normal
status: open
title: statistics module - incorrect results with boolean input
type: behavior
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file39220/statistics._sum.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24068
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com