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


Groups > comp.lang.python > #2392 > unrolled thread

Re: Mathematical Operations on Array

Started byTerry Reedy <tjreedy@udel.edu>
First post2011-04-01 15:45 -0400
Last post2011-04-01 15:45 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Mathematical Operations on Array Terry Reedy <tjreedy@udel.edu> - 2011-04-01 15:45 -0400

#2392 — Re: Mathematical Operations on Array

FromTerry Reedy <tjreedy@udel.edu>
Date2011-04-01 15:45 -0400
SubjectRe: Mathematical Operations on Array
Message-ID<mailman.96.1301687408.2990.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web