TypeError: only length-1 arrays can be converted to Python

Oscar Benjamin oscar.j.benjamin at gmail.com
Sat Sep 21 07:02:15 EDT 2013


On Sep 21, 2013 7:40 AM, "D.YAN ESCOLAR RAMBAL" <dyeringamsa at gmail.com>
wrote:
>
> Traceback (most recent call last):
>   File "D:\Yan\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION
NUMERICA PARA LA ECUACION DE LA DIFUSION EN 1D DYER", line 34, in <module>
>     C=(Cdifuana(M,A,D,x,tinicial))
>   File "D:\Yan\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION
NUMERICA PARA LA ECUACION DE LA DIFUSION EN 1D DYER", line 32, in Cdifuana
>     Cdifuana = (M/temp)*math.exp(-x**2 /(4*D*t))
> TypeError: only length-1 arrays can be converted to Python
>

The math module doesn't work with numpy arrays. You should use numpy.exp()
instead of math.exp().

Oscar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130921/db2d7a9a/attachment.html>


More information about the Python-list mailing list