timeit unit select breaks with >= 1000second duration

Bug #409566 reported by Fernando Perez
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Committed

Bug Description

[Note - fperez: Reported by David Warde-Farley, patch is his; don't forget to credit in commit log when applying]

This is a minor concern since I don't know how many people use timeit for things that take more than a few seconds but I noticed that if you have a function that runs for say, 1000 seconds, the code in Magic.py fails since 'order' gets a negative number. Thus you get something like 1.0e12 nanoseconds being printed, which is kind of silly.

Attached is a patch that fixes it in the simplest way possible: if best is >= 1000 then just use seconds, e.g.

In [16]: %timeit -n 1 -r 1 time.sleep(1000)
1 loops, best of 1: 1e+03 s per loop

See here for further details:

Related branches

Revision history for this message
Fernando Perez (fdo.perez) wrote :
Revision history for this message
Fernando Perez (fdo.perez) wrote :

Thanks David! Pushed to 0.10.1 (r1236) and trunk (r1258).

Changed in ipython:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.