Python Forum

Full Version: Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I have equation that i want to execute, but i cannot get it to run.

import numpy as np

x = (np.abs((np.sign)*(90)-0.5)-0.5) * (np.abs((np.sign)*(270)+0.5)-0.5)
It returns

Error:
circle.py", line 3, in <module> x = (np.abs((np.sign)*(90)-0.5)-0.5) * (np.abs((np.sign)*(270)+0.5)-0.5) TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'
How should i proceed?
what is np.sign?
"np.sign" is not used correctly; check the parentheses (see doc; for instance:

import numpy as np
A=np.sign(-10.59)
print(f"A={A}")
B=np.sign(1586.22)
print(f"B={B}")