So I'm assuming here that fp(x) or f(x) are functions that don't return anything.

Take a look at this,

def fp(x):
    print(x)

print(fp(10))

You might think that the output of this would be 10 but you get this,

10
None

Take a look at this function,

def fp():
    pass
print(fp())

Output:

None

Functions by default return a None type. So in your case when you are doing abs(fp(x)) the problem seems to be that you are doing abs() on None that's why you get the error.

Look at this,

def fp():
        pass
abs(fp())

Output:

TypeError: bad operand type for abs(): 'NoneType' python error

So add a return statement to the function and you can see the error will be gone

def fp(x):
    return x
some_value = abs(fp(-10.5))
print(some_value)

Output:

10.5

Now the error is gone.

Answer from void on Stack Overflow
🌐
Mozilla Discourse
discourse.mozilla.org › t › synthetic-test-sentence-typeerror-bad-operand-type-for-abs-nonetype-error › 56559
Synthetic test sentence TypeError: bad operand type for abs(): 'NoneType' error - TTS (Text-to-Speech) - Mozilla Discourse
March 25, 2020 - I’m training with the LJSpeech dataset and after about the 50th epoch I get the following error when it tries to generate the test sentences. File "train.py", line 502, in evaluate ap.save_wav(wav, file_path) File "/home/username/Audio/TTS/tts_namespace/TTS/utils/audio.py", line 58, in save_wav wav_norm = wav * (32767 / max(0.01, np.max(np.abs(wav)))) TypeError: bad operand type for abs(): 'NoneType' Traceback (most recent call last): File "train.py", line 502, in evaluate ap.save_wav(wav, file...
Discussions

API Integration - TypeError: bad operand type for abs(): 'NoneType'
Hi all, We are trying to submit sales orders programmatically with as few properties as possible to decrease our data load. We are running into this error: (most recent call last): File “/home/frappe/benches/bench-version-12-2020-09-25/apps/frappe/frappe/app.py”, line 64, in application ... More on discuss.frappe.io
🌐 discuss.frappe.io
1
0
June 21, 2020
python - bad operand type for abs(): 'list' - Stack Overflow
When calculating the absolute value in each value of an array, I am getting an error related to bad operand type for abs(): 'list'. The part of source code which is failing is the next: x = amplit... More on stackoverflow.com
🌐 stackoverflow.com
Python absolute value
hello, I am trying to get rid off the absolute value, but I don’t understand why I am getting error xVal = IN[0] xout= for x in xVal: b = abs(x): if b More on forum.dynamobim.com
🌐 forum.dynamobim.com
1
0
June 6, 2019
[Python 3.4] Making a simple program to print the absolute value of integer but coming up with an error
https://docs.python.org/3.4/library/functions.html#abs abs(x) Return the absolute value of a number. The argument may be an integer or a floating point number. https://docs.python.org/3.4/library/functions.html#input input([prompt]) The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. https://docs.python.org/3.4/library/functions.html#int int(x=0) Return an integer object constructed from a number or string x, or return 0 if no arguments are given. More on reddit.com
🌐 r/learnprogramming
8
3
June 6, 2014
🌐
GitHub
github.com › spiralgenetics › truvari › issues › 24
TypeError: bad operand type for abs(): 'NoneType' · Issue #24 · ACEnglish/truvari
May 7, 2018 - It bugged as below: Traceback (most recent call last): File "/usr/local/bin/truvari", line 1047, in run(sys.argv[1:]) File "/usr/local/bin/truvari", line 788, in run sizeA = get_vcf_entry_size(base_entry) File "/usr/local/bin/truvari", line 271, in get_vcf_entry_size size = abs(entry.INFO["SVLEN"]) TypeError: bad operand type for abs(): 'NoneType' what's meaning?
Author   Macy-Zhao
🌐
Trymito
trymito.io › excel-to-python › functions › math › ABS
Excel to Python: ABS Function - A Complete Guide | Mito
If you execute the ABS value function on a cell that contains new data in Excel, it will simply return 0. However, in Pandas, empty cells are represented by the Python NoneType. Using the .abs() function on the NoneType will create this error `TypeError: bad operand type for abs(): 'NoneType'`.
🌐
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])
Find elsewhere
🌐
GitHub
github.com › tarantool › test-run › issues › 28
TypeError: bad operand type for abs(): 'NoneType' · Issue #28 · tarantool/test-run
May 16, 2016 - --------------------------------------------------------------------------- box-py/args.test.py Traceback (most recent call last): File "/home/travis/build/rtsisyk/tarantool/test-run/lib/test.py", line 120, in run self.execute(server) File "/home/travis/build/rtsisyk/tarantool/test-run/lib/tarantool_server.py", line 124, in execute server.crash_grep() File "/home/travis/build/rtsisyk/tarantool/test-run/lib/tarantool_server.py", line 567, in crash_grep sys.stdout.write('[Signal=%d]\n' % abs(self.process.returncode)) TypeError: bad operand type for abs(): 'NoneType' [ fail ] Test failed!
🌐
Dynamo
forum.dynamobim.com › revit
Python absolute value - Revit - Dynamo
June 6, 2019 - hello, I am trying to get rid off the absolute value, but I don’t understand why I am getting error xVal = IN[0] xout= for x in xVal: b = abs(x): if b<150: xout.append("Less than 150 Pipe is " + str(b)) else: x…
🌐
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.
🌐
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
🌐
GitHub
github.com › coqui-ai › TTS › discussions › 168
Synthetic test sentence typeerror bad operand type for abs nonetype error · coqui-ai/TTS · Discussion #168
wav = None if use_griffin_lim: print('We are using griffin_lim.') wav = inv_spectrogram(postnet_output, ap, CONFIG) # trim silence if do_trim_silence: wav = trim_silence(wav, ap) print('In utils/synthesis is wav still None: ' + str(wav)) return wav, alignment, decoder_output, postnet_output, stop_tokens Is there somewhere that I need to set use_griffin_lim? config.json maybe? [This is an archived TTS discussion thread from discourse.mozilla.org/t/synthetic-test-sentence-typeerror-bad-operand-type-for-abs-nonetype-error]
Author   coqui-ai
🌐
GitHub
github.com › powa-team › powa › issues › 61
Unable to view index suggestions - TypeError: bad operand type for abs(): 'NoneType' · Issue #61 · powa-team/powa
April 14, 2015 - Unable to view index suggestions - TypeError: bad operand type for abs(): 'NoneType'#61 · Copy link · ribbles · opened · on Dec 15, 2015 · Issue body actions · Unable to view index suggestions.
Author   ribbles
🌐
Quora
quora.com › How-do-you-fix-the-TypeError-bad-operand-problem-in-Python-3
How to fix the TypeError: bad operand problem in Python 3 - Quora
Answer (1 of 2): Probably b is a string. Do print( type(b)) and Python will tell you its type. If it is a string representation of a number, you could do b = float(b), after that b is a float and unary minus will work on that. But if b is not guaranteed to be represent a number that line will gi...
🌐
Google Groups
groups.google.com › g › gurobi › c › d3q4JWw1ntI
How to use abs() function with decision variables
Hi, I am trying to use abs function with decision variables but Gurobi gives this output : TypeError: bad operand type for abs(): 'gurobipy.LinExpr'
🌐
Studytonight
studytonight.com › pandas › pandas-dataframe-abs-method
Pandas DataFrame abs() Method - Studytonight
April 12, 2023 - import pandas as pd df = pd.DataFrame([[23, -85, -0.25],[2, -1.259, -85]],columns=['A', 'B','C']) print("-----DataFrame-----") print(df) print(abs(df)) Once we run the program we will get the following output. -----DataFrame----- A B C 0 23 -85.000 -0.25 1 2 -1.259 -85.00 A B C 0 23.0 85.000 0.25 1 2.0 1.259 85.00 · We will get TypeError if try to get the absolute value of string because abs() methods allow only numeric values.