-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
apply unary minus spacing directly after equals sign #28186
base: main
Are you sure you want to change the base?
Conversation
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
The fix looks plausible (although there's also the case of a leading minus at the beginning of a equation, perhaps?). Did you check the TeXbook for reference? |
lib/matplotlib/_mathtext.py
Outdated
@@ -2285,7 +2285,7 @@ def symbol(self, s: str, loc: int, | |||
if (self._in_subscript_or_superscript or ( | |||
c in self._binary_operators and ( | |||
len(s[:loc].split()) == 0 or prev_char == '{' or | |||
prev_char in self._left_delims))): | |||
prev_char in self._left_delims or prev_char == '='))): |
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.
It should not just be =, but all relational operators.
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.
good idea, I will change that
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.
There's a comment above the if
that could be updated.
lib/matplotlib/_mathtext.py
Outdated
len(s[:loc].split()) == 0 or prev_char == '{' or | ||
prev_char in self._left_delims))): | ||
prev_char in self._left_delims or | ||
prev_char in self._relation_symbols))): |
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.
These could be compressed:
len(s[:loc].split()) == 0 or prev_char == '{' or | |
prev_char in self._left_delims))): | |
prev_char in self._left_delims or | |
prev_char in self._relation_symbols))): | |
len(s[:loc].split()) == 0 or | |
prev_char in {'{', *self._left_delims, *self._relation_symbols}))): |
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.
I made the change you suggested and tested it.
PR summary
Fixes a visual inconsistency where mathtext does not modify the spacing around a unary minus sign after an equals sign like it does for a unary minus sign after a closing parenthesis. Closes #28180.
PR checklist