From e63a316e57646311421ad0b592db322628ce8010 2024-10-25 07:55:12 From: M Bussonnier Date: 2024-10-25 07:55:12 Subject: [PATCH] Creates newlines in the %%timeit documentation (#14556) Fixes #13873 by adding empty lines after semicolons, rendering blocks correctly. Fixes the issue pointed out by this [comment](https://github.com/ipython/ipython/issues/13873#issuecomment-1363442055) 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) --- diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index e0b7040..3aa0a27 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -195,12 +195,16 @@ class ExecutionMagics(Magics): """Run a statement through the python code profiler. - Usage, in line mode: + **Usage, in line mode:** + %prun [options] statement - Usage, in cell mode: + **Usage, in cell mode:** + %%prun [options] [statement] + code... + code... In cell mode, the additional code lines are appended to the (possibly @@ -1028,12 +1032,17 @@ class ExecutionMagics(Magics): def timeit(self, line='', cell=None, local_ns=None): """Time execution of a Python statement or expression - Usage, in line mode: + **Usage, in line mode:** + %timeit [-n -r [-t|-c] -q -p

-o] statement - or in cell mode: + + **or in cell mode:** + %%timeit [-n -r [-t|-c] -q -p

-o] setup_code - code - code... + + code + + code... Time execution of a Python statement or expression using the timeit module. This function can be used both as a line and cell magic: @@ -1046,6 +1055,7 @@ class ExecutionMagics(Magics): body has access to any variables created in the setup code. Options: + -n: execute the given statement times in a loop. If is not provided, is determined so as to get sufficient accuracy. @@ -1066,7 +1076,7 @@ class ExecutionMagics(Magics): -q: Quiet, do not print result. -o: return a TimeitResult that can be stored in a variable to inspect - the result in more details. + the result in more details. .. versionchanged:: 7.3 User variables are no longer expanded,