absolute-value

The Absolute Value of a Complex Number with Numpy

The Absolute Value of a Complex Number with Numpy Question: I have the following script in Python. I am calculating the Fourier Transform of an array. When I want to plot the results (Fourier transform) I am using the absolute value of that calculation. However, I do not know how the absolute value of complex …

Total answers: 4

Should I use np.absolute or np.abs?

Should I use np.absolute or np.abs? Question: Numpy provides both np.absolute and the alias np.abs defined via from .numeric import absolute as abs which seems to be in obvious violation of the zen of python: There should be one– and preferably only one –obvious way to do it. So I’m guessing that there is a …

Total answers: 2

Pythonic way to find maximum absolute value of list

Pythonic way to find maximum absolute value of list Question: Given the following: lst = [3, 7, -10] I want to find the maximum value according to absolute values. For the above list it will be 10 (abs(-10) = 10). I can do it as follows: max_abs_value = lst[0] for num in lst: if abs(num) …

Total answers: 4

How to convert a negative number to positive?

How to convert a negative number to positive? Question: How can I convert a negative number to positive in Python? (And keep a positive one.) Asked By: aneuryzm || Source Answers: >>> n = -42 >>> -n # if you know n is negative 42 >>> abs(n) # for any n 42 Don’t forget to …

Total answers: 7