Skip to content

Commit

Permalink
fixed Polygon to pass a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBarker-NOAA committed Jan 20, 2018
1 parent 071591d commit 0c735a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion py_gnome/gnome/utilities/geometry/polygons.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ def __array_wrap__(self, out_arr, context=None):

def __getitem__(self, index):
"""
Override __getitem__ to return a simple (2, ) ndarray, rather than a
Override __getitem__ to return a ndarray, rather than a
Polygon object
"""
if type(index) is slice:
return Polygon(np.ndarray.__getitem__(self, index), self.metadata)
return np.asarray(np.ndarray.__getitem__(self, index))

def __eq__(self, other):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test_index2(self):
def test_slice(self):
P = Polygon([(1, 2), (3, 4), (5, 6)])
print P[:2]
print Polygon([(1, 2), (3, 4)])[:]
assert P[:2] == Polygon([(1, 2), (3, 4)])

def test_metadata(self):
Expand Down

0 comments on commit 0c735a5

Please sign in to comment.