
    ^h                     r   S r SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJrJr  SSKJrJrJrJrJrJrJrJrJrJr  SSKJ r   SSK!J"r"  SSK#J$r$  SSK%J&r&  SS	K'J(r(J)r)  SS
K*J+r+  SSK,J-r-J.r.J/r/  SSK0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?  SSK@JArA  SSKBJCrC  SSKDJErE  SSKFJGrG  SSKHJIrI  SSKJJKrKJLrL  SSKMJNrNJOrO  SSKPJQrQ   " S S\R5      rS " S S\R6                  5      rT " S S\R                  5      rU\; " S S\75      5       rVS  rWS"S! jrXg)#z4Implementation of execution-related magic functions.    N)DictAny)
AssignCallExprLoadModuleNameNodeTransformerStoreparseunparse)StringIO)error)Path)Restart)dedentindent)warn)magic_argumentsoinspectpage)DisplayHook)
UsageError)Macro)	Magics
cell_magicline_cell_magic
line_magicmagics_classneeds_local_scopeno_var_expandon_offoutput_can_be_silenced)skip_doctest)capture_output)preserve_keys)Struct)find_mod)get_py_filename	shellglob)clockclock2)ReplaceCodeTransformerc                   J    \ rS rSrSrS r\S 5       r\S 5       rS r	S r
Srg	)
TimeitResultH   av  
Object returned by the timeit magic with info about the run.

Contains the following attributes :

loops: (int) number of loops done per measurement
repeat: (int) number of times the measurement has been repeated
best: (float) best execution time / number
all_runs: (list of float) execution time of each run (in s)
compile_time: (float) time of statement compilation (s)

