diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index d9d77dc..fe60e27 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -85,9 +85,17 @@ class TimeitResult(object): return (math.fsum([(x - mean) ** 2 for x in self.timings]) / len(self.timings)) ** 0.5 def __str__(self): + pm = '+-' + if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding: + try: + u'\xb1'.encode(sys.stdout.encoding) + pm = u'\xb1' + except: + pass return ( - u"{mean} ± {std} per loop (mean ± std. dev. of {runs} run{run_plural}, {loops} loop{loop_plural} each)" + u"{mean} {pm} {std} per loop (mean {pm} std. dev. of {runs} run{run_plural}, {loops} loop{loop_plural} each)" .format( + pm = pm, runs = self.repeat, loops = self.loops, loop_plural = "" if self.loops == 1 else "s", diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index a7402d9..4f166f9 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -598,12 +598,12 @@ class TestAstTransform(unittest.TestCase): called.add(x) ip.push({'f':f}) - with tt.AssertPrints("mean ± std"): + with tt.AssertPrints("std. dev. of"): ip.run_line_magic("timeit", "-n1 f(1)") self.assertEqual(called, {-1}) called.clear() - with tt.AssertPrints("mean ± std"): + with tt.AssertPrints("std. dev. of"): ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") self.assertEqual(called, {-2, -3}) @@ -671,12 +671,12 @@ class TestAstTransform2(unittest.TestCase): called.add(x) ip.push({'f':f}) - with tt.AssertPrints("mean ± std"): + with tt.AssertPrints("std. dev. of"): ip.run_line_magic("timeit", "-n1 f(1)") self.assertEqual(called, {(1,)}) called.clear() - with tt.AssertPrints("mean ± std"): + with tt.AssertPrints("std. dev. of"): ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") self.assertEqual(called, {(2,), (3,)})