-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
BUG: Dot should not be spaced when used as a decimal separator #5301
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
Conversation
@@ -2504,7 +2504,8 @@ def symbol(self, s, loc, toks): | |||
break | |||
# Binary operators at start of string should not be spaced | |||
if (c in self._binary_operators and | |||
(len(s[:loc].split()) == 0 or prev_char == '{')): | |||
(len(s[:loc].split()) == 0 or prev_char == '{' or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should support everything in _left_delim
. Could probably just be prev_char
in self._left_delim
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, _left_delim
is definitely more general than (
. However, {
is not in _left_delim
(only \{
), so I'll do that comparison separately.
Can you try turning down the tolerance and seeing how many other tests fail and in what way? It would be good to know if there are any regressions.
|
@tacaswell did an overview of the mathtext tests with lower tolerance in #4887, but ended not using it because of lack of time in checking the images. Quite a lot of them fail with |
I didn't mean to lower the tolerance permanently, necessarily, just lower it enough to see if this change causes any regressions. I can probably find some time to sort through them soon. |
I did a run with
There are a lot of them related to recent PRs in which we did not replace the baseline images because the tests where not failing (#4887 for symbol spacing, #4403 for spacing symbols such as |
Regarding this PR, I don't think there are any relevant regressions. I believe it only affects test 03 where the baseline image is closer to this PR than the master render. Most of the other uses of decimal separators in the tests suite (tick labels mostly) are not in a mathtext enviroment, so this PR does not affect those. |
I have removed the new test because test 3 should have caught this problem if the tolerance was lower. When #5307 is merged, that test will be enough. |
BUG: Dot should not be spaced when used as a decimal separator
Backported to v2.0.x as 60b60fb |
BUG: Dot should not be spaced when used as a decimal separator
I removed the spacing after the dot when the previous and next characters are digits, i.e., when it is being used as a decimal separator.
I also sneaked in a change a few lines above so that binary operators will not be spaced after a parens (so that
$(-2)$
is not spaced as if it was an operation), see #5020.I added a test for this dot spacing issue, but given the high threshold for these tests I am not sure whether it would fail even if the spacing is as before this PR. At least it runs through the new code.
attn @mdboom