[SciPy-User] Help Equation

Nicolau Werneck nwerneck@gmail....
Mon Nov 22 07:19:48 CST 2010

Hello, Waléria. That seems correct, except for a missing ')' at the
end. But what exactly are you trying to do? And what problem do you

Is x a floating point value or a numpy array? If you are having the
following error message:

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

Itś because the math.log10 function is expecting a floating point
value, and won't work with lists or a numpy.array .  For that you need
to use numpy.log10(x). For example

In [14]: x = rand(3)

In [15]: x
Out[15]: array([ 0.79868967,  0.04746253,  0.61071733])

In [16]: numpy.log10(x)
Out[16]: array([-0.09762193, -1.32364908, -0.21415976])

In [17]: math.log10(x)
TypeError                                 Traceback (most recent call

/home/nlw/<ipython console> in <module>()

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

In [18]: 

See you,


On Mon, Nov 22, 2010 at 08:53:29AM -0200, Waléria Antunes David wrote:
>    That's correct?
>    I have this equationn m = 25+5log10(x)
>    In python i did so:
>    25 + (5 * math.log10(x)
>    Is correct?
>    Thanks,
>    Waléria.

> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user

Nicolau Werneck <nwerneck@usp.br>             C3CF E29F 5350 5DAA 3705
http://nwerneck.sdf.org                       7B9E D6C4 37BB DA64 6F15
Linux user #460716
"We should continually be striving to transform every art into a science: in the process, we advance the art."
-- Donald Knuth

More information about the SciPy-User mailing list