-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove list(zip(...)) when unnecessary. #10102
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
a1b081e
to
0754b29
Compare
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.
Minor quibble, not a blocker.
lib/matplotlib/bezier.py
Outdated
@@ -279,7 +278,7 @@ def split_path_inout(path, inside, tolerence=0.01, reorder_inout=False): | |||
codes_left = [Path.CURVE4, Path.CURVE4, Path.CURVE4] | |||
codes_right = [Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4] | |||
else: | |||
raise ValueError() | |||
raise ValueError |
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.
Instead of returning the class, it would be better to supply some sort of error message, wouldn't it? Leaving the empty parenthesis is at least a flag for someone to supply that message.
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.
Edited accordingly. Given the context of the code I believe this line should never be reached (it is effectively following a switch on the result of an internal routine).
0754b29
to
d483482
Compare
examples/api/collections.py
Outdated
@@ -30,16 +30,14 @@ | |||
theta = np.linspace(0, 2*np.pi, nverts) | |||
xx = r * np.sin(theta) | |||
yy = r * np.cos(theta) | |||
spiral = list(zip(xx, yy)) | |||
spiral = np.column_stack([xx, yy]) | |||
|
|||
# Make some offsets | |||
# Fixing random state for reproducibility | |||
rs = np.random.RandomState(19680801) | |||
|
|||
|
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.
Might as well remove this extra line while you're here.
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.
done
examples/api/collections.py
Outdated
@@ -30,16 +30,14 @@ | |||
theta = np.linspace(0, 2*np.pi, nverts) | |||
xx = r * np.sin(theta) | |||
yy = r * np.cos(theta) | |||
spiral = list(zip(xx, yy)) | |||
spiral = np.column_stack([xx, yy]) | |||
|
|||
# Make some offsets |
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.
And move this comment down to above xyo
where it should be.
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.
done
lib/matplotlib/bezier.py
Outdated
left, right = split_bezier_intersecting_with_closedpath(bp, | ||
inside, | ||
tolerence) | ||
bp = np.column_stack([bezier_path[::2], bezier_path[1::2]]) |
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.
np.reshape(bezier_path, (-1, 2))
, no?
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.
indeed
Replace by zip(...) when the result is immediately unpacked. Replace by np.column_stack when operating on arrays or when the result will be immediately converted to an array (e.g. by the Path constructor), as column_stack is faster in these cases. (This commit does not remove *all* instances of list(zip(...)).)
d483482
to
81b0efc
Compare
added some more simplifications to bezier code as well. |
Replace by zip(...) when the result is immediately unpacked. Replace
by np.column_stack when operating on arrays or when the result will be
immediately converted to an array (e.g. by the Path constructor), as
column_stack is faster in these cases.
(This commit does not remove all instances of list(zip(...)).)
PR Summary
PR Checklist