Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For timeit magic, no s at "loops" if only one loop #8925

Merged
merged 1 commit into from
Oct 25, 2015
Merged

For timeit magic, no s at "loops" if only one loop #8925

merged 1 commit into from
Oct 25, 2015

Conversation

Naereen
Copy link
Contributor

@Naereen Naereen commented Oct 25, 2015

Just a tiny tiny grammatical correction: no s at "loops" if there is only one loop.
It affects the %timeit magic, its doc, and the message about "an intermediate result being cached".

A message like "1 loops, best of 3: 307 ms per loop" always bothered me 😄 as there is only one loop.
So loopsloop if there is only one.

Just a grammatical correction: no s at "loops" if there is only one loop.
It affects the %timeit magic, its doc, and the message about "an intermediate result being cached".
@Carreau
Copy link
Member

Carreau commented Oct 25, 2015

Thanks that's great !
I suppose we don't have to handle the case where there is 0 loops :-P

Carreau added a commit that referenced this pull request Oct 25, 2015
For timeit magic, no s at "loops" if only one loop
@Carreau Carreau merged commit acb2c91 into ipython:master Oct 25, 2015
@Naereen
Copy link
Contributor Author

Naereen commented Oct 25, 2015

Well I was wondering about it, but it should never arise right?

Even using -n0 parameter does not force 0 loop:

In [22]: %timeit -n0 time.sleep(2)
1 loops, best of 3: 2 s per loop

@Carreau
Copy link
Member

Carreau commented Oct 25, 2015

Yep, I think the 0 case if fine as is.
I guess we could consider 0 loop if the code was raising an exception, but then we never get to the printing part.

One other way would have been :

u"%d loop%s, best of %d: %s per loop" % ('' if self.loops == 1 else 's' , ...)

It should handle correctly 0, but that's bikeshedding.

@Naereen
Copy link
Contributor Author

Naereen commented Oct 25, 2015

I know the inline .. if .. else .. syntax, but it would have been more confuse here, the ".." % (..) part of the line was already quite long.

That way, we clearly see that we deal with a special case for priting (I added a comment explaining this if someone works on that line again).

@minrk minrk modified the milestone: 4.1 Dec 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants