-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Minor simplifications to backend_svg. #12423
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
same_y = False | ||
break | ||
if same_y: | ||
if len({y for x, y, t in chars}) == 1: |
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 is shorter - but not a simplification (at least for me).
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 think it's much clearer what this does...
I can do
same_y = (len(...) == 1)
if same_y: ...
I guess that gets the best of both worlds?
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.
Its the curly braces: I have no idea what that does.
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's a set comprehension: https://docs.python.org/3/tutorial/datastructures.html#sets
The question is whether all y's are the same. So you build a set with all y's and check whether its size is 1.
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.
OK, I see. Each chars is 3-long, so x,y, t is juts unpacking the list. Suggest short comment:
# check if all the y values (second element of each chars) are the same using set comprehension.
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.
Would prefer the comment. Thanks for walking me through it
added comment |
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.
+ one typo
# coordinate will be flipped when this characters are | ||
# used. | ||
# We store the character glyphs w/o flipping. Instead, the | ||
# coordinate will be flipped when this characters are used. |
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 characters or this character
CI passed before minor typo in comment fix, so merging... |
PR Summary
PR Checklist