-
Notifications
You must be signed in to change notification settings - Fork 992
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
Better display of estimated line numbers and add number of columns for tabular #17492
Conversation
fixes galaxyproject#6506 for large files the number of lines is estimated and shown as a rounded number (using two significant digits), e.g `~8,700,000 lines`. with this change it will be: `~87 10^5 lines` this commit also makes roundify really round numbers (as the name suggests) and not simply cut at two digits, but this could be reverted if there are concerns wrt speed due to using more math
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great improvement!
lib/galaxy/util/__init__.py
Outdated
@@ -1135,14 +1139,49 @@ def commaify(amount): | |||
return commaify(new) | |||
|
|||
|
|||
def trailing_zeros_to_powerof10(amount): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a shorter version operating on numbers directly:
def trailing_zeros_to_powerof10(amount, threshold=5):
if abs(amount) < 10**threshold:
return amount
exp = threshold - 1
while not amount % 10**(exp+1):
exp += 1
if exp < threshold:
return amount
return f"{amount // 10**exp}\u22C510^{exp}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even shorter:
def trailing_zeros_to_powerof10(amount, threshold=5):
if amount == 0 or amount % 10**threshold:
return amount
exp = threshold
while not amount % 10**(exp+1):
exp += 1
return f"{amount // 10**exp}\u22C510^{exp}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while not amount % 10**(exp+1):
would run infinitely if amount is not a number of 10.
Note that if we would like to have short code for getting scientific notation we can just f"{number:.0e}"
. My goal here was to only remove trailing 0s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know and I've tested my suggestion at least with your docstring numbers :)
Co-authored-by: Wolfgang Maier <maierw@posteo.de>
Can you add type annotation to the functions please? |
I'm not sure, this new version is always more readable than the old one. |
Because 1<=m<10 or because n is a multiple of 3 (for m × 10n)? |
Because I'm used to think in exponents that are multiples of 3 (thousands, millions, etc lines). |
Expressed as code I think I'm looking for sth like this:
Note: this assumes that the amount has been roundified before. |
@wm75 It looks like to me you are proposing https://en.wikipedia.org/wiki/Engineering_notation instead of https://en.wikipedia.org/wiki/Scientific_notation ? |
Would be fine for me, then we could even use prefixes like |
The idea is similar at least, yes. |
16b8eb5
to
9fa8345
Compare
How about this one: 9fa8345? It's super compact (maybe even more than the E notation), it's maybe also the least technical (no exponential .. only hidden). By using the |
279c372
to
5797a3b
Compare
5797a3b
to
0790854
Compare
3a8dbf5
to
cb79e87
Compare
@bernt-matthias can you, please, backport this to 24.0? It was accidentally merged into the dev branch. |
This was not an accident -- we (wg-backend) discussed it on the call last week and decided targeting 24.1/dev was fine. We can just correct the milestone? |
@bernt-matthias never mind! |
Cherry picked from #13918
How to test the changes?
(Select all options that apply)
License