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

Render floating point numeric attributes with two decimal places of accuracy #100

Open
brimoor opened this issue Mar 10, 2020 · 4 comments
Labels
enhancement Code enhancement

Comments

@brimoor
Copy link
Contributor

brimoor commented Mar 10, 2020

Showing many significant digits for floating point numeric attributes is not useful and takes up a lot of visual space.

This is how ETA renders numeric attributes, which I request we adopt in Player51:

https://github.com/voxel51/eta/blob/ba108043fa9afb324915a7c2419c12e6a1768bed/eta/core/annotations.py#L1188

Screen Shot 2020-03-10 at 1 54 35 PM

Screen Shot 2020-03-10 at 1 53 18 PM

@lethosor
Copy link
Contributor

Suggest also moving this one to player51 since this affects Scoop as well.

Side note: that will render anything between 0 and 0.05 as 0.00 - if some numeric attribute is always this small, truncating it may not be useful.

@brimoor
Copy link
Contributor Author

brimoor commented Mar 10, 2020

Got it. Let's do "%.2g" instead of "%.2f" for floating point numbers then

@brimoor
Copy link
Contributor Author

brimoor commented Mar 10, 2020

(I'll update ETA to match this)

@lethosor lethosor transferred this issue from another repository Mar 10, 2020
@lethosor lethosor added the enhancement Code enhancement label Mar 10, 2020
@lethosor
Copy link
Contributor

lethosor commented Mar 18, 2020

That does have the following side effect, though:

>>> '%.2g' % 234
'2.3e+02'

compared to:

>>> '%.2f' % 234
'234.00'

Is scientific notation desirable for these? Or do we want the %f behavior for numbers >= 1?

Another option:

>>> '%g' % 234
'234'
>>> '%.2g' % .0001234
'0.00012'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Code enhancement
Projects
None yet
Development

No branches or pull requests

2 participants