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: Ensure contiguous inputs to points_in_polygon #410

Merged
merged 1 commit into from
Jul 3, 2018

Conversation

jwiggins
Copy link
Member

@jwiggins jwiggins commented Jul 3, 2018

Ahem... Right. So, in #409, I said there was one other call to points_in_polygon, but it looked OK. Well, I was wrong. It was being called with a transposed input. This corrects that.

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

Again, LGTM.

Although can we do this without the transpose by using a different numpy stacking operation?

@jwiggins
Copy link
Member Author

jwiggins commented Jul 3, 2018

Yes:

In [10]: arr = np.hstack((index[:, np.newaxis], value[:, np.newaxis]))

In [11]: arr
Out[11]: 
array([[ 0, 10],
       [ 1,  9],
       [ 2,  8],
       [ 3,  7],
       [ 4,  6],
       [ 5,  5],
       [ 6,  4],
       [ 7,  3],
       [ 8,  2],
       [ 9,  1]])

In [12]: arr.__array_interface__
Out[12]: 
{'data': (4302308880, False),
 'descr': [('', '<i8')],
 'shape': (10, 2),
 'strides': None,
 'typestr': '<i8',
 'version': 3}

In [13]: np.vstack((index, value)).T
Out[13]: 
array([[ 0, 10],
       [ 1,  9],
       [ 2,  8],
       [ 3,  7],
       [ 4,  6],
       [ 5,  5],
       [ 6,  4],
       [ 7,  3],
       [ 8,  2],
       [ 9,  1]])

@corranwebster
Copy link
Contributor

Finally had a little bit of time to think about this and look things up: I think column_stack may be even better.

@jwiggins
Copy link
Member Author

jwiggins commented Jul 3, 2018

Indeed. New commit incoming along with a redo of the changes in #409

@corranwebster
Copy link
Contributor

👍

@jwiggins
Copy link
Member Author

jwiggins commented Jul 3, 2018

Thanks for the input & review

@jwiggins jwiggins merged commit 09bef59 into master Jul 3, 2018
@jwiggins jwiggins deleted the fix/moar-p-in-p branch July 3, 2018 11:51
@jwiggins jwiggins mentioned this pull request Jul 12, 2018
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

2 participants