Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'skip:\xa0 30': 0.05; 'subject:Python': 0.06; '0.1': 0.09; '34,': 0.09; 'analytic': 0.09; 'arrays': 0.09; 'converted': 0.09; 'function,': 0.09; 'skip:c 80': 0.09; 'python': 0.11; 'def': 0.12; '32,': 0.16; '8bit%:1': 0.16; 'equation': 0.16; 'ing.': 0.16; 'numpy': 0.16; 'phase,': 0.16; 'skip:\xa0 60': 0.16; 'temp': 0.16; 'typeerror:': 0.16; 'numerical': 0.19; '8bit%:5': 0.22; 'code,': 0.22; 'import': 0.22; 'gmbh': 0.22; 'math': 0.24; 'define': 0.26; 'skip:" 20': 0.27; '8bit%:3': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'file': 0.32; 'skip:c 30': 0.32; 'run': 0.32; '(most': 0.33; 'message.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'obtain': 0.39; 'subject:can': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'no.': 0.61; 'show': 0.63; 'skip:n 10': 0.64; 'skip:w 30': 0.69; 'url:htm': 0.73; '8bit%:43': 0.74; 'skip:_ 50': 0.83; '*fax:': 0.84; 'comparative': 0.84; '800': 0.91; 'gracias,': 0.91; 'url:cc': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=QY+MPigsBxPbYmKEKn+YDGlSzrcMmf96461xgi0xnHY=; b=K45DsrE3uc1W/HsUcQs3Ugn//9ORaZHtvzXhdwmae4kL0eqP622210UvzQP0WvH9E3 1WwNmi5KrHObqkM0slkGgeSOE14hX8OGJEGc5bYm+BHJI/BtpQ4SNQKm/nsSKfaViHFd NysumCG6TVs8SCvN9uaTml00iXag8PXhElO+LmCRJUC1HTsXTvKKNu9BFHOgsth6TPDs 3JEmMpCqPJdlpdhNsrYdyVEdo7wV1qC9vyUdbOFRliwNDdxX3jqgFgZMbIfOa+PEqv2o JkKBVkicgcY6G1Y1RvK/+/BH37Noa0D9EJIwudTXH4Un0h4C18xEUx+0J1S/P3YRsCo/ j3BA== MIME-Version: 1.0 X-Received: by 10.60.68.135 with SMTP id w7mr8830333oet.9.1379731529135; Fri, 20 Sep 2013 19:45:29 -0700 (PDT) Date: Fri, 20 Sep 2013 21:45:29 -0500 Subject: TypeError: only length-1 arrays can be converted to Python From: "D.YAN ESCOLAR RAMBAL" To: python-list@python.org Content-Type: multipart/alternative; boundary=001a1134c4c2ae4f5704e6dbc7e8 X-Mailman-Approved-At: Sat, 21 Sep 2013 08:38:47 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 145 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1379745528 news.xs4all.nl 15984 [2001:888:2000:d::a6]:38494 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54535 --001a1134c4c2ae4f5704e6dbc7e8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable this the code, ______________________________________________________________ import math import numexpr as ne import matplotlib.pyplot as plt import numpy as np import numba as nb M =3D 10 A =3D 10 D =3D 0.1 xmin =3D -4 xmax =3D 4 n =3D 800 tfinal =3D 3 tinicial =3D 1 # GENERANDO VECTOR CON PUNTOS DE DISCRETIZACION X ESPACIADOS x=3D np.linspace(xmin, xmax, n) #GENERANDO FUNCION ANALITICA def Cdifuana(M,A,D,x,t): temp =3D A*math.sqrt(4*math.pi*D*t); Cdifuana =3D (M/temp)*math.exp(-x**2 /(4*D*t)) #GENERANDO CONDICION INICIAL C=3D(Cdifuana(M,A,D,x,tinicial)) ___________________________________________________________ In this code, I try obtain graph comparative the analytic and numerical solution for the diffusion equation in 1D, but whe I define the analytic function, run the phase, the compilator show me this message. 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 C=3D(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 =3D (M/temp)*math.exp(-x**2 /(4*D*t)) TypeError: only length-1 arrays can be converted to Python --=20 *Gracias, cordialmente, * * * * * *ING. YANETH ESCOLAR RAMBAL* *HAFI Engineering & Consulting GmbH* *CEL: + 57 3166257245* *TEL: + 57 (1) 6508308* *TEL: ++43 5522 77924 0* *Fax: ++43 5522 74938* *Dir : Cll 72f no. 113-21 Torre 5 - 604 Bogot=E1 Colombia* * Muehletorplatz 4-6, A-6800 Feldkirch, Austria* *www.hafi.cc/en/environ_en.htm* --001a1134c4c2ae4f5704e6dbc7e8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
this the code, =A0
________________________= ______________________________________
import math
impo= rt numexpr as ne
import matplotlib.pyplot as plt
import= numpy as np
import numba as nb


M =3D 10
A =3D 10
D =3D 0.1
xmin =3D -4
xmax = =3D 4
n =3D 800
tfinal =3D 3
tinicial =3D 1

# GENERANDO VECTOR CON PUNTOS DE DISCRETIZACION X ESPACIADOS
x=3D np.linspace(xmin, xmax, n)

#GENERANDO = FUNCION ANALITICA
def Cdifuana(M,A,D,x,t):
=A0 =A0 temp= =3D A*math.sqrt(4*math.pi*D*t);
=A0 =A0 Cdifuana =3D (M/temp)*math.exp(-x**2 /(4*D*t))

<= /div>
#GENERANDO CONDICION INICIAL

C=3D(Cdifua= na(M,A,D,x,tinicial))
___________________________________________= ________________

In this code, I try obtain graph comparative =A0th= e analytic and numerical solution for the diffusion equation in 1D, but whe= =A0I define =A0the analytic function, run the phase, the compilator show m= e this message.

Traceback (most recent call last):
=A0 File &= quot;D:\Yan\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION NUMERI= CA PARA LA ECUACION DE LA DIFUSION EN 1D DYER", line 34, in <module= >
=A0 =A0 C=3D(Cdifuana(M,A,D,x,tinicial))
=A0 File "D:\Y= an\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION NUMERICA PARA L= A ECUACION DE LA DIFUSION EN 1D DYER", line 32, in Cdifuana
= =A0 =A0 Cdifuana =3D (M/temp)*math.exp(-x**2 /(4*D*t))
TypeError: only length-1 arrays can be converted to Python=A0

--

Gracias,= cordialmente,=A0



ING. YANETH ESCOLA= R RAMBAL

HAFI Engineering & Consulting GmbH

CEL:=A0+ 57 3166257245

TEL:=A0+ 57 (1) 6508308=

TEL:=A0++43 5522 77924 0

= Fax:=A0++43 5522 74938

Dir : Cll 72f no. 113-21 Torre 5 = - 604=A0 Bogot=E1 Colombia

=A0=A0=A0=A0=A0=A0 Muehletorplatz 4-6, A-6800 Feldkir= ch, Austria

=A0=A0=A0=A0=A0=A0=A0www.hafi.cc/en/environ_en.htm

--001a1134c4c2ae4f5704e6dbc7e8--