什么是numpy中[x][y][:]和[x, y, :]之间的区别?
在我的例子中,我想将一个np.ndarray分配到另一个中,其中一种方式适用而另一种方式不适用。 使用相同的索引,因此我真的很想知道为什么。
谢谢。
>>> gtfb_fft_hypercube.shape
(187, 42, 96, 1026)
>>> amp_mod_cube.shape
(42, 1025, 187)
>>> gtfb_fft_hypercube[0][0][0][1:] = amp_mod_cube[0][:][0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: could not broadcast input array from shape (187,) into shape (1025,)
>>> gtfb_fft_hypercube[0, 0, 0, 1:] = amp_mod_cube[0, :, 0]
>>>