Skip to content

Commit

Permalink
Deal properly with scalar PixCoords
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Nov 30, 2016
1 parent 8b232cf commit bf3f349
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions regions/shapes/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ def area(self):
raise NotImplementedError

def contains(self, pixcoord):
return points_in_polygon(pixcoord.x.astype(float),
pixcoord.y.astype(float),
if pixcoord.isscalar:
x = np.array([pixcoord.x], dtype=float)
y = np.array([pixcoord.y], dtype=float)
else:
x = pixcoord.x.astype(float)
y = pixcoord.y.astype(float)
return points_in_polygon(x, y,
self.vertices.x.astype(float),
self.vertices.y.astype(float)).astype(bool)

Expand Down

0 comments on commit bf3f349

Please sign in to comment.