Commit b2658ad3 authored by Stefan Behnel's avatar Stefan Behnel

clean up some instances of suboffsets handling in memoryview code

parent 2799242d
......@@ -526,7 +526,7 @@ cdef class memoryview(object):
@cname('__pyx_memoryview_get_suboffsets')
def __get__(self):
if self.view.suboffsets == NULL:
return [-1] * self.view.ndim
return (-1,) * self.view.ndim
return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
......@@ -654,9 +654,8 @@ cdef tuple _unellipsify(object index, int ndim):
return have_slices or nslices, tuple(result)
cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
cdef int i
for i in range(ndim):
if suboffsets[i] >= 0:
for suboffset in suboffsets[:ndim]:
if suboffset >= 0:
raise ValueError("Indirect dimensions not supported")
#
......@@ -1024,10 +1023,7 @@ cdef void slice_copy(memoryview memview, {{memviewslice_name}} *dst):
for dim in range(memview.view.ndim):
dst.shape[dim] = shape[dim]
dst.strides[dim] = strides[dim]
if suboffsets == NULL:
dst.suboffsets[dim] = -1
else:
dst.suboffsets[dim] = suboffsets[dim]
dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
@cname('__pyx_memoryview_copy_object')
cdef memoryview_copy(memoryview memview):
......@@ -1291,21 +1287,21 @@ cdef int memoryview_copy_contents({{memviewslice_name}} src,
return 0
@cname('__pyx_memoryview_broadcast_leading')
cdef void broadcast_leading({{memviewslice_name}} *slice,
cdef void broadcast_leading({{memviewslice_name}} *mslice,
int ndim,
int ndim_other) nogil:
cdef int i
cdef int offset = ndim_other - ndim
for i in range(ndim - 1, -1, -1):
slice.shape[i + offset] = slice.shape[i]
slice.strides[i + offset] = slice.strides[i]
slice.suboffsets[i + offset] = slice.suboffsets[i]
mslice.shape[i + offset] = mslice.shape[i]
mslice.strides[i + offset] = mslice.strides[i]
mslice.suboffsets[i + offset] = mslice.suboffsets[i]
for i in range(offset):
slice.shape[i] = 1
slice.strides[i] = slice.strides[0]
slice.suboffsets[i] = -1
mslice.shape[i] = 1
mslice.strides[i] = mslice.strides[0]
mslice.suboffsets[i] = -1
#
### Take care of refcounting the objects in slices. Do this seperately from any copying,
......
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