
    BThI                         d dl mZ d dlmZ ddlmZ ddlmZ 	 d dlmZ d dl	m
Z
  G d
 de      Zd Zd Zy	# e$ rZ eej                  d      ed	Z[ww xY w)    )Iterable)Path   )
TIME_UNITS)slugify)Box)DefaultStylez?Please install pygal and pygaljs or pytest-benchmark[histogram]Nc                   6     e Zd Zd Zd Z fdZd fd	Z xZS )	CustomBoxc                     ||d   |d   gfS )Nr       )selfserie_s      l/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/pytest_benchmark/histogram.py_box_pointszCustomBox._box_points   s    uQxq***    c                     d|d d d   dd|d d d   dd|d d d   dd	|d d d
   dd|d d d   dd|d d d   dd|d d d   dS )NzMin:    r   z.4fz
Q1-1.5IQR: r   z
Q1:    z	
Median:    z
Q3:    z
Q3+1.5IQR:    z
Max: r   r   )r   xs     r   _value_formatzCustomBox._value_format   s    AbqE!HS> "BQ%(3 (Ra58C.
1Ra58C.q!uQxn MBQ%(3 (bqE!HS>	#	
r   c                     t         |   }|r|j                  }n|}t        |t              r| j                  |      |d   fS  ||g| S )Nr   )super_formatvalues
isinstancer   r   )r   r   argssupval	__class__s        r   r   zCustomBox._format   sO    go((CCc8$%%c*CF22q=4= r   c                     t         |   ||d   |||d        |d   | j                  j                  |dd      _        y )Nr   )classesxlabelr   descx_label)class_)r   _tooltip_datasvgnodetext)r   r.   valuer   yr'   r(   r%   s          r   r,   zCustomBox._tooltip_data&   s@    dE!HaGDQ=B1XdF95:r   )NN)__name__
__module____qualname__r   r   r   r,   __classcell__)r%   s   @r   r   r      s    +
	!F Fr   r   c                      G  fddt               }t        t        fd D                    }t        t        fd D              dz         }	 dd l}d|j                  dd	      gi}t        dd
d D cg c]  }|d    
 c}d|dd|ddd||f|g dd|}	 D ]I  }dD 
cg c]
  }
||
   z   }}
|j                  |d          |	j                  |d    d|d    d|       K |	S # t        $ r i }Y w xY wc c}w c c}
w )Nc                   2    e Zd Z ed W  D              ZdZy)make_plot.<locals>.Stylec              3   P   K   | ]  }|d    rdnt         j                  d      yw)pathz#000000r   N)r	   colors).0rows     r   	<genexpr>z"make_plot.<locals>.Style.<genexpr>-   s'     bPSCKy\5H5H5KKbs   $&zSConsolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospaceN)r2   r3   r4   tupler;   font_family)
benchmarkss   r   Styler8   ,   s    bWabbkr   rB   c              3   .   K   | ]  }|d    z    yw)minNr   r<   r=   
adjustments     r   r>   zmake_plot.<locals>.<genexpr>0   s     D#c%j:-Ds   c              3   H   K   | ]  }t        |d    |d         z    yw)maxhd15iqrN)rD   rE   s     r   r>   zmake_plot.<locals>.<genexpr>1   s%     Ysc#e*c)n5
BYs   "r   r   jsz2.0.xzpygal-tooltips.jstukeyinameFTrialDuration   2   )zfile://style.csszfile://graph.csszinline:
                .tooltip .value {
                    font-size: 1em !important;
                }
                .axis text {
                    font-size: 9px !important;
                }
            )box_modex_label_rotationx_labelsshow_legendtitlex_titley_titlestyle	min_scale	max_scaletruncate_labelrangezerocss)rD   ld15iqrq1medianq3rI   rH   r:   fullnamez - roundsz roundsr   )
r	   intrD   rH   pygaljsuriImportErrorr   appendadd)rA   rU   rF   rB   minimummaximumrf   optsr=   plotfieldr   s   ` `         r   	make_plotrp   +   sP   l l #DDDEG#YjYY\]]^GC w{{7,?@AB .89sS[M"9 
4 5D:  G6pqUUj(qqS[!C
O$CHg>FG KM   :6 rs   C+ 7C<$D+C98C9c                    |r!|  dt        |       d}dt        |    d| }n|  d}dt        |    }t        |      }|j                  j	                  dd       t        |||      }|j                  t        |             |S )N-z.svgz	Speed in z of T)exist_okparents)rA   rU   rF   )r   r   r   parentmkdirrp   render_to_filestr)	output_prefixrL   rA   unitrF   r:   rU   output_filern   s	            r   make_histogramr|   ^   s    '$-5Jt,-T$8%Jt,-.t*KdD9D
 	K()r   )collections.abcr   pathlibr   utilsr   r   pygal.graph.boxr   pygal.styler	   rh   excr"   r   rp   r|   r   r   r   <module>r      s`    $   l#(
F F:0fi  l
chh a
bhkkls   8 AAA