0
我想初始化一個只能包含0或1的numpy數組(n,m)。 此外,我想以後到np.bitwise_or與數組。np.ndarray ndarrays上的bitwise_or運算符失敗
例如,如果我嘗試:
import numpy as np
myArray = np.zeros([4,4])
myRow = myArray[1,]
myCol = myArray[,1]
np.bitwise_or(myRow, myCol)
它失敗:
TypeError: ufunc 'bitwise_or' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
我怎樣才能做到這一點以類似的方式,但沒有錯誤?
如果我嘗試,
np.bitwise_or([0,0,0,0], [0,0,0,0])
它的實際工作。