Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #15398: wrong output of %timeit
Browse files Browse the repository at this point in the history
{{{
sage: R=RealField(1000000)
sage: a=R(1/sqrt(3))
sage: %timeit a.arcsin()
1 loops, best of 3: 7.26 s per loop
}}}
It should be {{{1 loop, best of 3}}}.

URL: https://trac.sagemath.org/15398
Reported by: zimmerma
Ticket author(s): Saket Bhatt
Reviewer(s): Paul Zimmermann
  • Loading branch information
Release Manager committed Feb 29, 2020
2 parents 7a7ffbe + bc52a1c commit 30cb9d1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/sage/misc/sage_timeit.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ def __repr__(self):
sage: from sage.misc.sage_timeit import SageTimeitResult
sage: stats = (1, 2, int(3), pi, 'ns')
sage: SageTimeitResult(stats) #indirect doctest
1 loops, best of 2: 3.14 ns per loop
1 loop, best of 2: 3.14 ns per loop
"""
s = u"%d loops, best of %d: %.*g %s per loop" % self.stats
if self.stats[0] > 1:
s = u"%d loops, best of %d: %.*g %s per loop" % self.stats
else:
s = u"%d loop, best of %d: %.*g %s per loop" % self.stats

if isinstance(s, str):
return s
return s.encode("utf-8")
Expand Down Expand Up @@ -269,3 +273,4 @@ def sage_timeit(stmt, globals_dict=None, preparse=None, number=0, repeat=3, prec
order = 3
stats = (number, repeat, precision, best * scaling[order], units[order])
return SageTimeitResult(stats,series=series)

0 comments on commit 30cb9d1

Please sign in to comment.