Skip to content

FIX: Ensure contiguous inputs to points_in_polygon#410

Merged
jwiggins merged 1 commit into
masterfrom
fix/moar-p-in-p
Jul 3, 2018
Merged

FIX: Ensure contiguous inputs to points_in_polygon#410
jwiggins merged 1 commit into
masterfrom
fix/moar-p-in-p

Conversation

@jwiggins
Copy link
Copy Markdown
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.

@jwiggins jwiggins requested a review from corranwebster July 3, 2018 09:59
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

jwiggins commented Jul 3, 2018

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

@corranwebster
Copy link
Copy Markdown
Contributor

👍

@jwiggins
Copy link
Copy Markdown
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.

2 participants