8000 Throw ValueError when irregularly gridded data is passed to streamplot. by anntzer · Pull Request #12474 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Throw ValueError when irregularly gridded data is passed to streamplot. #12474

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 1 commit into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/api/api_changes/2018-10-10-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
`Axes.streamplot` now raises ValueError when an irregular grid is passed in
```````````````````````````````````````````````````````````````````````````

`Axes.streamplot` does not support irregularly gridded ``x`` and ``y`` values.
So far, it used to silently plot an incorrect result. This has been changed to
raise a ValueError instead.

The `.streamplot.Grid` class, which is internally used by streamplot code, also
throws a ValueError when irregularly gridded values are passed in.
5 changes: 5 additions & 0 deletions lib/matplotlib/streamplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ def __init__(self, x, y):
self.width = x[-1] - x[0]
self.height = y[-1] - y[0]

if not np.allclose(np.diff(x), self.width / (self.nx - 1)):
raise ValueError("'x' values must be equally spaced")
if not np.allclose(np.diff(y), self.height / (self.ny - 1)):
raise ValueError("'y' values must be equally spaced")

@property
def shape(self):
return self.ny, self.nx
Expand Down
0