Skip to content

Commit

Permalink
We could have negative step from indexing, but we don't want a negati…
Browse files Browse the repository at this point in the history
…ve shape
  • Loading branch information
Aaron Parsons authored and takluyver committed Jun 24, 2018
1 parent 7e78838 commit ace8955
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions h5py/_hl/group.py
Expand Up @@ -644,9 +644,9 @@ def __getitem__(self, *key):
new_shape = ()
for ix,sl in enumerate(tmp.slice_list):
start = 0 if sl.start is None else sl.start
step = 0 if sl.step is None else sl.step
step = 1 if sl.step is None else sl.step
stop = self.shape[ix]
new_shape+=((stop-start)/step,)
new_shape+=((stop-start)/abs(step),)
tmp.slice_list[ix] = slice(start,stop,step)
tmp.shape = new_shape
return tmp
Expand All @@ -660,8 +660,8 @@ def __getitem__(self, *key):
if (len(self.shape)-len(key))<0:
raise IndexError('Index rank is greater than dataset rank')
tmp = copy(self)
tmp.slice_list = list(key[0] + (slice(None, None, None),)*(len(self.shape)-len(key[0]))) # generate the right slice
tmp.slice_list = [slice(ix) if isinstance(ix, (int,float)) else ix for ix in tmp.slice_list]
tmp.slice_list = list(key[0] + (slice(None, None, None),)*(len(self.shape)-len(key[0]))) # generate the right slice_list length
tmp.slice_list = [slice(ix) if isinstance(ix, (int,float)) else ix for ix in tmp.slice_list]# cope with integers
return tmp


Expand Down

0 comments on commit ace8955

Please sign in to comment.