Python Forum
Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" (/thread-37763.html)



Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" - kalle - Jul-18-2022

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?


RE: Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" - deanhystad - Jul-18-2022

what is np.sign?


RE: Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" - paul18fr - Jul-19-2022

"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}")