galaxy
galaxy copied to clipboard
Better display of estimated line numbers and add number of columns for tabular
- Show estimated line number as a power of 10: showing all these zeros for an estimated number seems like a waste of space
- Show number of columns for tabular
Cherry picked from https://github.com/galaxyproject/galaxy/pull/13918
How to test the changes?
(Select all options that apply)
- [x] I've included appropriate automated tests.
- [ ] This is a refactoring of components with existing test coverage.
- [ ] Instructions for manual testing are as follows:
- [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]
License
- [x] I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.
roundify takes int
Can you add type annotation to the functions please?
I'm not sure, this new version is always more readable than the old one. 2*10^6 may be better than 2,000,000, but is 23*10^5 better than 2,300,000? If anything, I'd prefer 2.3*10^6 I think.
I'm not sure, this new version is always more readable than the old one. 210^6 may be better than 2,000,000, but is 2310^5 better than 2,300,000? If anything, I'd prefer 2.3*10^6 I think.
Because 1<=m<10 or because n is a multiple of 3 (for m × 10n)?
I'm not sure, this new version is always more readable than the old one. 2_10^6 may be better than 2,000,000, but is 23_10^5 better than 2,300,000? If anything, I'd prefer 2.3*10^6 I think.
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:
def trailing_zeros_to_powerof10(amount, threshold=5):
"""
>>> trailing_zeros_to_powerof10(23000)
'23000'
>>> trailing_zeros_to_powerof10(300000)
'0.3\u22C510^6'
>>> trailing_zeros_to_powerof10(2300000)
'2.3\u22C510^6'
>>> trailing_zeros_to_powerof10(23000000)
'23\u22C510^6'
>>> trailing_zeros_to_powerof10(1)
'1'
>>> trailing_zeros_to_powerof10(0)
'0'
>>> trailing_zeros_to_powerof10(100)
'100'
>>> trailing_zeros_to_powerof10(-100)
'-100'
"""
if abs(amount) < 10**threshold:
return str(amount)
exp = 3
while abs(amount) / 10**(exp+2) >= 1:
exp += 3
if amount % 10**exp:
return f"{amount / 10**exp}\u22C510^{exp}"
else:
return f"{amount // 10**exp}\u22C510^{exp}"
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 k, M, instead of using exponents. Could reuse nice_size() for this.
Would be fine for me, then we could even use prefixes like
k,M, instead of using exponents. Could reusenice_size()for this.
The idea is similar at least, yes.
How about this one: https://github.com/galaxyproject/galaxy/pull/17492/commits/9fa834532083c7d164d20a37eba2871385a50d40?
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 text=False in the metric prefix function we could also use nearly the same code for having 10^x. But we should remove it if we do not need it.
@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!