Skip to content

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

Merged
merged 3 commits into from
Apr 12, 2022

Conversation

aragilar
Copy link
Contributor

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 the maxlength argument when broken_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

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@aragilar
Copy link
Contributor Author

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?

@jklymak
Copy link
Member

jklymak commented Mar 26, 2022

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.

@aragilar aragilar force-pushed the no_broken_streamlines branch from 645f422 to 2ae5275 Compare March 27, 2022 02:57
@aragilar
Copy link
Contributor Author

I've added a small tolerance (as that seems to be what the other tests had). Hopefully that'll fix the Windows/MacOS tests.

Copy link
Member

@jklymak jklymak left a 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...

Comment on lines 73 to 77
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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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)
Copy link
Member

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

Copy link
Contributor Author

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,
Copy link
Member

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.

Copy link
Contributor Author

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.

@jklymak jklymak added this to the v3.6.0 milestone Mar 29, 2022
Includes some style changes as requested by the matplotlib devs.
@aragilar aragilar force-pushed the no_broken_streamlines branch from 2ae5275 to aaeb4ea Compare April 1, 2022 06:57
Copy link
Member

@jklymak jklymak left a 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.

@jklymak
Copy link
Member

jklymak commented Apr 1, 2022

Looks like a bug in your what's-new example.

@aragilar aragilar force-pushed the no_broken_streamlines branch from 5e42825 to d190205 Compare April 1, 2022 10:05
@aragilar
Copy link
Contributor Author

aragilar commented Apr 1, 2022

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?

@jklymak
Copy link
Member

jklymak commented Apr 1, 2022

You can try and build the docs, which is painfully slow or just wait for CI. Flake8 is available on conda (maybe pip?).

@oscargus oscargus added the status: needs workflow approval For PRs from new contributors, from which GitHub blocks workflows by default. label Apr 1, 2022
Copy link
Member

@jklymak jklymak left a 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!

@jklymak
Copy link
Member

jklymak commented Apr 8, 2022

@aragilar we need two approvals. If this languishes, feel free to ping on maybe a weekly time scale!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs workflow approval For PRs from new contributors, from which GitHub blocks workflows by default.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants