Python Forum
Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'"
#1
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?
Reply
#2
what is np.sign?
Reply
#3
"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}")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Bitwise Operations in numpy Sowmya 3 238 Apr-03-2024, 02:51 PM
Last Post: deanhystad
  [Numpy] How to store different data type in one numpy array? water 7 563 Mar-26-2024, 02:18 PM
Last Post: snippsat
  TypeError: unhashable type: 'Series' bongielondympofu 2 470 Mar-14-2024, 06:12 PM
Last Post: deanhystad
  [Numpy] Load date/time from .txt to 'datetime64' type. water 4 584 Mar-01-2024, 11:16 PM
Last Post: Gribouillis
  [pandas] TypeError: list indices must be integers or slices, not str but type is int. cspower 4 852 Dec-30-2023, 09:38 AM
Last Post: Gribouillis
  numpy.ufunc - Arguments missunderstand MarioBruza 0 809 Jan-11-2023, 05:03 AM
Last Post: MarioBruza
  reshaping 2D numpy array paul18fr 3 1,012 Jan-03-2023, 06:45 PM
Last Post: paul18fr
  Pandas dataframes and numpy arrays bytecrunch 1 1,329 Oct-11-2022, 08:08 PM
Last Post: Larz60+
Question about Numpy indexing. water 1 1,455 Jan-18-2022, 09:52 PM
Last Post: paul18fr
  numpy masking/filtering nilamo 3 3,492 Dec-04-2021, 10:28 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020