我有两个不同形状的数组,例如:
a = np.zeros((2, 4))
b = np.ones((2, 3))
我想对它们执行以下操作:
x1, x2 = a.shape
b[:x1, :x2] = a[:x1, :x2]
a我想通过在和之间翻转形状并b让它仍然工作的能力来实现这一点,即
a = np.zeros((2, 3)) # Note that I flipped
b = np.ones((2, 4)) # the shapes from the previous example
x1, x2 = a.shape
b[:x1, :x2] = a[:x1, :x2]
可以使用本机 NumPy 并且不使用 for 循环来完成吗?