Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!gegeweb.org!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'terry': 0.07; 'python': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'numpy': 0.16; 'pylab': 0.16; 'reedy': 0.16; 'subject:Operations': 0.16; 'traceback': 0.16; '(most': 0.16; 'math': 0.16; 'skip:m 30': 0.16; 'loading': 0.19; 'jan': 0.22; 'not.': 0.22; 'header:In-Reply-To:1': 0.22; 'convert': 0.22; 'converted': 0.23; 'last):': 0.23; 'values.': 0.23; 'wrong?': 0.23; 'problem': 0.29; 'list': 0.30; 'arrays': 0.31; 'typeerror:': 0.31; 'does': 0.31; 'anyone': 0.31; 'import': 0.32; 'to:addr :python-list': 0.32; 'answers': 0.33; 'expression': 0.33; 'array': 0.33; 'header:X-Complaints-To:1': 0.34; 'file': 0.35; 'header :User-Agent:1': 0.35; 'doing': 0.36; 'but': 0.38; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'where': 0.39; 'header:Mime- Version:1': 0.39; 'how': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'experts': 0.64; 'receive': 0.68; 'works,': 0.69 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Mathematical Operations on Array Date: Fri, 01 Apr 2011 15:45:24 -0400 References: <3573139D2D5DBF468087E68083D59B2702F48FEC7E@USFWA1EXMBX4.itt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: <3573139D2D5DBF468087E68083D59B2702F48FEC7E@USFWA1EXMBX4.itt.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 36 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1301687408 news.xs4all.nl 81484 [::ffff:82.94.164.166]:33676 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2392 On 4/1/2011 8:56 AM, Fodness, Bryan C - GS wrote: > I am loading text into an array and would like to convert the values. > from math import * > from numpy import * > from pylab import * > data=loadtxt('raw.dat') > mincos=degrees(acos(data[:,0])) > minazi=degrees(data[:,1]) > minthick=data[:,2]/0.006858 > > I am not sure why degrees() works, but acos() does not. It is not clear how you know that. > I receive the following > > Traceback (most recent call last): > File "C:\ test.py", line 6, in ? > mincos=degrees(acos(float(data[:,0]))) > > TypeError: only length-1 arrays can be converted to Python scalars This does not say where in the expression the problem arose. to be sure a = float(data([:,0]) b = acod(a) c = degrees(b) > Can anyone tell me what I am doing wrong? Numpy questions get better answers on the numpy list where numpy experts hang out. -- Terry Jan Reedy