Python Forum
Thread Rating:
  • 3 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list - list
#1
fa is an array of floats, exact type unknown (since Python doesn't declare)

pfa = fa
fa = np.concatenate( (np.zeros(2), fa ))
FAIs = np.maximum( fa - pfa, 0. )
first we set pfa = fa, then we prepend 2 zeros to fa, so "fa - pfa" is trying to operate on arrays of different sizes (I think).
Error:
TypeError: unsupported operand type(s) for -: 'list' and 'list'
What am I missing?

Okay, nvr mind. It turns out there are two variables and I was confusing them, one called fa and one called self.fa.
My bad.
Reply
#2
It would appear that your pfa and fa are lists rather than numpy arrays:
>>> a = [1,2,3]
>>> b = [4,5,6]
>>> a - b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'list' and 'list'
>>> import numpy as np
>>> a = np.array([1,2,3])
>>> b = np.array([4,5,6])
>>> a - b
array([-3, -3, -3])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [solved] list of list with one or more empty one paul18fr 5 2,386 Oct-04-2023, 09:08 AM
Last Post: jeffreyteague
  convert a list of string+bytes into a list of strings (python 3) pacscaloupsu 4 10,843 Mar-17-2020, 07:21 AM
Last Post: markfilan
  search for a part of strinf from list in another list ! evilcode1 3 3,184 Oct-29-2018, 12:07 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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