-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
Milestone
Description
DESCRIPTION of the request - Make something like sum() but it must actually work for bitmath objects
Passing an array of bitmath objects into the built-in sum() function has unpredictable results.
In [78]: to_count = [Byte(1), MiB(1), GiB(1)]
In [79]: sum(to_count)
Out[79]: 3.0
In [80]: bitmath.best_prefix(sum(to_count))
Out[80]: Byte(3.0)
Which is incorrect:
In [76]: counted
Out[76]: Byte(1074790401.0)
In [77]: counted.best_prefix()
Out[77]: GiB(1.0009765634313226)
What you EXPECTED to happen:
Expected sum to let bitmath objects use their built in rich comparison and numeric data model emulation methods.
What ACTUALLY happened:
sum() seems to be using the instance.value attribute
VERSION of bitmath effected (git hashes are OK). Did you install from RPM, PyPi, source?
- all versions from all sources
To Do
Add something to bitmath, like bitmath.sum to emulate the standard library function which is misbehaving.