-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
bracket flag #113
Comments
Do you have a reference about the correct format having parentheses? (This vaguely reminds me of a discussion one of my colleagues at the National Institute of Standards and Technology had, one day, arguing that the part before "±" should have explicit units!) I do agree that if you want to ensure that the printed value does have parenthesis, this should be handled by the uncertainties package as a way of formatting numbers with uncertainty. |
No, I don't have a written reference about the correct format, but it is obvious that parens are needed when having non-1 units. It simply does not make sense if the uncertainty has a different unit (e. g. 1) than the n value. That is equivalent to the addition (subtraction) of two values with different units. What is a second added to a meter? What the sum of 5 lux and 6 degrees? |
The pull request (#116) I created is ready for review, I think.
|
Thanks for the pull request. The number formatting code is probably the most complex in the whole library! I must say that I fail to see the relationship between not being able to add quantities with incompatible units and the need for parentheses. In fact, I do read "1±0.2 m" as "(1±0.2) m", precisely for the reason that you quote: any other interpretation would not make sense, so here we're obviously adding adding 1 meter and ±0.2 meter. Now, since you feel the need for this and since an additional format does not really complicate the API, I will have a look at the pull request and consider it for inclusion. I want to first handle the ongoing move to wheels, that impacts a couple of other programs (#112), though. Codes "b" and "B" are however not my favorites:
What about using "p" instead, like in "parenthesis"? ("P" is already used by uncertainties for pretty-printing.) |
Thanks a lot for accepting that without you feeling that need alike! I am quite used to the parenthesis, since the siunitx latex package automatically adds parens when a unit is specified (and leaves them out if not). You are right that b is not the best choice, but a strong and weak version of the flag are reasonable: for most applications (e. g. units) the weak flag is enough, but if someone wants to have parens surrounding everything and does |
What behavior do you have in mind exactly with the weak and strong versions of the flag that you are proposing? Don't hesitate to give examples. Thanks! PS: here is what I understand from the tests you added:
PPS: I therefore have a question: the strong version can always be obtained with the standard |
Yes, that is what the flags should do, exactly!
You are right! But if you prefer to write However, tell me what you think is best! |
Good point, about the special LaTeX parentheses. A library is here to help people, and letting people write convenient code instead of reimplementing the same thing independently over and over is part of this. I am thus good with having a strong form of the new parentheses flag.
Let me have a look at the implementation (and documentation of the flag behaviors). My conclusion about the SIunitx package (#117) is that it is best that it learn how to parse uncertainties with a decimal point, as in 123.4(5.6): this is the convention used in a major reference (the definition of fundamental constants). |
@lebigot The builds are passing, should I try to implement this feature now? |
Ah, yes, good point, that would be great! Now is a good time. |
The pull request passes the tests. Without the bugfixes that my previous attempt had, it is only +42 -4 lines (22 lines of documentation). |
Thanks a lot! My weekends are taken by two children, and my evenings by some other project that I would like to finish, currently, but when my evenings clear up, I'll review this. I am sorry for the delay. |
I am checking the documentation updated in pull request #128. I am sorry to come back to a point that we have discussed above, but I am not seeing anymore how forcing parentheses (with
I agreed that it is nice to let the user switch from pure text to LaTeX easily, and the idea of having To summarize, I am wondering how relevant it is to have the strong flag ( |
Since this issue is 10 months old, I had to think a moment about that, to be honest. f'Although our result ${result:RL)$ was close to the expected value, the uncertainty of it is relatively high....' would produce (GitHub sadly does not support TeX, so it looks as if produced with {:RP})
(Of course, This could be used when the result was calculated elsewhere and this is the final conclusion let's say... That is the only case I could come up with at this moment. There might be other ones or maybe not, I don't know. It is totally up to you... |
Thanks for the feedback. These were precisely my thoughts (including the potentially larger parentheses in the LaTeX output). It's useful to know we think the same. I am more concerned about making the API more bloated, as this is what most people see, so I'll remove the unconditional flag ( This means that the "weak" parentheses can now be requested with a I'll update the pull request as needed. |
Pull request updated and integrated in https://github.com/lebigot/uncertainties/releases/tag/3.1.5. Thanks! |
I wonder if it would be possible to add a
b
(bracket) flag as a format specifier to always have enclosing brackets (force!) with a common factor (optionally). This would be heavily useful for stuff with units:The correct format is
(0.8265±0.0735)×10⁻³ m = (0.8265±0.0735) mm
, not0.8265±0.0735 mm
.The right place to check for the common factor / enclosing brackets is this package I think, not in the user's module.
The text was updated successfully, but these errors were encountered: