Python Forum

Full Version: list - list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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])