-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Avoid temporaries when preparing step plots. #7454
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Avoid temporaries when preparing step plots.
The previous implementation of `pts_to_{pre,mid,post}`step was fairly unefficient: it allocated a large array during validation (`vstack`), then a second array to build the return tuple, then converted the columns to a tuple, then immediately converted the tuple back to a new array at the call site (to construct a Path). Instead, just create a single array and work with it all along. Also some minor related cleanups (moving imports in lines.py, in particular not exposing the individual `pts_to_*step` functions anymore (they are not directly used, only via the `STEP_LOOKUP_MAP` mapping).
- Loading branch information
commit cd2608e7caf8fc56a8e7d1be723658724c7a62c2
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Functions removed from the `lines` module | ||
````````````````````````````````````````` | ||
|
||
The `matplotlib.lines` module no longer imports the `pts_to_prestep`, | ||
`pts_to_midstep` and `pts_to_poststep` functions from the `matplotlib.cbook` | ||
module. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,18 +460,14 @@ def test_to_midstep(): | |
assert_array_equal(y1_target, y1s) | ||
|
||
|
||
def test_step_fails(): | ||
@pytest.mark.parametrize( | ||
"args", | ||
[(np.arange(12).reshape(3, 4), 'a'), | ||
(np.arange(12), 'a'), | ||
(np.arange(12), np.arange(3))]) | ||
def test_step_fails(args): | ||
with pytest.raises(ValueError): | ||
cbook._step_validation(np.arange(12).reshape(3, 4), 'a') | ||
|
||
with pytest.raises(ValueError): | ||
cbook._step_validation(np.arange(12), 'a') | ||
|
||
with pytest.raises(ValueError): | ||
cbook._step_validation(np.arange(12)) | ||
|
||
with pytest.raises(ValueError): | ||
cbook._step_validation(np.arange(12), np.arange(3)) | ||
cbook.pts_to_prestep(*args) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case got dropped. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above re don't error when no y is passed. |
||
|
||
def test_grouper(): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Looks like this no longer raises if there are no y-values. I think I am 👍 on this, but just checking that it was intentional.
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, I even removed the test for that (
test_step_fails
).