-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
points_in_path can fail with NaN data #3759
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
mdboom
commented
Nov 5, 2014
Good point. It should be an easy enough fix. |
Fix attached. This may require some non-straightforward merging to master, but I'll deal with that once this is merged. |
box = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]) | ||
p = Path(box) | ||
test = np.array([[np.nan, 0.5]]) | ||
assert p.contains_points(test)[0] == False |
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 would also add a test on the length.
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.
and pep8 seems to want this to be assert not p.contaions_point(test)[0]
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.
Cool. I've fixed both.
Looks good |
points_in_path can fail with NaN data
p = Path(box) | ||
test = np.array([[np.nan, 0.5]]) | ||
contains = p.contains_points(test) | ||
assert len(contains) == 1 |
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.
why isn't the length 2?
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.
Because "test" is length 1
On Fri, Nov 7, 2014 at 9:05 AM, Thomas A Caswell notifications@github.com
wrote:
In lib/matplotlib/tests/test_path.py:
@@ -61,6 +61,15 @@ def test_path_clipping():
xy, facecolor='none', edgecolor='red', closed=True))+def test_point_in_path_nan():
- box = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]])
- p = Path(box)
- test = np.array([[np.nan, 0.5]])
- contains = p.contains_points(test)
- assert len(contains) == 1
why isn't the length 2?
—
Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3759/files#r20011300.
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.
Yeah -- a single point (which is an x, y pair) is being tested.
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.
Right, sorry for the brains-bar comment.
On Fri Nov 07 2014 at 11:23:55 AM Michael Droettboom <
notifications@github.com> wrote:
In lib/matplotlib/tests/test_path.py:
@@ -61,6 +61,15 @@ def test_path_clipping():
xy, facecolor='none', edgecolor='red', closed=True))+def test_point_in_path_nan():
- box = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]])
- p = Path(box)
- test = np.array([[np.nan, 0.5]])
- contains = p.contains_points(test)
- assert len(contains) == 1
Yeah -- a single point (which is an x, y pair) is being tested.
—
Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3759/files#r20019732.
Conflicts: src/_path.cpp src/_path.cpp has been deleted on master, need to apply the changes to fix matplotlib#3759 to src/_path.h