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


Groups > comp.lang.python > #2352

Re: Mathematical Operations on Array

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; '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; '>>>': 0.12; 'wrote:': 0.14; 'numpy': 0.16; 'pylab': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'subject:Operations': 0.16; 'traceback': 0.16; '(most': 0.16; 'math': 0.16; 'skip:m 30': 0.16; 'loading': 0.19; 'not.': 0.22; 'convert': 0.22; 'converted': 0.23; 'last):': 0.23; 'values.': 0.23; 'wrong?': 0.23; 'arrays': 0.31; 'from:addr:web.de': 0.31; 'typeerror:': 0.31; 'does': 0.31; 'anyone': 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'things': 0.33; 'array': 0.33; 'using': 0.34; 'header:X-Complaints-To:1': 0.34; 'file': 0.35; 'doing': 0.36; 'but': 0.38; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'where': 0.39; 'from:': 0.39; 'header :Mime-Version:1': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'receive': 0.68; 'works,': 0.69
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Mathematical Operations on Array
Date Fri, 01 Apr 2011 15:52:55 +0200
Organization None
References <decec810-5909-4a2e-a682-13979a8046f5@t13g2000vbo.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084d3bf.dip.t-dialin.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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.74.1301665981.2990.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 82.94.164.166
X-Trace 1301665981 news.xs4all.nl 81481 [::ffff:82.94.164.166]:42623
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2352

Show key headers only | View raw


Bryan.Fodness@gmail.com 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.
> 
> 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
> 
> Can anyone tell me what I am doing wrong?

Using star-imports. 

Among other things it makes it hard to keep track of where things are coming 
from:

>>> from math import *
>>> from numpy import *
>>> degrees
<ufunc 'degrees'>
>>> acos
<built-in function acos>
>>> acos.__module__
'math'
>>> arccos
<ufunc 'arccos'>


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


Thread

Mathematical Operations on Array "Bryan.Fodness@gmail.com" <bryan.fodness@gmail.com> - 2011-04-01 06:35 -0700
  Re: Mathematical Operations on Array Peter Otten <__peter__@web.de> - 2011-04-01 15:52 +0200
    Re: Mathematical Operations on Array "Bryan.Fodness@gmail.com" <bryan.fodness@gmail.com> - 2011-04-01 07:00 -0700
  Re: Mathematical Operations on Array Terry Reedy <tjreedy@udel.edu> - 2011-04-01 15:49 -0400

csiph-web