Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54535

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

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 <dyeringamsa@gmail.com>
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" <dyeringamsa@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.218.1379745528.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

this the code,
______________________________________________________________
import math
import numexpr as ne
import matplotlib.pyplot as plt
import numpy as np
import numba as nb


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

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

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

#GENERANDO CONDICION INICIAL

C=(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 <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

-- 

*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á Colombia*

*       Muehletorplatz 4-6, A-6800 Feldkirch, Austria*

       *www.hafi.cc/en/environ_en.htm*

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

TypeError: only length-1 arrays can be converted to Python "D.YAN ESCOLAR RAMBAL" <dyeringamsa@gmail.com> - 2013-09-20 21:45 -0500

csiph-web