Skip to content

Commit e63a316

Browse files
authored
Creates newlines in the %%timeit documentation (ipython#14556)
Fixes ipython#13873 by adding empty lines after semicolons, rendering blocks correctly. Fixes the issue pointed out by this [comment](ipython#13873 (comment)) Fixes unintentional bolding in the later part of the same section, by removing indentation: ![image](https://github.com/user-attachments/assets/0200ff8a-6a0d-4250-85d6-ddb94c04725c)
2 parents 18e4529 + 1a91aca commit e63a316

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

IPython/core/magics/execution.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,16 @@ def prun(self, parameter_s='', cell=None):
195195

196196
"""Run a statement through the python code profiler.
197197
198-
Usage, in line mode:
198+
**Usage, in line mode:**
199+
199200
%prun [options] statement
200201
201-
Usage, in cell mode:
202+
**Usage, in cell mode:**
203+
202204
%%prun [options] [statement]
205+
203206
code...
207+
204208
code...
205209
206210
In cell mode, the additional code lines are appended to the (possibly
@@ -1028,12 +1032,17 @@ def _run_with_timing(run, nruns):
10281032
def timeit(self, line='', cell=None, local_ns=None):
10291033
"""Time execution of a Python statement or expression
10301034
1031-
Usage, in line mode:
1035+
**Usage, in line mode:**
1036+
10321037
%timeit [-n<N> -r<R> [-t|-c] -q -p<P> -o] statement
1033-
or in cell mode:
1038+
1039+
**or in cell mode:**
1040+
10341041
%%timeit [-n<N> -r<R> [-t|-c] -q -p<P> -o] setup_code
1035-
code
1036-
code...
1042+
1043+
code
1044+
1045+
code...
10371046
10381047
Time execution of a Python statement or expression using the timeit
10391048
module. This function can be used both as a line and cell magic:
@@ -1046,6 +1055,7 @@ def timeit(self, line='', cell=None, local_ns=None):
10461055
body has access to any variables created in the setup code.
10471056
10481057
Options:
1058+
10491059
-n<N>: execute the given statement <N> times in a loop. If <N> is not
10501060
provided, <N> is determined so as to get sufficient accuracy.
10511061
@@ -1066,7 +1076,7 @@ def timeit(self, line='', cell=None, local_ns=None):
10661076
-q: Quiet, do not print result.
10671077
10681078
-o: return a TimeitResult that can be stored in a variable to inspect
1069-
the result in more details.
1079+
the result in more details.
10701080
10711081
.. versionchanged:: 7.3
10721082
User variables are no longer expanded,

0 commit comments

Comments
 (0)