Search code examples
pythonnumpypyopengl

Numpy.hstack() adds the end of line mark to the result array


i have problem with numpy.hstack() function. I have three the same numpy arrays and i want to join them using hstack(), so I create tuple from these numpy arrays and use numpy.hstack(tuple)

v, n, t // rows example [ 0.83468097  0.50044298  0.229835  ]

tuple_stack = (v, n, t)

stack = numpy.hstack(tuple_stack)

as result I got ndarray, which rows looks like this one

[ 0.091698 0.69801199 0.88459301 0.83468097 0.50044298 0.229835\n 0.429932 0.989021 0. ]

Because this stack i use to init VBO in opengl I probably have mistake in this object with '\n' after sixth element. How can i fix this?


Solution

  • There is no \n in the array itself. It looks like you are just looking at repr(str(stack)) for some reason.

    [~]
    |14> stack
    array([ 0.091698  ,  0.69801199,  0.88459301,  0.83468097,  0.50044298,  0.229835  ,  0.429932  ,  0.989021  ,  0.        ])
    
    [~]
    |15> print stack
    [ 0.091698    0.69801199  0.88459301  0.83468097  0.50044298  0.229835
      0.429932    0.989021    0.        ]
    
    [~]
    |16> print str(stack)
    [ 0.091698    0.69801199  0.88459301  0.83468097  0.50044298  0.229835
      0.429932    0.989021    0.        ]
    
    [~]
    |17> print repr(str(stack))
    '[ 0.091698    0.69801199  0.88459301  0.83468097  0.50044298  0.229835\n  0.429932    0.989021    0.        ]'
    
    [~]
    |18> repr(stack[5])
    '0.22983500000000001'