Skip to content
Snippets Groups Projects
Commit 0db02ab8 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Use non-tuple indices for 1D indexing for compatibility with Python sequences

parent 5d2bc6b6
No related branches found
No related tags found
No related merge requests found
......@@ -866,9 +866,19 @@ class ArrayBase(Record):
if not sep_shape:
return None
def unwrap_1d_indices(idx):
# This allows these indices to work on Python sequences, too, not
# just numpy arrays.
if len(idx) == 1:
return idx[0]
else:
return idx
from pytools import indices_in_shape
return [
(i, self.name + "".join("_s%d" % sub_i for sub_i in i))
(unwrap_1d_indices(i),
self.name + "".join("_s%d" % sub_i for sub_i in i))
for i in indices_in_shape(sep_shape)]
# }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment