[SciPy-user] scientific rounding

lorenzo bolla lbolla@gmail....
Mon Jan 7 09:39:41 CST 2008


You can give set_printoptions a try:

In [143]: numpy.set_printoptions(0)

In [144]: print numpy.array([1.3, 1.3e-9])
[   1e+00    1e-09]

hth,
L.

On 1/7/08, Lars Friedrich <lfriedri@imtek.de> wrote:
>
> Hello,
>
> when printing numerical data, rounding is often desirable. I would like
> to do something like 'relative rounding'. What I mean is the following:
>
> round(1.3) -> 1.0
> round(1.3e-9) -> 0.0
>
> What I would like to have is
>
> newFunction(1.3) -> 1.0
> newFunction(1.3e-9) ->1.0e-9
>
> So I would like the newFunction to do the rounding with respect to the
> order of magnitude. Of course, it would be easy to write such a function
> (dividing by the log of the number, rounding, multiplying again), but my
> question is, if such a function is already available in numpy or scipy.
>
> Thanks,
> Lars
>
> --
> Dipl.-Ing. Lars Friedrich
>
> Photonic Measurement Technology
> Department of Microsystems Engineering -- IMTEK
> University of Freiburg
> Georges-Köhler-Allee 102
> D-79110 Freiburg
> Germany
>
> phone: +49-761-203-7531
> fax:   +49-761-203-7537
> room:  01 088
> email: lars.friedrich@imtek.de
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20080107/78d7a5f1/attachment.html 


More information about the SciPy-user mailing list