pyccel icon indicating copy to clipboard operation
pyccel copied to clipboard

np.array in c does not handle lists of vector variables

Open EmilyBourne opened this issue 4 years ago • 2 comments

Describe the bug np.array works for lists of scalars and lists of lists of scalars, but it does not handle lists of variables

To Reproduce Provide code to reproduce the behavior:

@types('real[:,:]','real[:,:]')                         
def array_real_3d_C_array_initialization_1(x, y):                   
    from numpy import array                                            
    tmp      = array([x, y], dtype='float')

Provide the generated code, or the error message:

Traceback (most recent call last):
  File "/home/emily/Code/pyccel/pyccel/codegen/printing/ccode.py", line 1297, in _print_Assign
    return self.copy_NumpyArray_Data(expr)
  File "/home/emily/Code/pyccel/pyccel/codegen/printing/ccode.py", line 317, in copy_NumpyArray_Data
    arg = functools.reduce(operator.concat, arg)
TypeError: 'Variable' object can't be concatenated

Expected behavior This should be handled, if it is non-trivial then as a first step a neat error should be raised

Language C

EmilyBourne avatar Feb 13 '21 19:02 EmilyBourne

it will need a concatenation function to do so.

bauom avatar Apr 12 '21 12:04 bauom

Error is now: image

EmilyBourne avatar Jul 09 '21 07:07 EmilyBourne