Skip to content
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

Fix issue #6003 #6011

Merged
merged 6 commits into from Mar 20, 2016
Merged

Fix issue #6003 #6011

merged 6 commits into from Mar 20, 2016

Conversation

galaunay
Copy link

#6003

Instreamplot, skip start_points that are on an existing streamline instead of raising InvalidIndexError.

@WeatherGod
Copy link
Member

Should add a unit test to exercise this case.

On Tue, Feb 16, 2016 at 5:49 PM, muahah notifications@github.com wrote:

In streamplot, skip start_points that are on an existing streamline

instead of raising InvalidIndexError.

You can view, comment on, or merge this pull request online at:

#6011
Commit Summary

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#6011.

@galaunay
Copy link
Author

Run into another problem while adding a test case :
streamplot() accept 1d or 2d arrays for x and y arguments.
But trying to use 2d arrays while specifying start_points lead to an error.
At a first though, transforming x and y to 1d arrays at streamplot.py:140 should fix the problem.
I will try to do so soon.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Feb 17, 2016
@tacaswell
Copy link
Member

attn @tonysyu

@galaunay
Copy link
Author

I fixed issue #6003 and added a test case for streamplot() with non-null start_points argument.
The test case raised an error because of the use of 2-dimensionnal arrays for x and y (Grid class, that normally deal with 2-dimensionnal arrays is not called in that case), so I made some changes for that too.

sp2[:, 0] += np.abs(x[0][0])
sp2[:, 1] += np.abs(y[0][0])
else:
raise ValueError("'x' and 'y' should have the same dimensions")
Copy link
Member

Choose a reason for hiding this comment

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

This message is not strictly correct if, e.g., x.ndim == y.ndim == 3.

@galaunay
Copy link
Author

By looking more closely, those checks are redundant because Grid already checks x and y (ndim and values).
Grid also extract x and y origins that can be re-used to shift the seed points, instead of getting them from data.

@QuLogic
Copy link
Member

QuLogic commented Mar 2, 2016

So is this complete? None of the streamlines in the test image appear to originate at the plotted points.

Also, the file names do not need "test_image" in them; it's clear it's a test image from the directory.

@galaunay
Copy link
Author

galaunay commented Mar 2, 2016

I pointed out the fact that streamlines do not exactly originate from starting points in #6002.
Don't know yet if particular seeding positions on the grid are needed by the streamline algorithm or if there is just a problem while passing between data coordinates and grid coordinates.
I will keep looking on that.
I don't know if it belongs to another pull request or not.

Regarding the image names, I can change them.

@tacaswell
Copy link
Member

Please do not merge the master branch into your branch. Instead rebase your branch on top of current master and then force-push to your gh repo.

@galaunay
Copy link
Author

galaunay commented Mar 7, 2016

I realize that this pull request is a bit messy (I'm slowly getting used to git and github).

Does it sound good to you if we close it so I can open a new (clean) pull request for issues #6002 and #6003 when it will be ready ?

@tacaswell
Copy link
Member

The easiest thing to do is to fix this is to rebase + force push. I just did the rebase locally and there is fortunately no conflicts so (I am going to assume that your upsrteam remote is called 'matplotlib' and the remote pointing at your gh account is called origin

# update your computer to know what gh knows
git remote update  
# make sure you are one the branch this PR looks at
git checkout master
# rebase onto current master
git rebase matplotlib/master
# check gitk to make sure tis went well

# fail to push to your gh for pedagogical reasons 
git push origin master:master
# try again with --force, only use this when you are sure
git push --force origin master:master

@galaunay
Copy link
Author

Thank you, this is better now.
I think this is it, I had to change the way the function pass from data coordinates to internal grid coordinates (the bug was here).
After that some tests failed with low RMS (0.001 and 0.072).
Theoretically, the change made should not modify the result from streamplot(start_points=None) but it indeed change the way data are passed from and to grid coordinates. So I assume small differences in tests are due to numerical errors...

@tacaswell
Copy link
Member

It looks like you added some new test images and then modified them in later commits. Can you squash these down into a single commit so that the repository does not carry around the (wrong) intermediary results?

muahah added 6 commits March 19, 2016 20:28
Starting points on the same streamline don't raise IndexInvalidError anymore.
Fix passage from data to grid coordinates for starting points.
Raise an explicit error when specified starting points are outside of
the data boundaries.
With specified 'start_points'.
Change in 'streamplot' slightly modified some test cases
@galaunay
Copy link
Author

I rebased the whole thing to have clean an explicit commits (and no intermediary results).

@tacaswell
Copy link
Member

Thanks!

The lower left point in the start point test does fall exactly on the stream line. Is that expected?

@galaunay
Copy link
Author

The streamline do not originate from this point but from the point in the very corner (-3; -3).
the point at (-2.33, -2.33) is ignored because too close to an existing streamline (c.f. e9ddd00).
It is possible to get it back by increasing the density parameter.

@tacaswell
Copy link
Member

Ah, I missed that point was there.

tacaswell added a commit that referenced this pull request Mar 20, 2016
@tacaswell tacaswell merged commit 9110be0 into matplotlib:master Mar 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants