Tag Archives: Python BUG

Python bug problems and solutions sorted out in recent days

TypeError: unsupported operand type(s) for ^: ‘float’ and ‘int’

Solution: Changed the multiplication sign ^ to **

https://stackoverflow.com/questions/34258537/python-typeerror-unsupported-operand-types-for-float-and-int

TypeError: type numpy.ndarray doesn’t define __round__ method

Solution: change round() to np.round()

TypeError: ufunc ‘bitwise_xor’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ”safe”

Solution: change ^ to **

TypeError: only size-1 arrays can be converted to Python scalars

Solution: change math.exp to np.exp()

Reason: sigma is a numpy matrix, use numpy.exp to handle it