Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some kind of sum work, it doesn't now #103

Open
tbielawa opened this issue May 25, 2023 · 0 comments
Open

Make some kind of sum work, it doesn't now #103

tbielawa opened this issue May 25, 2023 · 0 comments
Milestone

Comments

@tbielawa
Copy link
Owner

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.

@tbielawa tbielawa added this to the 2.0.0 milestone May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant