I see you've already imported numpy because you're using np.linspace in the code. You are probably confusing numpy's abs, which will happily work on lists and arrays, with __builtin__.abs, which only works for scalars.

Change this:

abs(wf[0:100])

To this:

np.abs(wf[0:100])
Answer from wim on Stack Overflow
Discussions

'Bad operand type for abs', how do i solve this
def checkio(numbersarray: tuple) -> list: result = sorted([numbersarray], key=lambda x:abs(x)) return result More on py.checkio.org
🌐 py.checkio.org
cryptography - How to correctly apply Python absolute value to a list to avoid an TypeError: bad operand type for abs(): 'list' - Stack Overflow
in B i need to use list, but I can't find a workaround for TypeError: bad operand type for abs(): 'list'. Following the documentation of ABS I tried to use map() and list() function to convert it to the absolute value, More on stackoverflow.com
🌐 stackoverflow.com
August 21, 2022
python - Why built-in functions like abs works on numpy array? - Stack Overflow
I feel surprised that abs works on numpy array but not on lists. Why is that? import numpy as np abs(np.array((1,-2))) array([1, 2]) abs([1,-1]) TypeError: bad operand type for abs(): 'list' More on stackoverflow.com
🌐 stackoverflow.com
TypeError: bad operand type for abs(): 'NoneType' python error - Stack Overflow
abs(fp(x)) TypeError: bad operand type for abs(): 'NoneType' More on stackoverflow.com
🌐 stackoverflow.com
🌐
Pytut
pytut.com › abs
Python abs() Function - PyTut
The argument can't be a str, tuple, list, set, or dict. These raise TypeError. >>> abs('-3.5') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: bad operand type for abs(): 'str' >>> abs((1, -1)) Traceback (most recent call last): File "<stdin>", line 1, in <module> ...
🌐
Checkio
py.checkio.org › forum › post › 13102 › bad-operand-type-for-abs-how-do-i-solve-this
'Bad operand type for abs', how do i solve this
def checkio(numbersarray: tuple) -> list: result = sorted([numbersarray], key=lambda x:abs(x)) return result
🌐
iO Flood
ioflood.com › blog › python-absolute-value
Python Absolute Value | abs() Function and Alternatives
February 6, 2024 - This error occurs when you try to find the absolute value of a non-numeric data type, such as a string or a list. Let’s look at an example: string = 'Hello, Python!' try: absolute_value = abs(string) except TypeError: print('TypeError: bad ...
🌐
Python Examples
pythonexamples.org › python-absolute-value-abs
abs() - Python Examples
Absolute value of the expression (a+b) is 72. If we provide an argument of any non-numeric type like string, abs() function raises TypeError.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Get Absolute Values in Python: abs(), math.fabs() | note.nkmk.me
May 11, 2025 - If you try to use abs() with an object that doesn't implement __abs__(), such as a list, you'll get a TypeError. l = [-2, -1, 0, 1, 2] print(hasattr(l, '__abs__')) # False # print(abs(l)) # TypeError: bad operand type for abs(): 'list' source: ...
Find elsewhere
🌐
GitHub
github.com › HIPS › autograd › issues › 102
TypeError: bad operand type for abs(): 'FloatNode' · Issue #102 · HIPS/autograd
April 28, 2016 - def predict(self, theta, data): const = assert_arr_shape({ data.X.shape: ('batch_size', self.n_steps, self.n_input_dim), data.y.shape: ('batch_size', self.n_hidden_dim) }) h_prev = bk.repeat(theta.h_0[:, bk.newaxis], const.batch_size, axis=1).T activation = lambda x: bk.maximum(0, 1-x) to_stack = [] for i in range(self.n_steps): input2hidden = bk.dot(data.X[:, i, :], theta.W_input_to_hidden) hidden2hidden = bk.dot(h_prev, theta.W_hidden_to_hidden) before_activation = (input2hidden + hidden2hidden) h_prev = activation(before_activation) to_stack.append(h_prev) output = bk.stack(to_stack, axis=1) assert_arr_shape({output.shape: (None, self.n_steps, self.n_hidden_dim)}) return output def loss(self, theta, data): pred = self.predict(theta, data) last_step_pred = pred[:, -1, :] loss = bk.sum(bk.abs(last_step_pred - data.y)) return loss
🌐
Real Python
realpython.com › python-absolute-value
How to Find an Absolute Value in Python – Real Python
June 4, 2025 - Unfortunately, as soon as you try calling abs() on a Python list with those numbers, you get an error: ... >>> temperature_readings = [1, -5, 1, -4, -1, -8, 0, -7, 3, -5, 2] >>> abs(temperature_readings) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: bad operand ...
🌐
Narkive
theano-users.narkive.com › Nt3Eyhfv › typeerror-bad-operand-type-for-abs-list
[theano-users] TypeError: bad operand type for abs(): 'list'
<https://github.com/Newmu/Theano-Tutorials> <https://github.com/Newmu/Theano-Tutorials> def RMSprop(cost, params, lr=0.001, rho=0.9, epsilon=1e-6): grads = T.grad(cost=cost, wrt=params) updates = [] for p, g in zip(params, grads): acc = theano.shared(p.get_value() * 0.) acc_new = rho * acc + (1 - rho) * g ** 2 gradient_scaling = T.sqrt(acc_new + epsilon) g = g / gradient_scaling updates.append((acc, acc_new)) updates.append((p, p - lr * g)) return updates <https://github.com/Newmu/Theano-Tutorials> <https://github.com/Newmu/Theano-Tutorials> cost = T.mean(T.nnet.categorical_crossentropy(noise_py_x, Y)) params = [w, w2, w3, w4, w_o] updates = RMSprop(cost, params, lr=0.001) T.sum(abs(params)) is l1 regularization. Wondering after running the below code, the error of TypeError: bad operand type for abs(): 'list' comes up.
🌐
GitHub
github.com › numpy › numpy › issues › 1784
numpy.ma.abs not working correctly? (Trac #1186) · Issue #1784 · numpy/numpy
October 19, 2012 - Original ticket http://projects.scipy.org/numpy/ticket/1186 on 2009-08-03 by @dalloliogm, assigned to @pierregm. the standard function abs() raises an error when applied to an array/list containing a 'None' value. To circumvent this prob...
🌐
Gurobi
support.gurobi.com › hc › en-us › community › posts › 16825969921297-bad-operand-type-for-abs-gurobipy-LinExpr
bad operand type for abs(): 'gurobipy.LinExpr' – Gurobi Help Center
When I run this, it gives the error "bad operand type for abs(): 'gurobipy.LinExpr' " in this line M.addConstr(A[i]*diag_y*expected_demand +epsilon*np.linalg.norm(A[i]*diag_y*P,np.inf) <= c[i])
🌐
GitHub
github.com › mindsdb › mindsdb › issues › 1387
Error: bad operand type for abs(): 'tuple' · Issue #1387 · mindsdb/mindsdb
August 11, 2021 - If you meant to do this, you must specify 'dtype=object' when creating the ndarray. return idxs, np.array(data['data'])[idxs, :] ERROR:mindsdb-logger-2121b1be-fabf-11eb-869d-2c4d54eb39b2---a2d53a6e-c8e2-4434-bf3e-faeedd0821fd:C:\PROGRA~1\MindsDB\python\lib\site-packages\mindsdb_native\libs\controllers\transaction.py:173 - Could not load module ModelInterface ERROR:mindsdb-logger-2121b1be-fabf-11eb-869d-2c4d54eb39b2---a2d53a6e-c8e2-4434-bf3e-faeedd0821fd:C:\PROGRA~1\MindsDB\python\lib\site-packages\mindsdb_native\libs\controllers\transaction.py:263 - bad operand type for abs(): 'tuple' 2021-08-
🌐
Xszz
faq.xszz.org › faq-1 › question-2018083117396.html
bad operand type for abs(): 'list' - Developer FAQ 1 - XSZZ.ORG
August 31, 2018 - I see you've already imported numpy because you're using np.linspace in the code. You are probably confusing numpy's abs, which will happily work on lists and arrays, with __builtin__.abs, which only works for scalars.
🌐
Devasking
devasking.com › issue › bad-operand-type-for-abs-list
Bad operand type for abs(): 'list'
February 11, 2022 - Traceback (most recent call last): File "example1.py", line 2, in <module> absVal = abs(x) TypeError: bad operand type for abs(): 'str' Source: https://pythonexamples.org/python-absolute-value-abs/ We usually do print a specific error when a function is not supported (i.e. that the gradient is not yet implemented), but functions that take lists as input (like stack or concatenate) are particularly troublesome in how they interact with autograd's boxed values.,I think we don't support calling stack yet.