[issue39218] Assertion failure when calling statistics.variance() on a float32 Numpy array
Steven D'Aprano
report at bugs.python.org
Sun Jan 5 03:03:42 EST 2020
Steven D'Aprano <steve+python at pearwood.info> added the comment:
Nice analysis and bug report, thank you! That's pretty strange behaviour for float32, but I guess we're stuck with it.
I wonder if the type assertion has outlived its usefulness? I.e. drop the `T == U` part and change the assertion to `assert count == count2` only.
If we removed the failing part of the assertion, and changed the final line to `return (U, total)`, that ought to keep the exact sum but convert to float32 later, rather than float64.
I am inclined to have the stdev of float32 return a float32 is possible. What do you think?
We should check the numpy docs to see what the conversion rules for numpy floats are.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39218>
_______________________________________
More information about the Python-bugs-list
mailing list