PainterQubits / Unitful.jl

Physical quantities with arbitrary units
Other
614 stars 112 forks source link

Update hour symbol to `h` and Planck constant symbol to `ℎ` #536

Open Mo-Gul opened 2 years ago

Mo-Gul commented 2 years ago

I suggest to change the default "Symbol" and "Display" from

https://github.com/PainterQubits/Unitful.jl/blob/960e09ef518b0d3ff54747460b9c3872c08df0d7/src/pkgdefaults.jl#L252

to

@unit h     "h"       Hour                  3600s         false

because this should be the usual/common default. As examples have a look at

Of course then also the Planck constant symbol has to change. Therefore I suggest to change

https://github.com/PainterQubits/Unitful.jl/blob/960e09ef518b0d3ff54747460b9c3872c08df0d7/src/pkgdefaults.jl#L422

to

const ℎ  = 6.626_070_15e-34*J*s     # exact, Planck constant (type as "\planck<TAB>")

as it is also proposed in the above documents. The corresponding places are

It should be quite natural in Julia to use , since this is also listed in the Julia Manual. (Search for "planck" there.)

In case this should also help to consider this breaking change: The same was done recently in Pint (the Python equivalent of Unitful) in PR https://github.com/hgrecco/pint/pull/1454. See also the corresponding issue https://github.com/hgrecco/pint/issues/719.

Jellby commented 2 years ago

I'm not sure I like using for Planck's constant. I don't know what the reasoning was for including it as a codepoint in Unicode, except maybe to complement . Why should it have a dedicated symbol and not other constants such as 𝑒 (U+1D452 MATHEMATICAL ITALIC SMALL E, elementary charge), 𝑐 (U+1D450 MATHEMATICAL ITALIC SMALL C, speed of light in vacuum), 𝐺 (U+1D43A MATHEMATICAL ITALIC CAPITAL G, gravitational constant), etc.?

I can agree to using solving the conflict by assigning h to the more common hour (although that will make my particular usage of pint-convert more cumbersome), but if obscure/italic characters are going to be used for some constant, they should be used for all (at the very least ħ should be changed to too).

sostock commented 2 years ago

Since this would be breaking, it is something to consider for Unitful 2.0. That said, I’m not sure it is worth the breaking change and I worry that h and might be too easily confused.

I agree that if we change h to , we should also change ħ to . Changing all physical constants to italics would technically be the correct thing to do, but it makes them harder to type (\itc<tab> instead of just c).

sostock commented 1 year ago

There is a plan to normalize to ħ: https://github.com/JuliaLang/julia/issues/48870

If this is implemented, Unitful.ℏ and Unitful.ħ would automatically refer to the same object (we could still change the printing from "ħ" to "ℏ").

Edit: is normalized to ħ starting from Julia 1.10.