[IPython-dev] Engineering formatting

Robert Kern robert.kern@gmail....
Tue Apr 20 12:46:05 CDT 2010

On 4/19/10 3:37 PM, Stéfan van der Walt wrote:
> Hi all,
> This is probably an easy question, but how do I tweak IPython to
> display my numerical results in engineering notation?

Use the pretty extension! In your ipy_user_conf.py:

from IPython.Extensions import ipy_pretty


def float_eng_pprinter(obj, p, cycle):
     p.text('%e' % obj)

def array_eng_pprinter(obj, p, cycle):
     # ... Left as exercise for the reader.

ipy_pretty.for_type(float, float_eng_pprinter)
ipy_pretty.for_type_by_name('numpy', 'ndarray', array_eng_pprinter)

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though 
it had
  an underlying truth."
   -- Umberto Eco

More information about the IPython-dev mailing list