Skip to content

Commit

Permalink
[vectorarrays] support iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
sdrave committed Apr 11, 2017
1 parent 1268798 commit ed5eff0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/pymor/vectorarrays/list.py
Expand Up @@ -242,7 +242,10 @@ def __len__(self):
return len(self._list)

def __getitem__(self, ind):
return ListVectorArrayView(self, ind)
try:
return ListVectorArrayView(self, ind)
except Exception as e:
raise IndexError(e)

def __delitem__(self, ind):
assert self.check_ind(ind)
Expand Down
10 changes: 8 additions & 2 deletions src/pymor/vectorarrays/numpy.py
Expand Up @@ -52,7 +52,10 @@ def __len__(self):
return self._len

def __getitem__(self, ind):
return NumpyVectorArrayView(self, ind)
try:
return NumpyVectorArrayView(self, ind)
except Exception as e:
raise IndexError(e)

def __delitem__(self, ind):
assert self.check_ind(ind)
Expand Down Expand Up @@ -427,7 +430,10 @@ def __len__(self):
return self.base.len_ind(self.ind)

def __getitem__(self, ind):
return self.base[self.base.sub_index(self.ind, ind)]
try:
return self.base[self.base.sub_index(self.ind, ind)]
except Exception as e:
raise IndexError(e)

def __delitem__(self):
raise ValueError('Cannot remove from NumpyVectorArrayView')
Expand Down

0 comments on commit ed5eff0

Please sign in to comment.