Skip to content

Commit

Permalink
fix band indexing with negative tuple elements
Browse files Browse the repository at this point in the history
backport to 0.7.x
  • Loading branch information
njwilson23 committed Oct 8, 2016
1 parent 238a9eb commit 171b5d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions karta/raster/band.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def __getitem__(self, key):
kr, kc = key

if isinstance(kr, Integral):
yoff = kr
yoff = kr % self.size[0]
ny = 1
ystride = 1

Expand All @@ -207,7 +207,7 @@ def __getitem__(self, key):
"supported".format(type(kr)))

if isinstance(kc, Integral):
xoff = kc
xoff = kc % self.size[1]
nx = 1
xstride = 1

Expand Down
2 changes: 2 additions & 0 deletions tests/band_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def test_get_scalar(self):

self.assertEqual(band[4,3], 11.0)
self.assertTrue(band[4:5,3:4].shape, (1, 1))
self.assertEqual(band[-1,-1], d[-1,-1])
return

def test_initval(self):
band = self.type((1024, 1024), np.float64, initval=0.0)
Expand Down

0 comments on commit 171b5d9

Please sign in to comment.