Format: application/x-python-code
1 o
2
3 ��h�� � @ s2 d Z ddlZddlZddlZddlZddlZddlZddl Z ddl
4 Z
5 ddlZddlZddl
6 Z
7 ddlZddlZddlZddlZddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZ ddlm Z ddl!m"Z" ddl#m$Z$ ddl%m&Z& dd l'm(Z(m)Z) dd
8 l*m+Z+ ddl,m-Z-m.Z.m/Z/ ddl0m1Z1 dd
9 l2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZG ddlHmIZI ddlJmKZKmLZL ddlMmNZNmOZO ddlPmQZQ G dd� deR�ZSG dd� dej�ZTG dd� dejU�ZUe;G dd� de7��ZVd d!� ZWd%d#d$�ZXdS )&z4Implementation of execution-related magic functions.� N)�Dict�Any)
10 �Assign�Call�Expr�Load�Module�Name�NodeTransformer�Store�parse�unparse)�StringIO)�error)�Path)�Restart)�dedent�indent)�warn)�magic_arguments�oinspect�page)�DisplayHook)�
11 UsageError)�Macro) �Magics�
12 cell_magic�line_cell_magic�
13 line_magic�magics_class�needs_local_scope�
14 no_var_expand�on_off�output_can_be_silenced)�skip_doctest)�capture_output)�
15 preserve_keys)�Struct)�find_mod)�get_py_filename� shellglob)�clock�clock2)�ReplaceCodeTransformerc @ s@ e Zd ZdZdd� Zedd� �Zedd� �Zdd � Zd
16 d� Z dS )
17 �TimeitResulta�
18 Object returned by the timeit magic with info about the run.
19
20 Contains the following attributes :
21
22 loops: (int) number of loops done per measurement
23 repeat: (int) number of times the measurement has been repeated
24 best: (float) best execution time / number
25 all_runs: (list of float) execution time of each run (in s)
26 compile_time: (float) time of statement compilation (s)
27
28 c sB |� _ |� _|� _|� _|� _|� _|� _� fdd�|D �� _d S )Nc s g | ]}|� j �qS � )�loops)�.0�dt��selfr/ �Sc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/magics/execution.py�
29 <listcomp>] s z)TimeitResult.__init__.<locals>.<listcomp>)r0 �repeat�best�worst�all_runs�compile_time�
30 _precision�timings)r4 r0 r7 r8 r9 r: r; � precisionr/ r3 r5 �__init__U s zTimeitResult.__init__c C s t �| j�t| j� S �N)�math�fsumr= �lenr3 r/ r/ r5 �average_ s zTimeitResult.averagec s. | j � t�� fdd�| jD ��t| j� d S )Nc s g | ]}|� d �qS )� r/ )r1 �x��meanr/ r5 r6 f s z&TimeitResult.stdev.<locals>.<listcomp>g �?)rD rA rB r= rC r3 r/ rG r5 �stdevc s (zTimeitResult.stdevc
31 C s� d}t tjd�rtjjrzd�tjj� d}W n Y dj|| j| j| jdkr*dnd| jdkr2dndt| j | j
32 �t| j| j
33 �d�S ) Nz+-�encoding� ±zl{mean} {pm} {std} per loop (mean {pm} std. dev. of {runs} run{run_plural}, {loops:,} loop{loop_plural} each)� � �s)�pm�runsr0 Zloop_pluralZ
34 run_pluralrH Zstd)�hasattr�sys�stdoutrJ �encode�formatr7 r0 �_format_timerD r<