Keno / SIUnits.jl

Efficient unit-checked computation
Other
70 stars 26 forks source link

Optionally show derived units #92

Open grero opened 8 years ago

grero commented 8 years ago

It would be nice to have the option of getting the string representation of a derived unit directly, e.g. print 1V as 1V, instead of 1 kg m²s⁻³A⁻¹. I realise this might be contrary to the purpose of this package. The reason I want to do this is that I'm looking to store some data with their associated units, and so would like to be able to read strings like "mV" from a file and create an array of mV quantities. What I have tried so far is

_strunit = string(SIUnits.unit(first(data)))

which of course returns "kg m²s⁻³A⁻¹" for an array of voltage data.

Conversely, I would like to have something like

parse(SIUnit, "mV") = 1//1000 kg m²s⁻³A⁻¹

My apologies if this functionality is outside of the scope of the package.