c                     Xl         X l        X0l        X@l        XPl        X`l        Xpl        U Vs/ s H  oU R                   -  PM     snU l        g s  snf N)loopsrepeatbestworstall_runscompile_time
_precisiontimings)	selfr4   r5   r6   r7   r8   r9   	precisiondts	            W/home/james-whalen/.local/lib/python3.13/site-packages/IPython/core/magics/execution.py__init__TimeitResult.__init__U   sE    
	
 (#3;<8Rdjj8<<s   Ac                 n    [         R                  " U R                  5      [        U R                  5      -  $ r3   )mathfsumr;   lenr<   s    r?   averageTimeitResult.average_   s#    yy&T\\):::    c                     U R                   n[        R                  " U R                   Vs/ s H
  o"U-
  S-  PM     sn5      [	        U R                  5      -  S-  $ s  snf )N   g      ?)rG   rC   rD   r;   rE   )r<   meanxs      r?   stdevTimeitResult.stdevc   sJ    ||		DLLALqH?LABSEVV[^^^As   Ac                    Sn[        [        R                  S5      (       aK  [        R                  R                  (       a,   SR	                  [        R                  R                  5        SnSR                  UU R                  U R                  U R                  S:X  a  SOSU R                  S:X  a  SOS[        U R                  U R                  5      [        U R                  U R                  5      S9$ !    N= f)	Nz+-encoding   ±zl{mean} {pm} {std} per loop (mean {pm} std. dev. of {runs} run{run_plural}, {loops:,} loop{loop_plural} each)    s)pmrunsr4   loop_plural
run_pluralrL   std)hasattrsysstdoutrQ   encodeformatr5   r4   _format_timerG   r:   rN   )r<   rV   s     r?   __str__TimeitResult.__str__h   s    3::z**szz/B/Bszz223 ~  E  E**"jjAo3![[A-r3dllDOO<TZZ9 E 
 	
s   +C6 6C:c                 R    U R                  5       nUR                  SU-   S-   5        g )Nz<TimeitResult : >)ra   text)r<   pcycleunics       r?   _repr_pretty_TimeitResult._repr_pretty_z   s$    ||~	"4',-rI   )r:   r8   r6   r9   r4   r5   r;   r7   N)__name__
__module____qualname____firstlineno____doc__r@   propertyrG   rN   ra   ri   __static_attributes__ rI   r?   r0   r0   H   s@    = ; ; _ _
$.rI   r0   c                   *    \ rS rSrSrS rS rS rSrg)TimeitTemplateFiller   zFill in the AST template for timing execution.

This is quite closely tied to the template definition, which is in
:meth:`ExecutionMagics.timeit`.
c                     Xl         X l        g r3   	ast_setupast_stmt)r<   rx   ry   s      r?   r@   TimeitTemplateFiller.__init__   s    " rI   c                     U R                  U5        UR                  S:X  a#  U R                  R                  UR                  SS& U$ )zFill in the setup statementinnerNrS   )generic_visitnamerx   bodyr<   nodes     r?   visit_FunctionDef&TimeitTemplateFiller.visit_FunctionDef   s:    4 99 NN//DIIbqMrI   c                     [        [        UR                  S   SS5      SS5      S:X  a  U R                  R                  Ul        U$ )z!Fill in the statement to be timedr   valueNidstmt)getattrr   ry   r   s     r?   	visit_ForTimeitTemplateFiller.visit_For   s:    7499Q<$7tDN**DIrI   rw   N)	rk   rl   rm   rn   ro   r@   r   r   rq   rr   rI   r?   rt   rt      s    
!rI   rt   c                   8    \ rS rSrSr\R                  4S jrSrg)Timer   z|Timer class that explicitly uses self.inner

which is an undocumented implementation detail of CPython,
not shared by PyPy.
c                 <   [         R                  " SU5      n[        R                  " 5       n[        R                  " 5          U R                  X R                  5      nU(       a  [        R                  " 5         U$ ! U(       a  [        R                  " 5         f f = f)a  Time 'number' executions of the main statement.

To be precise, this executes the setup statement once, and
then returns the time it takes to execute the main statement
a number of times, as a float measured in seconds.  The
argument is the number of times through the loop, defaulting
to one million.  The main statement, the setup statement and
the timer function to be used are passed to the constructor.
N)	itertoolsr5   gc	isenableddisabler|   timerenable)r<   numberitgcoldtimings        r?   timeitTimer.timeit   sg     dF+


	ZZJJ/F		 		 s   A< <Brr   N)rk   rl   rm   rn   ro   r   default_numberrq   rr   rI   r?   r   r      s     #11 rI   r   c                     ^  \ rS rSr% Sr0 r\\\4   \	S'   U 4S jr
\\\S5S j5       5       5       rS r\S6S	 j5       r\R$                  " 5       \R&                  " S
SSSS9\R&                  " SSSS9\\\S7S j5       5       5       5       5       5       rS rS8S jr\S 5       r\\SS\4S j5       5       r S9S jr\S 5       r\\\\S7S j5       5       5       5       r\\\\\S7S j5       5       5       5       5       r \\S6S j5       5       r!\R$                  " 5       \R&                  " S\SSSS 9\R&                  " S!S"S#S$9\R&                  " S%S"S&S$9\R&                  " S'S"S(S$9\"S) 5       5       5       5       5       5       r#\\R$                  " 5       \R&                  " S*\S+SS,9\R&                  " S-S"S.S$9\R&                  " S/S"S0S$9\R&                  " S1S"S2S$9\S8S3 j5       5       5       5       5       5       5       r$S4r%U =r&$ ):ExecutionMagics   z<Magics related to code execution, debugging, profiling, etc._transformersc                 :   > [         [        U ]  U5        S U l        g r3   )superr   r@   default_runner)r<   shell	__class__s     r?   r@   ExecutionMagics.__init__   s    ot-e4"rI   rT   Nc                     U R                  USSSS9u  p4Ub  USU-   -  nU R                  R                  U5      nU R                  XCU R                  R                  5      $ )a  Run a statement through the python code profiler.

Usage, in line mode:
  %prun [options] statement

Usage, in cell mode:
  %%prun [options] [statement]
  code...
  code...

In cell mode, the additional code lines are appended to the (possibly
empty) statement in the first line.  Cell mode allows you to easily
profile multiline blocks without having to put them in a separate
function.

The given statement (which doesn't require quote marks) is run via the
python profiler in a manner similar to the profile.run() function.
Namespaces are internally managed to work correctly; profile.run
cannot be used in IPython because it makes certain assumptions about
namespaces which do not hold under IPython.

Options:

-l <limit>
  you can place restrictions on what or how much of the
  profile gets printed. The limit value can be:

     * A string: only information for function names containing this string
       is printed.

     * An integer: only these many lines are printed.

     * A float (between 0 and 1): this fraction of the report is printed
       (for example, use a limit of 0.4 to see the topmost 40% only).

  You can combine several limits with repeated use of the option. For
  example, ``-l __init__ -l 5`` will print only the topmost 5 lines of
  information about class constructors.

-r
  return the pstats.Stats object generated by the profiling. This
  object has all the information about the profile in it, and you can
  later use it for further analysis or in other functions.

-s <key>
  sort profile by given key. You can provide more than one key
  by using the option several times: '-s key1 -s key2 -s key3...'. The
  default sorting key is 'time'.

  The following is copied verbatim from the profile documentation
  referenced below:

  When more than one key is provided, additional keys are used as
  secondary criteria when the there is equality in all keys selected
  before them.

  Abbreviations can be used for any key names, as long as the
  abbreviation is unambiguous.  The following are the keys currently
  defined:

  ============  =====================
  Valid Arg     Meaning
  ============  =====================
  "calls"       call count
  "cumulative"  cumulative time
  "file"        file name
  "module"      file name
  "pcalls"      primitive call count
  "line"        line number
  "name"        function name
  "nfl"         name/file/line
  "stdname"     standard name
  "time"        internal time
  ============  =====================

  Note that all sorts on statistics are in descending order (placing
  most time consuming items first), where as name, file, and line number
  searches are in ascending order (i.e., alphabetical). The subtle
  distinction between "nfl" and "stdname" is that the standard name is a
  sort of the name as printed, which means that the embedded line
  numbers get compared in an odd way.  For example, lines 3, 20, and 40
  would (if the file names were the same) appear in the string order
  "20" "3" and "40".  In contrast, "nfl" does a numeric compare of the
  line numbers.  In fact, sort_stats("nfl") is the same as
  sort_stats("name", "file", "line").

-T <filename>
  save profile results as shown on screen to a text
  file. The profile is still shown on screen.

-D <filename>
  save (via dump_stats) profile statistics to given
  filename. This data is in a format understood by the pstats module, and
  is generated by a call to the dump_stats() method of profile
  objects. The profile is still shown on screen.

-q
  suppress output to the pager.  Best used with -T and/or -D above.

If you want to run complete programs under the profiler's control, use
``%run -p [prof_opts] filename.py [args to program]`` where prof_opts
contains profiler specific options as described here.

You can read the complete documentation for the profile module with::

  In [1]: import profile; profile.help()

.. versionchanged:: 7.3
    User variables are no longer expanded,
    the magic line is always left unmodified.

z
D:l:rs:T:qTF)list_allposix
)parse_optionsr   transform_cell_run_with_profileruser_ns)r<   parameter_scelloptsarg_strs        r?   prunExecutionMagics.prun   sk    j **;48 + Gtd{"G**++G4&&wdjj6H6HIIrI   c           	         UR                  [        S// S/S/S95        [        R                  " 5       n UR	                  XU5      nSn[        R                  " U5      R                  5       R                  " UR                  6 nUR                  nU(       a0  / nUR                   H  n UR                  [        U5      5        M      [!        5       n	UR"                  n
 Xl        UR$                  " U6   Xl        U	R'                  5       nUR)                  5       nSU;  a  [*        R*                  " U5        [-        USS9  UR.                  S   nUR0                  S   nU(       a+  UR3                  U5        [-        S	[5        U5       S
U 35        U(       aD  [7        U5      nUR9                  SS9  UR;                  USS9  [-        S[5        U5       S
U 35        SU;   a  U$ g! [
         a    Sn GNf = f! [         aD     UR                  [        U5      5         GMz  ! [         a    UR                  U5          GM  f = ff = f! Xl        f = f)a
  
Run `code` with profiler.  Used by ``%prun`` and ``%run -p``.

Parameters
----------
code : str
    Code to be executed.
opts : Struct
    Options parsed by `self.parse_options`.
namespace : dict
    A dictionary for Python namespace (e.g., `self.shell.user_ns`).

rT   time)DlrU   Tz7*** SystemExit exception caught in code being profiled.q endr   z&
*** Profile stats marshalled to file .T)exist_okzutf-8)rQ   z)
*** Profile printout saved to text file rN)merger(   profileProfilerunctx
SystemExitpstatsStats
strip_dirs
sort_statsrU   r   appendint
ValueErrorfloatr   streamprint_statsgetvaluerstripr   printr   r   
dump_statsreprr   touch
write_text)r<   coder   	namespaceprofsys_exitstatslimslimstdout_trapstats_streamoutput	dump_file	text_filepfiles                  r?   r   "ExecutionMagics._run_with_profiler;  s     	

6RDB6(rd;< 	U;;t	:DH T"--/::DFFCvvDvv)KKC)  j||	(&Lt$'L%%'d?IIfhC FF1I	FF1I	OOI&9$y/9J!H:V OEKKK&Vg6<T)_<MQxjY $;Li  	UTH	U " ))E#J//% )C(()) (LsG   G# )G6I #G32G36
IHI :I?I  IIc                    UR                  5       R                  5       nU(       a   SSSSS.U   nOU R                  R
                  (       + nX0R                  l        [        S[        U5      5        g! [         a    [        S5         gf = f)aS  Control the automatic calling of the pdb interactive debugger.

Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
argument it works as a toggle.

When an exception is triggered, IPython can optionally call the
interactive pdb debugger after the traceback printout. %pdb toggles
this feature on and off.

The initial state of this feature is set in your configuration
file (the option is ``InteractiveShell.pdb``).

If you want to just activate the debugger AFTER an exception has fired,
without having to type '%pdb on' and rerunning your code, you can use
the %debug magic.r   rS   )off0on1z=Incorrect argument. Use on/1, off/0, or nothing for a toggle.Nz%Automatic pdb calling has been turned)striplowerKeyErrorr   r   call_pdbr#   )r<   r   parnew_pdbs       r?   pdbExecutionMagics.pdb  s    $ !'')!"qaA6s; **---G &

5fWoF   2 3s   
A3 3B
Bz--breakpointz-bz	FILE:LINEz2
        Set break point at LINE in FILE.
        )metavarhelp	statement*zX
        Code to run in debugger.
        You can omit this in cell magic mode.
        )nargsr   c                    [         R                  " U R                  U5      nUR                  (       d)  UR                  (       d  U(       d  U R                  5         gUR                  (       d  U(       d  U R                  USU5        gSR                  UR                  5      nU(       a  USU-   -  nU R                  XTR                  U5        g)a  Activate the interactive debugger.

This magic command support two ways of activating debugger.
One is to activate debugger before executing code.  This way, you
can set a break point, to step through the code from the point.
You can use this mode by giving statements to execute and optionally
a breakpoint.

The other one is to activate debugger in post-mortem mode.  You can
activate this mode simply running %debug without any argument.
If an exception has just occurred, this lets you inspect its stack
frames interactively.  Note that this will always work only on the last
traceback that occurred, so you must call this quickly after an
exception that you wish to inspect has fired, because if another one
occurs, it clobbers the previous one.

If you want IPython to automatically do this on every exception, see
the %pdb magic for more details.

.. versionchanged:: 7.3
    When running code, user variables are no longer expanded,
    the magic line is always left unmodified.

Nr   )r   parse_argstringdebug
breakpointr   _debug_post_mortem_debug_execjoin)r<   liner   local_nsargsr   s         r?   r   ExecutionMagics.debug  s    P ..tzz4@4>>T##%//TT42
 99T^^,Dt#T??H=rI   c                 6    U R                   R                  SS9  g )NT)force)r   debuggerrF   s    r?   r   "ExecutionMagics._debug_post_mortem  s    

$'rI   c                     U(       a   UR                  SS5      u  pE[        U5      nOSu  pEU R                  XR                  R                  XEUS9  g )N:rS   )NN)r   )rsplitr   _run_with_debuggerr   r   )r<   r   r   r   filenamebp_lines         r?   r   ExecutionMagics._debug_exec  sO    ","3"3C";X'lG".X**$$h( 	  	
rI   c                    U R                   R                  nU(       ah  S nUR                  5       R                  5       nUR                  n  UR                  US9  U R                   R                  5         UR                  US9  gU R                   R                  5         g! [         a    U" S5         N?f = f! UR                  US9  f = f)a  Print the last traceback.

Optionally, specify an exception reporting mode, tuning the
verbosity of the traceback. By default the currently-active exception
mode is used. See %xmode for changing exception reporting modes.

Valid modes: Plain, Context, Verbose, and Minimal.
c                 V    [        SU < S[        R                  " 5       S   < 35        g )NzError changing z exception modes.
rS   )r   r\   exc_info)r~   s    r?   xmode_switch_err,ExecutionMagics.tb.<locals>.xmode_switch_err  s    #,,.+- .rI   modeuserN)r   InteractiveTBr   
capitalizer  set_modeshowtraceback	Exception)r<   rU   interactive_tbr  new_modeoriginal_modes         r?   tbExecutionMagics.tb  s     11. wwy++-H*//M</"+++: JJ,,.'']';JJ$$& ! -$V,-
 '']';s*   B! B9 !B63B9 5B66B9 9C
c                   ^ ^^^^^ SU;   a  SU;  a  [         R                  " U[        R                  S:H  S9n[	        U5       HG  u  pVU(       a;  UR                  S5      (       a%  US:w  a  US:X  a  UR                  US-   S5          OMG    O   SR                  S U 5       5      nT R                  US	S
SS9u  pxSU;   a,  US   S   m[        T5      n	U	c  ST-  n
[        U
5      eU	/U-   n SnUS   nU" U5      mTR-                  5       R/                  S5      (       a]  [1        T R2                  R4                  S5         TT R2                  R4                  S'   T R2                  R7                  TSS9  SSS5        gSU;   m[(        R8                  nSU;   a  USS nO0[;        [=        [        R>                  R@                  USS 5      5      nT/U-   [(        l        SU;   a  [C        T5      RD                  nOSnSU;   aP  T R2                  R4                  mT R2                  R4                  S   nUTS'   T R2                  RF                  nTTS'   O(T R2                  RI                  TU5      nURJ                  mTS   nUS:X  a  [(        RL                  S   nOS nU[(        RL                  U'   S!U;   d  S"U;   aQ  SU;   a  S#nT R2                  RN                  TTS$.nO.S"U;   a  S%nOS&nT R2                  RP                  T[S        T5      S'.n SnS!U;   a  T RU                  WUW5      nGOBS"U;   a:  [W        URY                  S(S)/5      S   T5      u  nnT R[                  WWTUU5        GOSU;   a	  UUU 4S* jnO1Tc  T R\                  mTc  T R2                  RP                  mUUUU4S+ jnS,U;   a   [_        US-   S   5      nUS:  a  [a        S.5         [b        T R2                  R4                  S/'   U[(        l        U(       a<  U[(        RL                  S'   S0[(        RL                  ;   a  U[(        RL                  S0'   gg[(        RL                  U	 g T Rg                  UU5        OU" 5         SU;   a  WT R2                  R4                  S'   O`TRi                  SS5        [1        T R2                  R4                  S5         T R2                  R4                  Rk                  T5        SSS5        [b        T R2                  R4                  S/'   U[(        l        U(       a<  U[(        RL                  S'   S0[(        RL                  ;   a  U[(        RL                  S0'   U$ [(        RL                  U	  U$ ! [         a  nSn
[        U
5      UeSnAf[         au  n [        U5      n
O! [         a    UR                  n
 Of = f[        R                  S:X  a'  [         R"                  " SW5      (       a  [%        S5        [        U
5      UeSnAf[&         a    W[(        R*                  ;   a  Sm GN(e f = f! , (       d  f       g= f! [d         a    Sn GNf = f! , (       d  f       GNr= f! [b        T R2                  R4                  S/'   U[(        l        U(       a<  U[(        RL                  S'   S0[(        RL                  ;   a  U[(        RL                  S0'   f f [(        RL                  U	 f = f)1ak  Run the named file inside IPython as a program.

Usage::

  %run [-n -i -e -G]
       [( -t [-N<N>] | -d [-b<N>] | -p [profile options] )]
       ( -m mod | filename ) [args]

The filename argument should be either a pure Python script (with
extension ``.py``), or a file with custom IPython syntax (such as
magics). If the latter, the file can be either a script with ``.ipy``
extension, or a Jupyter notebook with ``.ipynb`` extension. When running
a Jupyter notebook, the output from print statements and other
displayed objects will appear in the terminal (even matplotlib figures
will open, if a terminal-compliant backend is being used). Note that,
at the system command line, the ``jupyter run`` command offers similar
functionality for executing notebooks (albeit currently with some
differences in supported options).

Parameters after the filename are passed as command-line arguments to
the program (put in sys.argv). Then, control returns to IPython's
prompt.

This is similar to running at a system prompt ``python file args``,
but with the advantage of giving you IPython's tracebacks, and of
loading all variables into your interactive namespace for further use
(unless -p is used, see below).

The file is executed in a namespace initially consisting only of
``__name__=='__main__'`` and sys.argv constructed as indicated. It thus
sees its environment as if it were being run as a stand-alone program
(except for sharing global objects such as previously imported
modules). But after execution, the IPython interactive namespace gets
updated with all variables defined in the program (except for __name__
and sys.argv). This allows for very convenient loading of code for
interactive work, while giving each program a 'clean sheet' to run in.

Arguments are expanded using shell-like glob match.  Patterns
'*', '?', '[seq]' and '[!seq]' can be used.  Additionally,
tilde '~' will be expanded into user's home directory.  Unlike
real shells, quotation does not suppress expansions.  Use
*two* back slashes (e.g. ``\\*``) to suppress expansions.
To completely disable these expansions, you can use -G flag.

On Windows systems, the use of single quotes `'` when specifying
a file is not supported. Use double quotes `"`.

Options:

-n
  __name__ is NOT set to '__main__', but to the running file's name
  without extension (as python does under import).  This allows running
  scripts and reloading the definitions in them without calling code
  protected by an ``if __name__ == "__main__"`` clause.

-i
  run the file in IPython's namespace instead of an empty one. This
  is useful if you are experimenting with code written in a text editor
  which depends on variables defined interactively.

-e
  ignore sys.exit() calls or SystemExit exceptions in the script
  being run.  This is particularly useful if IPython is being used to
  run unittests, which always exit with a sys.exit() call.  In such
  cases you are interested in the output of the test results, not in
  seeing a traceback of the unittest module.

-t
  print timing information at the end of the run.  IPython will give
  you an estimated CPU time consumption for your script, which under
  Unix uses the resource module to avoid the wraparound problems of
  time.clock().  Under Unix, an estimate of time spent on system tasks
  is also given (for Windows platforms this is reported as 0.0).

If -t is given, an additional ``-N<N>`` option can be given, where <N>
must be an integer indicating how many times you want the script to
run.  The final timing report will include total and per run results.

For example (testing the script uniq_stable.py)::

    In [1]: run -t uniq_stable

    IPython CPU timings (estimated):
      User  :    0.19597 s.
      System:        0.0 s.

    In [2]: run -t -N5 uniq_stable

    IPython CPU timings (estimated):
    Total runs performed: 5
      Times :      Total       Per run
      User  :   0.910862 s,  0.1821724 s.
      System:        0.0 s,        0.0 s.

-d
  run your program under the control of pdb, the Python debugger.
  This allows you to execute your program step by step, watch variables,
  etc.  Internally, what IPython does is similar to calling::

      pdb.run('execfile("YOURFILENAME")')

  with a breakpoint set on line 1 of your file.  You can change the line
  number for this automatic breakpoint to be <N> by using the -bN option
  (where N must be an integer). For example::

      %run -d -b40 myscript

  will set the first breakpoint at line 40 in myscript.py.  Note that
  the first breakpoint must be set on a line which actually does
  something (not a comment or docstring) for it to stop execution.

  Or you can specify a breakpoint in a different file::

      %run -d -b myotherfile.py:20 myscript

  When the pdb debugger starts, you will see a (Pdb) prompt.  You must
  first enter 'c' (without quotes) to start execution up to the first
  breakpoint.

  Entering 'help' gives information about the use of the debugger.  You
  can easily see pdb's full documentation with "import pdb;pdb.help()"
  at a prompt.

-p
  run program under the control of the Python profiler module (which
  prints a detailed report of execution times, function calls, etc).

  You can pass other options after -p which affect the behavior of the
  profiler itself. See the docs for %prun for details.

  In this mode, the program's variables do NOT propagate back to the
  IPython interactive namespace (because they remain in the namespace
  where the profiler executes them).

  Internally this triggers a call to %prun, see its documentation for
  details on the options available specifically for profiling.

There is one special usage for which the text above doesn't apply:
if the filename ends with .ipy[nb], the file is run as ipython script,
just as if the commands were written on IPython prompt.

-m
  specify module name to load instead of script path. Similar to
  the -m option for the python interpreter. Use this option last if you
  want to combine with other %run options. Unlike the python interpreter
  only source modules are allowed no .pyc or .pyo files.
  For example::

      %run -m example

  will run the example module.

-G
  disable shell-like glob expansion of arguments.

z-mz--r   )r   -rK   r   c              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr3   )shlexquote).0args     r?   	<genexpr>&ExecutionMagics.run.<locals>.<genexpr>  s     "Dt5;;s#3#3ts   #%znidtN:b:pD:l:rs:T:em:GlistrS   )r  r   mr   Nz(%r is not a valid modulename on sys.pathz%you must provide at least a filename.ntz^'.*'$zJFor Windows, use double quotes to wrap a filename: %run "mypath\myfile.py"rT   )z.ipyz.ipynb__file__T)raise_exceptionseGn__main__irk   Frf   dzrun_module(modulename, prog_ns))
run_moduleprog_ns
modulenamez2execfile(filename, prog_ns, raise_exceptions=True)zexecfile(filename, prog_ns))execfiler3  r	  br   c                  >   > TR                   R                  T T5        g r3   )r   safe_run_module)r4  r3  r<   s   r?   run ExecutionMagics.run.<locals>.run9  s     JJ66z7KrI   c                     > T" TTTT S9  g )N)exit_ignorerr   )r<  r	  r3  runners   r?   r9  r:  A  s    "8Wg0;=rI   tNzNumber of runs must be >=1__builtins____mp_main__)6r!  splitosr~   	enumerate
startswithinsertr   r   r)   r  
IndexErrorIOErrorstrUnicodeErrormessagerematchr   	TypeErrorr\   	meta_pathr   endswithr'   r   r   safe_execfile_ipyargvr+   mappath
expanduserr   stemuser_modulenew_main_mod__dict__modulesr8  safe_execfiler*   r   parse_breakpointgetr  r   r   r   builtin_modr   _run_with_timingpopupdate)r<   r   r=  file_finderrR  idxr$  r   arg_lstmodpathmsgfpathr,  	save_argvr   r~   _ExecutionMagics__name__savemain_modmain_mod_namerestore_mainr   code_nsr   bp_filer
  r9  nrunsr<  r	  r4  r3  s   ` `                        @@@@r?   r9  ExecutionMagics.run  sJ   F ;4{#:;;{277g3EGD%dO3>>#..3#:d{C!GT2 #
  , (("Dt"DDK **;+C06 + D $;c1Jz*G@Kn$i')G	EAJE"5)H$ >>$$%788tzz11:>19

"":.

,,X,M ?  Tk HH	$;12;D S!3!3gabkBCD:$$;>&&DD$;jj((G::--j9L"&GJzz--H
 #+GJ zz..x>H''G  
+J&;;z2L L &.M"$;#+d{8"&**"<"<&", $;OD8D $

 8 8& / 9G	/Ed{//dGD$;'7se,Q/(;$GW++gx'C d{L L ">%)%8%8F!>%)ZZ%=%=F= = d{&$'S	!$5E$qy %&B C &: 2=DJJ~. !CH*6J' CKK/1=CKK. 0 KK.W  )
 --c59 d{1=

"":. J-"4::#5#5zBJJ&&--g6 C 2=DJJ~. !CH*6J' CKK/1=CKK.  KK.S  	(9CC.a' 	( !f  ii ww$288Ie#<#<bcC.a' 	%		 ?> T !) &$%E&" CB 2=DJJ~. !CH*6J' CKK/1=CKK. 0 KK.s   .U* 4X*B#Y  0"X; A-Y  =&Y#Y  *
X'4VX'VW?V52W?4V55A
W??#X'%X'*
X8;YY  
YY  
YY   A>[c                 B   U R                   R                  R                  nU(       d]  U R                   R                  R                  5       U R                   R                  l        U R                   R                  R                  n[	        US5      (       a  U?S[        R                  l        0 [        R                  l	        S/[        R                  l
        UR                  5         Ub  SnU=(       d    UnUR                  XT5      n	U	(       dC  [        US-   XH-   S-   5       H  n
UR                  XZ5      (       d  M    O   SW
-  n[        U5      eUR                  U< SU< 35        U(       a  SUl        UR#                  U5      Ul        ['        SUR(                  -  5         U(       a  X7l          [,        R.                  " 5       nUR1                  XU5         [,        R2                  " U5        g! [4         aI    ['        S	5        U(       a  SUl        UR#                  U5      Ul         [,        R2                  " W5        M  f = f! [,        R2                  " W5        f = f!   [,        R6                  " 5       u  pnU R                   R                  XUS
S9   g= f)a,  
Run `code` in debugger with a break point.

Parameters
----------
code : str
    Code to execute.
code_ns : dict
    A namespace in which `code` is executed.
filename : str
    `code` is ran as if it is in `filename`.
bp_line : int, optional
    Line number of the break point.
bp_file : str, optional
    Path to the file in which break point is specified.
    `filename` is used if not given.
local_ns : dict, optional
    A local namespace in which `code` is executed.

Raises
------
UsageError
    If the break point given by `bp_line` is not valid.

curframerS   N
   z
I failed to find a valid line to set a breakpoint
after trying up to line: %s.
Please set a valid breakpoint manually with the -b option.r  Tz7NOTE: Enter 'c' at the %s prompt to continue execution.
Restarting   )	tb_offset)r   r  r   debugger_clsr[   rr  bdb
Breakpointnextbplist
bpbynumberclear_all_breaks	checklineranger   do_break_wait_for_mainpyfilecanonic
mainpyfiler   prompt_exec_filenamer\   gettracer9  settracer   r  )r<   r   rm  r	  r
  rn  r   debmaxtriesr~  bprf  traceetyper   r  s                   r?   r  "ExecutionMagics._run_with_debuggerx  s   8 jj&&**+/::+C+C+P+P+RDJJ$$(****..C 3
##   "%)F!H)Gg7I!W-?!-CDB}}W11 E1 46	6C
 %S/)LLGW56'+C$ [[2CN 	G#**TU	D%-"(LLNEGGD84 LL'  ,'370),X)> LL' LL'	D"||~E" JJ$$U2$CsB   (I' 7'G6 I' 69I	/I 0I' I		I I$$I' '5Jc                 R   [         R                  " 5       nUS:X  aY  [        5       nU " 5         [        5       nUS   US   -
  nUS   US   -
  n[        S5        [        SU-  5        [        SU-  5        O[	        U5      n[        5       nU H
  nU " 5         M     [        5       nUS   US   -
  nUS   US   -
  n[        S5        [        SU5        [        SS-  5        [        S	XUU-  4-  5        [        S
XfU-  4-  5        [         R                  " 5       n	[        SX-
  -  5        g)z
Run function `run` and print timing information.

Parameters
----------
run : callable
    Any callable object which takes no argument.
nruns : int
    Number of times to execute `run`.

rS   r   z!
IPython CPU timings (estimated):z  User   : %10.2f s.z  System : %10.2f s.zTotal runs performed:z  Times  : %10s   %10s)TotalzPer runz  User   : %10.2f s, %10.2f s.z  System : %10.2f s, %10.2f s.zWall time: %10.2f s.N)r   perf_counterr-   r   r  )
r9  ro  twall0t0t1t_usrt_sysrW   nrtwall1s
             r?   r_   ExecutionMagics._run_with_timing  s&    ""$A:BEBqEBqEMEqEBqEME67(501(501<DB BqEBqEMEqEBqEME67)51*-AAB2eU]5KKL2eU]5KKL""$$89rI   c           	         U R                  USSSSS9u  pEUS:X  a  Uc  g[        R                  n[        [	        USS5      5      n[        R
                  S	:  a  S	O[        R
                  n[        [	        US
U5      5      n	[        [	        USS5      5      n
SU;   nSU;   n[        US5      (       a  [        R                  n[        US5      (       a  [        n[        US9nU R                  R                  nUcQ  U R                  R                  R                  S5      nU R                  R                  R                  U" U5      5      nOVU R                  R                  R                  U" U5      5      nU R                  R                  R                  U" U5      5      nU R                  R                  U5      nU R                  R                  U5      nU R                  R                  USS5        U R                  R                  USS5        [        R                   " S5      n[#        UU5      R%                  U5      n[        R&                  " U5      nSn[        5       nU R                  R                  USS5      n[        5       U-
  n0 nU R                  R(                  n0 nU(       a;  Uc8  UR+                  5        H  u  nnUU;   d  M  UUU'   M     UR-                  U5        [/        UUU5        US   Ul        US:X  a1  [3        SS5       H!  nSU-  nUR                  U5      nUS:  d  M!    O   UR5                  X5      n[7        U5      U-  n[9        U5      U-  n [;        XyUU UUU
5      n!U(       a  UR-                  U5        U(       dE  U SU-  :  a  US:  a  U S:  a  [=        SU U-  -  5        [=        U!5        UU:  a  [=        SU-  5        U(       a  U!$ g) u  Time execution of a Python statement or expression

Usage, in line mode:
  %timeit [-n<N> -r<R> [-t|-c] -q -p<P> -o] statement
or in cell mode:
  %%timeit [-n<N> -r<R> [-t|-c] -q -p<P> -o] setup_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:

- In line mode you can time a single-line statement (though multiple
  ones can be chained with using semicolons).

- In cell mode, the statement in the first line is used as setup code
  (executed but not timed) and the body of the cell is timed.  The cell
  body has access to any variables created in the setup code.

Options:
-n<N>: execute the given statement <N> times in a loop. If <N> is not
provided, <N> is determined so as to get sufficient accuracy.

-r<R>: number of repeats <R>, each consisting of <N> loops, and take the
average result.
Default: 7

-t: use time.time to measure the time, which is the default on Unix.
This function measures wall time.

-c: use time.clock to measure the time, which is the default on
Windows and measures wall time. On Unix, resource.getrusage is used
instead and returns the CPU user time.

-p<P>: use a precision of <P> digits to display the timing result.
Default: 3

-q: Quiet, do not print result.

-o: return a TimeitResult that can be stored in a variable to inspect
    the result in more details.

.. versionchanged:: 7.3
    User variables are no longer expanded,
    the magic line is always left unmodified.

Examples
--------
::

  In [1]: %timeit pass
  8.26 ns ± 0.12 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)

  In [2]: u = None

  In [3]: %timeit u is None
  29.9 ns ± 0.643 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)

  In [4]: %timeit -r 4 u == None

  In [5]: import time

  In [6]: %timeit -n1 time.sleep(2)

The times reported by %timeit will be slightly higher than those
reported by the timeit.py script when variables are accessed. This is
due to the fact that %timeit executes the statement in the namespace
of the shell, compared with timeit.py, which uses a single setup
statement to import function or create variables. Generally, the bias
does not matter as long as results from timeit.py are not mixed with
those from %timeit.z
n:r:tcp:qoFT)r   strictpreserve_non_optsrT   Nr.  r      r   rf   ru  r   or>  c)r   passz<magic-timeit-setup>execz<magic-timeit-stmt>z}def inner(_it, _timer):
    setup
    _t0 = _timer()
    for _i in _it:
        stmt
    _t1 = _timer()
    return _t1 - _t0
皙?z<magic-timeit>r|   rs  g?   gư>zvThe slowest run took %0.2f times longer than the fastest. This could mean that an intermediate result is being cached.zCompiler time: %.2f s)r   r   default_timerr   r   default_repeatr[   r   r,   r   r   r   compile	ast_parsetransform_astastr   rt   visitfix_missing_locationsr   itemsra  r  r|   r  r5   minmaxr0   r   )"r<   r   r   r   r   r   timefuncr   r  r5   r=   quietreturn_resultr   	transformrx   ry   timeit_ast_template
timeit_asttc_minr  r   tcnsglobconflict_globsvar_namevar_valindextime_numberr8   r6   r7   timeit_results"                                     r?   r   ExecutionMagics.timeit   s   Z '',eET ( 

 2:$,''WT3*+$33a7V=R=RWT378c1-.	tt4yyH4HH% ZZ..	<

**44V<Izz))33IdODH

**44Yt_EIzz))33IdODHJJ,,Y7	::++H5 	

9&<fE

8%:FC
 "ii )A B *)X>DDEXY
..z:
 Wzz!!*.>GWRZzz!!%)ZZ\!'x'/6N8, &2 KK!T4k
 Q;q"u#ll62#%	 & <</8}v%H&$VT5(BPYZ ;;~& q4xD1H ),1DL: ; ="F{-23   rI   c           
      T   U(       a  U(       a  [        S5      eU(       a  U R                  R                  U5      nOU R                  R                  U5      nSn[        5       nU R                  R                  R                  U5      n[        5       U-
  nU R                  R                  U5      nSn	Sn
[        UR                  5      S:X  a^  [        UR                  S   [        R                  5      (       a2  SnSn[        R                  " UR                  S   R                  5      nOSnS	n[        UR                  5      S:  av  [        UR                  S
   [        R                  5      (       aJ  UR                  S
   n
UR                  SS
 n[        U/ 5      n[        R                  " U
R                  5      n
[        5       nU R                  R	                  X|U5      n[        5       U-
  nU R                  R                  n[         R                   nU" 5       nUS:X  a"  [#        5       n [%        XU5      n[#        5       nON[#        5       n [)        XU5        SnU
b(  U R                  R	                  XS5      n[%        UX5      n[#        5       nU" 5       nUU-
  nUS   US   -
  nUS   US   -
  nUU-   n[*        R,                  S:w  a0  [/        S[1        U5       S[1        U5       S[1        U5       35        O[/        S[1        U5       35        [/        S[1        U5       35        X:  a  [/        S[1        U5       35        X:  a  [/        S[1        U5       35        U$ !   U R                  R'                  5          g= f!   U R                  R'                  5          g= f)a  Time execution of a Python statement or expression.

The CPU and wall clock times are printed, and the value of the
expression (if any) is returned.  Note that under Win32, system time
is always reported as 0, since it can not be measured.

This function can be used both as a line and cell magic:

- In line mode you can time a single-line statement (though multiple
  ones can be chained with using semicolons).

- In cell mode, you can time the cell body (a directly
  following statement raises an error).

This function provides very basic timing functionality.  Use the timeit
magic for more control over the measurement.

.. versionchanged:: 7.3
    User variables are no longer expanded,
    the magic line is always left unmodified.

Examples
--------
::

  In [1]: %time 2**128
  CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
  Wall time: 0.00
  Out[1]: 340282366920938463463374607431768211456L

  In [2]: n = 1000000

  In [3]: %time sum(range(n))
  CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
  Wall time: 1.37
  Out[3]: 499999500000L

  In [4]: %time print 'hello world'
  hello world
  CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
  Wall time: 0.00

.. note::
    The time needed by Python to compile the given expression will be
    reported if it is more than 0.1s.

    In the example below, the actual exponentiation is done by Python
    at compilation time, so while the expression can take a noticeable
    amount of time to compute, that time is purely due to the
    compilation::

        In [5]: %time 3**9999;
        CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
        Wall time: 0.00 s

        In [6]: %time 3**999999;
        CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
        Wall time: 0.00 s
        Compiler : 0.78 s
z,Can't use statement directly after '%%time'!r  NrS   r   evalz<timed eval>r  z<timed exec>win32zCPU times: user z, sys: z	, total: zCPU times: total: zWall time: zCompiler : zParser   : )r   r   r   r,   r  r  r  rE   r   
isinstancer  r   
Expressionr   r	   r   r   r-   r  r  r  r\   platformr   r`   )r<   r   r   r   exprtp_minr  expr_asttpr  expr_valr  sourcer   r  r  wtimewall_ststoutr   code_2wall_end	wall_timecpu_usercpu_syscpu_tots                              r?   r   ExecutionMagics.time  s*   H DKLL::,,T2D::,,T2D W::%%//5WRZ ::++H5 x}}q Za0@#((%K%KD#F~~hmmA&6&<&<=HD#F8==!A%*X]]25F*Q*Q"--+#=="-!(B/>>(..9Wzz!!(D9WRZ zz!!		'<B4x0 (CB	T*'!ZZ//&IFvt6C (C7w&	q6BqE>a&2a5.W$<<7""<#9":',wBWAXXabnovbwaxy &|G'<&=>?L3456;KR 0123;KR 0123
I

((*

((*s   0M( 9N	 (N	N'c                 N   U R                  USSS9u  p#U(       d4  [        S U R                  R                  R	                  5        5       5      $ [        U5      S:X  a  [        S5      eUS   SR                  USS	 5      pT U R                  R                  US
U;   5      n[        U5      nU R                  R                  XH5        SU;  a$  [        SU-  5        [        S5        [        USS9  g	g	! [        [        4 a"  n[        UR                  S   5         S	nAg	S	nAff = f)a  Define a macro for future re-execution. It accepts ranges of history,
filenames or string objects.

Usage:\
  %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...

Options:

  -r: use 'raw' input.  By default, the 'processed' history is used,
  so that magics are loaded in their transformed version to valid
  Python.  If this option is given, the raw input as typed at the
  command line is used instead.
  
  -q: quiet macro definition.  By default, a tag line is printed 
  to indicate the macro has been created, and then the contents of 
  the macro are printed.  If this option is given, then no printout
  is produced once the macro is created.

This will define a global variable called `name` which is a string
made of joining the slices and lines you specify (n1,n2,... numbers
above) from your input history into a single string. This variable
acts like an automatic function which re-executes those lines as if
you had typed them. You just type 'name' at the prompt and the code
executes.

The syntax for indicating input ranges is described in %history.

Note: as a 'hidden' feature, you can also use traditional python slice
notation, where N:M means numbers N through M-1.

For example, if your history contains (print using %hist -n )::

  44: x=1
  45: y=3
  46: z=x+y
  47: print x
  48: a=5
  49: print 'x',x,'y',y

you can create a macro with lines 44 through 47 (included) and line 49
called my_macro with::

  In [55]: %macro my_macro 44-47 49

Now, typing `my_macro` (without quotes) will re-execute all this code
in one pass.

You don't need to give the line-numbers in order, and any given line
number can appear multiple times. You can assemble macros with any
lines from your input history in any order.

The macro is a simple object which holds its value in an attribute,
but IPython's display system checks for macros and executes them as
code instead of printing them when you type their name.

You can view a macro's contents by explicitly printing it with::

  print macro_name

rqr'  r  c              3   X   #    U  H   u  p[        U[        5      (       d  M  Uv   M"     g 7fr3   )r  r   )r#  kvs      r?   r%  (ExecutionMagics.macro.<locals>.<genexpr>  s!     Z'AZPQSXEY!!'As   *	*rS   z:%macro insufficient args; usage '%macro name n1-n2 n3-4...r   r   Nr   r   z?Macro `%s` created. To execute, type its name (without quotes).z=== Macro contents: ===r   )r   sortedr   r   r  rE   r   r   find_user_coder   rN  r   r   r   define_macro)	r<   r   r   r   r~   codefromlinesr,  macros	            r?   r  ExecutionMagics.macro[  s   ~ &&{4V&D	Ztzz'9'9'?'?'AZZZt9>LN Na#((48"4h	JJ--htDE e

,SVZZ[+,%S!  I& 	!&&)	s   C2 2D$DD$r   ?a  The name of the variable in which to store output.
        This is a utils.io.CapturedIO object with stdout/err attributes
        for the text of the captured output.

        CapturedOutput also has a show() method for displaying the output,
        and __call__ as well, so you can use that to quickly display the
        output.

        If unspecified, captured output is discarded.
        )typedefaultr   r   z--no-stderr
store_truezDon't capture stderr.)actionr   z--no-stdoutzDon't capture stdout.z--no-displayz%Don't capture IPython's rich display.c                 \   [         R                  " U R                  U5      nUR                  (       + nUR                  (       + nUR
                  (       + n[        XEU5       nU R                  R                  U5        SSS5        [        R                  " U5      (       aG  UR                  U R                  R                  ;   a"  U R                  R                  UR                  	 ggUR                  (       a$  WU R                  R                  UR                  '   gg! , (       d  f       N= f)zKrun the cell, capturing stdout, stderr, and IPython's rich display() calls.N)r   r   capture	no_stdout	no_stderr
no_displayr&   r   run_cellr   semicolon_at_end_of_expressionr   r   )r<   r   r   r   r  errdispios           r?   r  ExecutionMagics.capture  s    2 ..t||TB.. .. ??"Cd+rJJ% ,55d;;{{djj000JJ&&t{{3 1[[.0DJJt{{+  ,+s   !D
D+r~   r  )r  r  r   z--removezremove the current transformerz--listzlist existing transformers namez
--list-allz1list existing transformers name and code templatec                 h   [         R                  " U R                  U5      nUR                  (       a-  U R                  R                  5        H  n[        U5        M     gUR                  (       am  U R                  R                  5        HD  u  pE[        US5        [        [        [        R                  " UR                  5      S5      5        MF     [        5         gU R                  R                  UR                  S5      nX`R                  R                   ;   a%  U R                  R                   R#                  U5        Ub  UR"                  (       a  g[%        [        R&                  " U5      5      nXpR                  UR                  '   U R                  R                   R)                  U5        g)a  
Simple magic to quickly define a code transformer for all IPython's future imput.

``__code__`` and ``__ret__`` are special variable that represent the code to run
and the value of the last expression of ``__code__`` respectively.

Examples
--------

.. ipython::

    In [1]: %%code_wrap before_after
       ...: print('before')
       ...: __code__
       ...: print('after')
       ...: __ret__


    In [2]: 1
    before
    after
    Out[2]: 1

    In [3]: %code_wrap --list
    before_after

    In [4]: %code_wrap --list-all
    before_after :
        print('before')
        __code__
        print('after')
        __ret__

    In [5]: %code_wrap --remove before_after

Nr  z    )r   r   	code_wrapr'  r   keysr   r   r  r   r  r   templater`  r~   r   ast_transformersremover.   r   r   )r<   r   r   r   r~   _t	to_remove_trss           r?   r  ExecutionMagics.code_wrap  s%   h ..t~~tD99**//1d 2== ..446dC fS[[5v>? 7 G&&**499d;	

333JJ''..y9<4;;%ciio6(,499%

##**40rI   )r   )rT   N)rT   )rT   NNr3   )NNNN)'rk   rl   rm   rn   ro   r   r   rI  r   __annotations__r@   r%   r"   r   r   r   r   r   r   argumentr!   r   r   r   r  r*   r9  r  staticmethodr_  r   r$   r   r  r   r  r  rq   __classcell__)r   s   @r?   r   r      s    F$&M4S>&#
 wJ   wJrJX  G  GD $$&ndK
 k '>    ''>R(
 ' '>  -e  eP RV_DB $: $:L z!    z!x T     
Tl P"  P"d $$&hS"C	 mL( mL( n\8 1  '.1 $$&f3	M<.N ,M @
 ;1  N ' ;1rI   r   c                 t    U R                  S5      nUS:X  a  U[        U 5      4$ U SU [        XS-   S 5      4$ )zDReturns (file, line) for file:line and (current_file, line) for liner  r  NrS   )findr   )re   current_filecolons      r?   r\  r\  !  sC    IIcNE{SY&&FU|SAgh000rI   c           	      |   U S:  ad  / SQn/ nU nU HE  u  pV[        XF-  5      nUS:  a%  XF-  nUR                  " [        U5      < U< 35        US:  d  ME    O   SR                  U5      $ / SQn[	        [
        R                  S5      (       aM  [
        R                  R                  (       a.   SR                  [
        R                  R                  5        / S	Qn/ S
Qn	U S:  aB  [        [        [        R                  " [        R                  " U 5      5      S-  5      * S5      n
OSn
SXX   -  X   4-  $ !    N`= f)z-Formats the timespan in a human readable formg      N@))r1  iQ )hi  )r  <   )rU   rS   r   rS   r   )rU   msusr  rQ      µ)rU   r	  u   µsr  )rS   g     @@g    .Ag    eAg        ru  z%.*g %s)r   r   rI  r   r[   r\   r]   rQ   r^   r  rC   floorlog10)timespanr=   partsr   leftoversuffixlengthr   unitsscalingorders              r?   r`   r`   )  s    4 E#NF)*Eqy#,s5z6:;!| $ xx~ %Eszz:&&3::+>+>	NN3::..//E !G#~SDJJx$89Q>??C	gn#<elKKK	s   .-D7 7D;)ru  )Yro   r  rx  builtinsr^  copycProfiler   r   r   rC   rC  r   rL  r!  r\   r   r   typingr   r   r   r   r   r   r	   r
   r   r   r   r   r  r   loggingr   pathlibr   r   r   textwrapr   r   warningsr   IPython.corer   r   r   IPython.core.displayhookr   IPython.core.errorr   IPython.core.macror   IPython.core.magicr   r   r   r   r    r!   r"   r#   r$   IPython.testing.skipdoctestr%   IPython.utils.capturer&   IPython.utils.contextsr'   IPython.utils.ipstructr(   IPython.utils.module_pathsr)   IPython.utils.pathr*   r+   IPython.utils.timingr,   r-   IPython.core.magics.ast_modr.   objectr0   rt   r   r   r\  r`   rr   rI   r?   <module>r,     s    :  
    	   	  	  
          #  8 8 0 ) $
 
 
 5 0 0 ) / 9 . >4.6 4.n3.. 2FLL 8 i1f i1 i1X+1%LrI   