Commit a27c6e77 authored by Daniel Scheffler's avatar Daniel Scheffler

Merge branch 'bugfix/fix_np_integer_indexing' into 'master'

Fixed issue #22 (GeoArray[slice, slice, np.integer] returns the full array...

Closes #22

See merge request !2
parents 9836f23d 9f48cd6d
Pipeline #11581 canceled with stages
...@@ -778,13 +778,13 @@ class GeoArray(object): ...@@ -778,13 +778,13 @@ class GeoArray(object):
if isinstance(givenR, slice): if isinstance(givenR, slice):
rS = givenR.start rS = givenR.start
rE = givenR.stop - 1 if givenR.stop is not None else None rE = givenR.stop - 1 if givenR.stop is not None else None
elif isinstance(givenR, int): elif isinstance(givenR, (int, np.integer)):
rS = givenR rS = givenR
rE = givenR rE = givenR
if isinstance(givenC, slice): if isinstance(givenC, slice):
cS = givenC.start cS = givenC.start
cE = givenC.stop - 1 if givenC.stop is not None else None cE = givenC.stop - 1 if givenC.stop is not None else None
elif isinstance(givenC, int): elif isinstance(givenC, (int, np.integer)):
cS = givenC cS = givenC
cE = givenC cE = givenC
...@@ -794,14 +794,14 @@ class GeoArray(object): ...@@ -794,14 +794,14 @@ class GeoArray(object):
if isinstance(givenB, slice): if isinstance(givenB, slice):
bS = givenB.start bS = givenB.start
bE = givenB.stop - 1 if givenB.stop is not None else None bE = givenB.stop - 1 if givenB.stop is not None else None
elif isinstance(givenB, int): elif isinstance(givenB, (int, np.integer)):
bS = givenB bS = givenB
bE = givenB bE = givenB
elif isinstance(givenB, (tuple, list)): elif isinstance(givenB, (tuple, list)):
typesInGivenB = [type(i) for i in givenB] typesInGivenB = [type(i) for i in givenB]
assert len(list(set(typesInGivenB))) == 1, \ assert len(list(set(typesInGivenB))) == 1, \
'Mixed data types within the list of bands are not supported.' 'Mixed data types within the list of bands are not supported.'
if isinstance(givenB[0], int): if isinstance(givenB[0], (int, np.integer)):
bL = list(givenB) bL = list(givenB)
elif isinstance(givenB[0], str): elif isinstance(givenB[0], str):
bL = [self.bandnames[i] for i in givenB] bL = [self.bandnames[i] for i in givenB]
...@@ -858,7 +858,7 @@ class GeoArray(object): ...@@ -858,7 +858,7 @@ class GeoArray(object):
if 1 in arr.shape: if 1 in arr.shape:
outshape = [] outshape = []
for i, sh in enumerate(arr.shape): for i, sh in enumerate(arr.shape):
if sh == 1 and isinstance(getitem_params[i], (int, float)): if sh == 1 and isinstance(getitem_params[i], (int, np.integer, float, np.floating)):
pass pass
else: else:
outshape.append(sh) outshape.append(sh)
......
__version__ = '0.8.11' __version__ = '0.8.12'
__versionalias__ = '20180214.01' __versionalias__ = '20190329.01'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment