Commit 187d3491 authored by Cheuk Ting Ho's avatar Cheuk Ting Ho Committed by Stefan Behnel

stop generating code that compiler skips

parent 103e4f22
......@@ -852,28 +852,40 @@ if (unlikely(__pyx_memoryview_slice_memviewslice(
{
Py_ssize_t __pyx_tmp_idx = {{idx}};
Py_ssize_t __pyx_tmp_shape = {{src}}.shape[{{dim}}];
{{if wraparound or boundscheck}}
Py_ssize_t __pyx_tmp_shape = {{src}}.shape[{{dim}}];
{{endif}}
Py_ssize_t __pyx_tmp_stride = {{src}}.strides[{{dim}}];
if ({{wraparound}} && (__pyx_tmp_idx < 0))
__pyx_tmp_idx += __pyx_tmp_shape;
{{if wraparound}}
if (__pyx_tmp_idx < 0)
__pyx_tmp_idx += __pyx_tmp_shape;
{{endif}}
if ({{boundscheck}} && !__Pyx_is_valid_index(__pyx_tmp_idx, __pyx_tmp_shape)) {
{{if not have_gil}}
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
{{endif}}
{{if boundscheck}}
if (!__Pyx_is_valid_index(__pyx_tmp_idx, __pyx_tmp_shape)) {
{{if not have_gil}}
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
{{endif}}
PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis {{dim}})");
PyErr_SetString(PyExc_IndexError,
"Index out of bounds (axis {{dim}})");
{{if not have_gil}}
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
{{endif}}
{{if not have_gil}}
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
{{endif}}
{{error_goto}}
}
{{error_goto}}
}
{{else}}
// make sure label is not un-used
if ((0)) {{error_goto}}
{{endif}}
{{if all_dimensions_direct}}
{{dst}}.data += __pyx_tmp_idx * __pyx_tmp_stride;
......
# mode: run
cimport cython
@cython.boundscheck(False)
@cython.wraparound(False)
def testing_memoryview(double[:, :] x):
""" Function testing boundscheck and wraparound in memoryview
>>> import numpy as np
>>> array = np.ones((2,2)) * 3.5
>>> testing_memoryview(array)
"""
cdef Py_ssize_t numrow = x.shape[0]
cdef Py_ssize_t i
for i in range(numrow):
x[i, 0]
x[i]
x[i, ...]
x[i, :]
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