-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Prefer concatenate to h/vstack in simple cases. #19332
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
lib/matplotlib/markers.py
Outdated
right = Path(verts[(0, 5, 4, 3), :]) | ||
top = Path(np.concatenate([[(-x, 0)], verts[[1, 0, 5]], [(x, 0)]])) | ||
bottom = Path(np.concatenate([[(-x, 0)], verts[2:5], [(x, 0)]])) | ||
left = Path(verts[[0, 1, 2, 3]]) |
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.
left = Path(verts[[0, 1, 2, 3]]) | |
left = Path(verts[:4]) |
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 to all
lib/matplotlib/markers.py
Outdated
[-x, -y], [x, y]))) | ||
right = Path(np.vstack(([x, y], verts[(5, 4, 3), :], [-x, -y]))) | ||
top = Path(verts[[1, 0, 5, 4, 1]]) | ||
bottom = Path(verts[[1, 2, 3, 4]]) |
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.
bottom = Path(verts[[1, 2, 3, 4]]) | |
bottom = Path(verts[1:5]) |
lib/matplotlib/markers.py
Outdated
top = Path(verts[[1, 0, 5, 4, 1]]) | ||
bottom = Path(verts[[1, 2, 3, 4]]) | ||
left = Path(np.concatenate([ | ||
[(x, y)], verts[[0, 1, 2]], [(-x, -y), (x, y)]])) |
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.
[(x, y)], verts[[0, 1, 2]], [(-x, -y), (x, y)]])) | |
[(x, y)], verts[:3], [(-x, -y), (x, y)]])) |
lib/matplotlib/markers.py
Outdated
left = Path(np.concatenate([ | ||
[(x, y)], verts[[0, 1, 2]], [(-x, -y), (x, y)]])) | ||
right = Path(np.concatenate([ | ||
[(x, y)], verts[[5, 4, 3]], [(-x, -y)]])) |
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.
[(x, y)], verts[[5, 4, 3]], [(-x, -y)]])) | |
[(x, y)], verts[5:2:-1], [(-x, -y)]])) |
concatenate is (much) faster than hstack, while being essentially equivalent in the 1D case; when working on 2D arrays it can replace vstack too.
concatenate is (much) faster than hstack, while being essentially
equivalent in the 1D case; when working on 2D arrays it can replace
vstack too.
Timings:
PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).