pythran icon indicating copy to clipboard operation
pythran copied to clipboard

Error when setting values of 2d array with index array

Open cycomanic opened this issue 3 years ago • 0 comments

I'm encountering an error when setting values of a 2d array using 0.9.7 (will test master later).

Simplest reproducible test case:

import numpy as np

#pythran export draw_line(int32[][])
def draw_line(grid):
    x = np.arange(0, grid.shape[1]//2).astype(int)
    grid[:, x] = 1

error:

building 'test_pt' extension
C compiler: g++ -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -fPIC

creating /tmp/tmp3_l_6d8g/tmp
compile options: '-DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DPYTHRAN_BLAS_OPENBLAS -I/home/jschrod/.local/lib/python3.8/site-packages/pythran -I/usr/lib64/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c'
extra options: '-std=c++11 -fno-math-errno -w -fvisibility=hidden -fno-wrapv'
g++: /tmp/tmp49tylgd3.cpp
In file included from /home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/ndarray.hpp:39,
                 from /home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/types/ndarray.hpp:4,
                 from /home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/types/tuple.hpp:13,
                 from /home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/builtins/bool_.hpp:7,
                 from /home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/types/NoneType.hpp:8,
                 from /home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/types/slice.hpp:5,
                 from /home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/core.hpp:29,
                 from /tmp/tmp49tylgd3.cpp:1:
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp: In instantiation of ‘struct {anonymous}::pythonic::types::numpy_gexpr<{anonymous}::pythonic::types::ndarray<int, {anonymous}::pythonic::types::pshape<long int, long int> >, {anonymous}::pythonic::types::contiguous_normalized_slice, {anonymous}::pythonic::types::ndarray<long int, {anonymous}::pythonic::types::array_base<long int, 1, {anonymous}::pythonic::types::tuple_version> > >’:
/tmp/tmp49tylgd3.cpp:54:9:   required from ‘typename __pythran_test_pt::draw_line::type<argument_type0>::result_type __pythran_test_pt::draw_line::operator()(argument_type0&&) const [with argument_type0 = {anonymous}::pythonic::types::ndarray<int, {anonymous}::pythonic::types::pshape<long int, long int> >&; typename __pythran_test_pt::draw_line::type<argument_type0>::result_type = {anonymous}::pythonic::types::none_type]’
/tmp/tmp49tylgd3.cpp:65:79:   required from here
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp:537:71: error: static assertion failed: all slices are valid
  537 |                        std::is_same<S, normalized_slice>::value)...>::value,
      |                                                                       ^~~~~
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp: In instantiation of ‘constexpr const size_t {anonymous}::pythonic::types::count_long<{anonymous}::pythonic::types::ndarray<long int, {anonymous}::pythonic::types::array_base<long int, 1, {anonymous}::pythonic::types::tuple_version> > >::value’:
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp:167:24:   recursively required from ‘constexpr const size_t {anonymous}::pythonic::types::count_long<{anonymous}::pythonic::types::ndarray<long int, {anonymous}::pythonic::types::array_base<long int, 1, {anonymous}::pythonic::types::tuple_version> > >::value’
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp:167:24:   required from ‘constexpr const size_t {anonymous}::pythonic::types::count_long<{anonymous}::pythonic::types::ndarray<long int, {anonymous}::pythonic::types::array_base<long int, 1, {anonymous}::pythonic::types::tuple_version> > >::value’
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp:167:54:   required from ‘constexpr const size_t {anonymous}::pythonic::types::count_long<{anonymous}::pythonic::types::contiguous_normalized_slice, {anonymous}::pythonic::types::ndarray<long int, {anonymous}::pythonic::types::array_base<long int, 1, {anonymous}::pythonic::types::tuple_version> > >::value’
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp:558:69:   required from ‘constexpr const size_t {anonymous}::pythonic::types::numpy_gexpr<{anonymous}::pythonic::types::ndarray<int, {anonymous}::pythonic::types::pshape<long int, long int> >, {anonymous}::pythonic::types::contiguous_normalized_slice, {anonymous}::pythonic::types::ndarray<long int, {anonymous}::pythonic::types::array_base<long int, 1, {anonymous}::pythonic::types::tuple_version> > >::value’
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp:579:52:   required from ‘struct {anonymous}::pythonic::types::numpy_gexpr<{anonymous}::pythonic::types::ndarray<int, {anonymous}::pythonic::types::pshape<long int, long int> >, {anonymous}::pythonic::types::contiguous_normalized_slice, {anonymous}::pythonic::types::ndarray<long int, {anonymous}::pythonic::types::array_base<long int, 1, {anonymous}::pythonic::types::tuple_version> > >’
/tmp/tmp49tylgd3.cpp:54:9:   required from ‘typename __pythran_test_pt::draw_line::type<argument_type0>::result_type __pythran_test_pt::draw_line::operator()(argument_type0&&) const [with argument_type0 = {anonymous}::pythonic::types::ndarray<int, {anonymous}::pythonic::types::pshape<long int, long int> >&]’
/tmp/tmp49tylgd3.cpp:65:79:   required from here
/home/jschrod/.local/lib/python3.8/site-packages/pythran/pythonic/include/types/numpy_gexpr.hpp:167:24: fatal error: template instantiation depth exceeds maximum of 900 (use ‘-ftemplate-depth=’ to increase the maximum)
  167 |         count_long<T>::value + count_long<Types...>::value;
      |                        ^~~~~
compilation terminated.
WARNING: Compilation error, trying hard to find its origin...
WARNING: Nop, I'm going to flood you with C++ errors!
CRITICAL: Cover me Jack. Jack? Jaaaaack!!!!
E: error: Command "g++ -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -fPIC -DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DPYTHRAN_BLAS_OPENBLAS -I/home/jschrod/.local/lib/python3.8/site-packages/pythran -I/usr/lib64/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c /tmp/tmp49tylgd3.cpp -o /tmp/tmp3_l_6d8g/tmp/tmp49tylgd3.o -std=c++11 -fno-math-errno -w -fvisibility=hidden -fno-wrapv" failed with exit status 1

however

import numpy as np

#pythran export draw_line(int32[][])
def draw_line(grid):
    x = np.arange(0, grid.shape[0]//2).astype(int)
    grid[x, :] = 1        

works.

cycomanic avatar Nov 05 '20 11:11 cycomanic