开发者

How to set number of digits for float point output in Ipython

开发者 https://www.devze.com 2023-01-21 17:51 出处:网络
In octave the output of float point n开发者_如何学运维umbers is limited by default to 4 digits (%.4f). Is there a way to set this behavior using IPython?If you are using numpy a lot, then numpy.set_pr

In octave the output of float point n开发者_如何学运维umbers is limited by default to 4 digits (%.4f). Is there a way to set this behavior using IPython?


If you are using numpy a lot, then numpy.set_printoptions lets you tweak that.

Another option is to use the magic %precision command (only in IPython 0.11 or greater).

I guess that you can put your defaults in your startup configuration file.


%precision also takes a format argument, eg like this (gives you 2 digit precision and non-scientific format):

%precision %.2f


If you want to set the precision to 6 digits, try this:

%precision 6
0

精彩评论

暂无评论...
验证码 换一张
取 消