-
Notifications
You must be signed in to change notification settings - Fork 24
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
show unit symbols for common units #54
base: master
Are you sure you want to change the base?
Conversation
I had thought about this, but was concerned about cases where there was two possible representations, e.g. |
We could display both, i.e. |
I'd rather do this as a separate function call, than automatically, i.e. something like julia> using SIUnits, SIUnits.ShortUnits
julia> 10N
10 kg m/s^2
julia> simplifyunits(10 N * m)
10 J
julia> simplifyunits(10 N * m; commons=[N,m])
10 N m where my idea with the optional parameter (which could probably be better named) is we have a predefined list of "common" units to which we contract, but the user can override it to alter the behavior - e.g. to choose to display Doing it this way has the added benefit that it won't alter the behavior of existing code. |
When I played around with this, I initially also did it using a separate function. However, it became kind of annoying to always call |
@jonasrauber, sure, but how does the user get to choose which units are used? I see no functionality in this PR that allows that flexibility. |
@tlycken no, you are right, that's currently not part of this PR. I thought someone might have a better idea to solve this problem. Do you know any other julia package that gives the user the choice to configure the output of |
This is somewhat similar to the GRISU/show_shortest problem when displaying floats. It'd be really cool to automagically print the shortest representation of the units, but it seems like a traveling-salesman problem to me… especially once you start considering combinations of powers of derived units. But then For my purposes, though, I almost always use microvolts or milliamps, so something simple along these lines would make most of what I do more intuitive. |
Hi Keno/Everyone, Along the same theme, I implemented facilities to display numeric values using SI prefixes (M, k, m, u, n, ...)
Question If so, the code can be found under (MIT-lic) |
I think it would be nice to see the unit symbol for common units, e.g.
N
for Newton instead ofkg m s⁻²
.