hgrecco / pint

Operate and manipulate physical quantities in Python
http://pint.readthedocs.org/
Other
2.4k stars 468 forks source link

Use of Planck constant symbol is inconsistent #1578

Open Jellby opened 2 years ago

Jellby commented 2 years ago

Regarding https://github.com/hgrecco/pint/pull/1454, I think the usage of as a symbol for Planck's constant is inconsistent (and inconvenient for my own usage, but I guess that's my problem). I already mentioned it in https://github.com/PainterQubits/Unitful.jl/issues/536#issuecomment-1225847077 without realizing that was a different project, so I thought I'd repeat it here.

Basically, if you change h to , you should also change ħ to , e to 𝑒 (elementary charge), G to 𝐺 (gravitational constant), etc. But my opinion is that these italic codepoints should not exist at all.

keewis commented 2 years ago

I guess the most convenient (and consistent) way would be a separate namespace for constants, as described in https://github.com/hgrecco/pint/issues/1078#issuecomment-950231900

Jellby commented 2 years ago

For the record: https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols

jules-ch commented 2 years ago

Problems occurs with clashing keys & string parsing. We cannot have both clashing of keys & string parsing of constants. Even with different namespaces, that's the weakness of dealing with strings only with parsing functions.

I'm not against using unicode for widely used constants since that's how they are printed in the literature (e.g. planck constant, gravital constants, light speed) and how you can differentiate from units. (see BIPM brochure about this).

Anyone got the ISO 80000-1 to see the chapter about constants, I wonder what they say about it.

About the use with namespaces, I really like the idea. Though if you want to keep the use of constants parsing in strings, strict no clashing policy need to be observed.

@Jellby, I think we can all agree h should be kept for hours, this is the standard symbol for it & I don't see us moving back on this change.

For those constants, I think using specific unicode & long version name should be enough when dealing with text.

Jellby commented 2 years ago

@jules-ch Indeed, I'm not suggesting to change the symbol for hours, but using the italic codepoint for Planck's constant only is inconsistent. For convenience and text parsing, there could be "shorthand" aliases , e.g. h_ or \h (and the same for other constants, which would allow using e for Euler's number and G for Gauss, if you wish...).

hgrecco commented 2 years ago

I agree with @keewis The most straightforward way is finally having the constants group!