U
    ,d                     @   sd   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	 G dd deZ
edkr`e  dS )    N)dedent)TemporaryDirectory)TestCaserun_in_subprocessc                   @   s   e Zd ZdZdd ZdS )TestChromeTraceModulez0
    Test chrome tracing generated file(s).
    c           	      C   s   d}t |}t }tj|d}tj }||d< t||d t|T}t	
|}| |t |D ]2}| |t | t| ddddd	d
dh qdW 5 Q R X W 5 Q R X d S )NaY  
            from numba import njit
            import numpy as np

            x = np.arange(100).reshape(10, 10)

            @njit
            def go_fast(a):
                trace = 0.0
                for i in range(a.shape[0]):
                    trace += np.tanh(a[i, i])
                return a + trace

            go_fast(x)
        ztest_trace.jsonZNUMBA_CHROME_TRACE)envcatpidtidphnameargsts)r   r   ospathjoinenvironcopyr   openjsonloadZassertIsInstancelistdictassertEqualsetkeys)	selfcodesrcZtmpdirr   r   fileeventsZev r!   A/tmp/pip-unpacked-wheel-eu7e0c37/numba/tests/test_chrome_trace.pytest_trace_output   s     



z'TestChromeTraceModule.test_trace_outputN)__name__
__module____qualname____doc__r#   r!   r!   r!   r"   r   
   s   r   __main__)r   r   Zunittesttextwrapr   tempfiler   Znumba.tests.supportr   r   r   r$   mainr!   r!   r!   r"   <module>   s   (