我有numpy.hstack()函数的问题。我有三个相同的numpy数组,我想使用hstack()加入它们,所以我从这些numpy数组创建元组并使用numpy.hstack(元组)
v, n, t // rows example [ 0.83468097 0.50044298 0.229835 ]
tuple_stack = (v, n, t)
stack = numpy.hstack(tuple_stack)
结果我得到了ndarray,哪一行看起来像这个
[0.091698 0.69801199 0.88459301 0.83468097 0.50044298 0.229835 \ n 0.429932 0.989021 0.]
因为这个堆栈用于在opengl中初始化VBO,所以我可能在第六个元素之后使用'\ n'错误地使用了这个对象。我该如何解决这个问题?
答案 0 :(得分:1)
看起来你正在使用字符串数组而不是数字。您可以将numpy字符串数组转换为浮点数:
a = numpy.array(['0.4', '1.2\n', '.6'])
x = a.astype(numpy.float)
答案 1 :(得分:1)
数组本身没有requestPermissions()
。看起来你出于某种原因看着\n
。
repr(str(stack))