Only size-1 arrays can be converted to python scalars

Last Updated On Sunday 18th Jul 2021

PythonTypeError:Only size-1 arrays can be converted to Python scalars

	import math
import matplotlib.pyplot as plt
plt.plot(x, y)
r = np.arange(0, 1, 0.01)
T_0 = pow(math.sqrt(1-pow(r,2)),-1)
L_0 = math.sqrt(1-pow(r,2))
	

And the error message appears

TypeError: only size-1 arrays can be converted to Python scalars

Change the math package to the numpy package

	import numpy as np
...
T_0 = pow(np.sqrt(1-pow(r,2)),-1) #error list
L_0 = np.sqrt(1-pow(r,2)) #error list