-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Proposed ENH: Allow user to turn off breaking of streamlines in streamplot (rebased) #22707
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
It looks like the Windows and MacOS tests versions of the tests are failing, but passing on linux (which the images were created on), any suggestions about how to best fix that? |
The errors are 0.001 which is a pixel jumped somewhere. 1) you could make sure your data is not too aligned with integer values. 2) you could add a small tolerance. |
645f422
to
2ae5275
Compare
I've added a small tolerance (as that seems to be what the other tests had). Hopefully that'll fix the Windows/MacOS tests. |
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 seems good! A few technical things to fix...
lib/matplotlib/streamplot.py
Outdated
broken_streamlines : If False, forces streamlines to continue until they | ||
leave the plot domain. If True, they may be terminated if they | ||
come too close to another streamline. Default is True. | ||
|
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.
broken_streamlines : If False, forces streamlines to continue until they | |
leave the plot domain. If True, they may be terminated if they | |
come too close to another streamline. Default is True. | |
broken_streamlines : boolean, default: True | |
If False, forces streamlines to continue until they | |
leave the plot domain. If True, they may be terminated if they | |
come too close to another streamline. | |
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/streamplot.py
Outdated
except InvalidIndexError: | ||
return None | ||
if integration_direction in ['both', 'backward']: | ||
s, xyt = _integrate_rk12(x0, y0, dmap, backward_time, maxlength) | ||
s, xyt = _integrate_rk12(x0, y0, dmap, backward_time, maxlength, broken_streamlines) |
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.
fix line break here and below
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
@@ -34,6 +34,18 @@ def test_startpoints(): | |||
plt.plot(start_x, start_y, 'ok') | |||
|
|||
|
|||
@image_comparison(['streamplot_startpoints_no_broken'], remove_text=True, |
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.
We try to limit our image tests as they take substantial repo size. I would just choose your favourite of these, versus having all of them test this new functionality.
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 picked out the one with maxlength, as we may want that to raise an exception if we think this should conflict with it.
Includes some style changes as requested by the matplotlib devs.
2ae5275
to
aaeb4ea
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.
This looks good to me.
This needs a what's-new entry: doc/users/next_whats_new/
Optionally, you would add to one of the stream plot examples an example of using this. For simplicity I'd just add a second figure at the bottom of https://matplotlib.org/stable/gallery/images_contours_and_fields/plot_streamplot.html
which is in examples//images_contours_and_fields/plot_streamplot.py
. You could link the modified example in the what's-new entry above.
Looks like a bug in your what's-new example. |
5e42825
to
d190205
Compare
Ah, yep, I've now fixed that. I've been running tox, but only seeing the same errors that I see on main (which I'm putting down to my TeX installation being slightly different than the tests want), is there some other command I should run to catch flake8/documentation errors? |
You can try and build the docs, which is painfully slow or just wait for CI. Flake8 is available on conda (maybe pip?). |
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 looks good to me!
@aragilar we need two approvals. If this languishes, feel free to ping on maybe a weekly time scale! |
PR Summary
This is a rebased version of #17098 which adds tests. Note: based on
streamplot_maxlength_no_broken.png
, it appears this effective ignores themaxlength
argument whenbroken_streamlines=False
. This may or may not be the desired behaviour (maybe an exception should be raised?), but that should be discussed before merging. Feel free to interactively rebase as needed (e.g. to remove test images).PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).