-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Various style fixes. #10569
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
Various style fixes. #10569
Conversation
if key.startswith('l'): continue | ||
pw, ph = papersize[key] | ||
if (w < pw) and (h < ph): return key | ||
for key, (pw, ph) in sorted(papersize.items())[::-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.
Use sorted(..., reverse=True)
?
if type == 'rotate' and value == (0.0,): | ||
if (type == 'scale' and (value == (1.0,) or value == (1.0, 1.0)) | ||
or type == 'translate' and value == (0.0, 0.0) | ||
or type == 'rotate' and value == (0.0,)): |
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.
leave out all the zeros after the decimal point?
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.
actually even the decimal point is not necessary ((1., 1.) == (1, 1))
@@ -252,10 +250,8 @@ def random_ports(port, n): | ||
raise |
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.
maybe slightly more readable:
try:
app.listen(port, cls.address)
cls.port = port
break
except socket.error as e:
if e.errno != errno.EADDRINUSE:
raise
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.
tend to prefer the try really only surrounding the potentially exception-raising code.
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.
lib/matplotlib/mathtext.py
Outdated
@@ -1557,12 +1557,10 @@ def _determine_order(self, totals): | ||
A helper function to determine the highest order of glue |
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.
Should be a staticmethod.
lib/matplotlib/mathtext.py
Outdated
break | ||
return o | ||
return i |
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'd return 0
here and return i
instead of break.
all comments handled |
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.
conditional on CI pass
name for name, obj in globals().items() | ||
if not name.startswith('_') and name not in exclude | ||
and inspect.isfunction(obj) | ||
and inspect.getmodule(obj) is this_module) |
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.
Side note: as an argument to sorted
, using a list comprehension is faster than using a bare generator:
In [10]: timeit sorted([i for i in range(100)])
7.52 µs ± 119 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [11]: timeit sorted(i for i in range(100))
10.1 µs ± 223 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
Of course, it doesn't matter unless one is dealing with a large number of items or calls.
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.
Actually I'm puzzled how that can be the case. https://bugs.python.org/issue32945
"tick_levels": dict(left=[], bottom=[], right=[], top=[]), | ||
"tick_locs": dict(left=[], bottom=[], right=[], top=[]), | ||
"lines": [], | ||
} |
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 OK, but I have a mild style preference for using dict()
whenever possible:
gi = dict(values=[],
levels=[],
tick_levels=dict(left=[], bottom=[], right=[], top=[]),
#etc.
)
PR Summary
Closes (among other things) item 3 of #10556.
PR Checklist