for numpy.bitwise_and.reduceufunc.reduce
が適切に動作していないようです... 誤用ですか?
>>> import numpy as np
>>> x = [0x211f,0x1013,0x1111]
>>> np.bitwise_or.accumulate(x)
array([ 8479, 12575, 12575])
>>> np.bitwise_and.accumulate(x)
array([8479, 19, 17])
>>> '%04x' % np.bitwise_or.reduce(x)
'311f'
>>> '%04x' % np.bitwise_and.reduce(x)
'0001'
の結果はreduce()
の最後の値である必要がありますが、そうではaccumulate()
ありません。ここで何が欠けていますか?
とりあえず、DeMorgan の ID を使用して回避できます (OR と AND を交換し、入力と出力を反転します)。
>>> ~np.bitwise_or.reduce(np.invert(x))
17