[Numpy-discussion] puzzle with boolean dtype

Alan G Isaac alan.isaac@gmail....
Wed Oct 6 16:10:54 CDT 2010


Integer exponentiation fails (i.e., changes type)
with boolean dtype.  See below. Expected?

Alan Isaac


     >>> a = np.array([[0,1,0],[0,0,1],[1,0,0]], dtype=np.bool_)
     >>> a2 = a*a
     >>> a3 = a2*a
     >>> print(a3)
     [[False  True False]
      [False False  True]
      [ True False False]]
     >>> print(a**3)
     [[0 1 0]
      [0 0 1]
      [1 0 0]]



More information about the NumPy-Discussion mailing list