我发现与NumPy的一个ndarray以下令人费解的行为和一个自定义的D型细胞,当数组赋值问题:NumPy的:使用自定义的D型
import numpy as np
# Make a custom dtype with a single triplet of floats (my actual dtype has other
# components, but this suffices to demonstrate the problem.
dt = np.dtype([('a', np.float64, 3)])
# Make a zero array with this dtype:
points = np.zeros((4, 4), dtype=dt)
# Try to edit an entry:
points[0][0]['a'] = np.array([1, 1, 1])
print points[0][0]['a']
现在,这回来为含有不[1。如我所料,但是[1]。 0. 0],只在第一个坐标上执行赋值。我可以通过坐标明智地执行分配来解决这个问题,但这看起来没有必要,因为在这种情况下完全分配肯定应该是默认行为。
想到这里发生了什么?
正是我在找的,谢谢。 –