[SciPy-user] nice floating point display ?
Stef Mientki
s.mientki at ru.nl
Fri Feb 29 13:51:23 EST 2008
thanks Robert,
Robert Kern wrote:
> On Thu, Feb 28, 2008 at 5:43 PM, Stef Mientki <s.mientki at ru.nl> wrote:
>
>> hello,
>>
>> I'm creating an float / log slider,
>> now I need a nice representation of the min / max / value
>> of the slider.
>>
>> For some unknown reason
>> set_printoptions(precision=2)
>> doesn't work,
>> and I doubt if it is adequate in my application,
>> because precision and notation depends more on the range
>> than on the actual value itself.
>>
>> Does anyone has a elegant solution ?
>>
>
> set_printoptions() doesn't affect Python floats at all, and that looks
> like what you are trying to print.
>
>
I didn't know that, but it sounds very plausible after all ;-)
> You can explicitly format the numbers yourself:
>
> http://docs.python.org/dev/library/stdtypes.html#string-formatting-operations
>
>
> In [39]: x = 1.2345678901
>
> In [40]: '%f' % x
> Out[40]: '1.234568'
>
>
Yes that's part of the answer ( I already knew),
but the rest of the problem looks more complicated to me,
(whether I have a range of 1..1000 or 0.0000004 ...0.00000041 etc)
and I think a number of people has already solved this part of the
problem (like in MatPlotlib).
For now I'm going to for a very simple solution,
let the user specify the format ;-)
cheers,
Stef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080229/144aedb2/attachment.html>
More information about the SciPy-User
mailing list