Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2352
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Mathematical Operations on Array |
| Date | 2011-04-01 15:52 +0200 |
| Organization | None |
| References | <decec810-5909-4a2e-a682-13979a8046f5@t13g2000vbo.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.74.1301665981.2990.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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