
    Q/Ph&                     l   d Z ddlZddlZddlZddlmZ ddlmZmZm	Z	m
Z
mZmZ ddlZddlZddlmZ dedefdZed	ed
edefd            Zed	ededefd            Zed*dededefd            Zed+dededefd            Zed,dedededefd            Ze	 d-dededededef
d            Zed.dededefd             Zededefd!            Zeej         fdej!        d"edefd#            Z"ededefd$            Z#ededefd%            Z$d/d&ed'ee         defd(Z%ededefd)            Z&dS )0z3Formatters are mappings from object(s) to a string.    N)	timedelta)AnyCallableDictListOptionalUnion)escapefuncreturnc                 L     dt           dt           dt           dt           f fd}|S )zExtend the function to allow taking a list as the first argument, and apply the function on each of the elements.

    Args:
        func: the function to extend

    Returns:
        The extended function
    argargskwargsr   c                 j    t          | t                    rfd| D             S  | gR i S )Nc                 (    g | ]} |gR i S  r   ).0vr   r   r   s     a/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/ydata_profiling/report/formatters.py
<listcomp>z,list_args.<locals>.inner.<locals>.<listcomp>   s3    :::DD,T,,,V,,:::    )
isinstancelist)r   r   r   r   s    ``r   innerzlist_args.<locals>.inner   sW    c4   	;::::::c::::tC)$)))&)))r   )r   )r   r   s   ` r   	list_argsr      sD    *3 *s *c *c * * * * * * Lr   textcolorc                     d| d|  dS )zFormat a string in a certain color (`<span>`).

    Args:
      text: The text to format.
      color: Any valid CSS color.

    Returns:
        A `<span>` that contains the colored text.
    z<span style="color:"></span>r   )r   r   s     r   	fmt_colorr"       s     877$7777r   clsc                     d| d|  dS )zFormat a string in a certain class (`<span>`).

    Args:
      text: The text to format.
      cls: The name of the class.

    Returns:
        A `<span>` with a class added.
    z<span class="r    r!   r   )r   r#   s     r   	fmt_classr%   .   s     03//$////r   Bnumsuffixc                 d    dD ]&}t          |           dk     r| dd| | c S | dz  } '| dd| S )zChange a number of bytes in a human-readable format.

    Args:
      num: number to format
      suffix: (Default value = 'B')

    Returns:
      The value formatted in human readable format (e.g. KiB).
    ) KiMiGiTiPiEiZig      @z3.1f z.1fz Yi)abs)r'   r(   units      r   fmt_bytesizer5   <   sh     ?  s88f////v/////v"""&"""r   Tvalue
edge_casesc                     |rt          | d          dk    r| dk    rdS |rt          | d          dk    r| dk     rdS | dz  ddS )	zFormat a ratio as a percentage.

    Args:
        edge_cases: Check for edge cases?
        value: The ratio.

    Returns:
        The percentage with 1 point precision.
       r   z< 0.1%   z> 99.9%d   z2.1f%)round)r6   r7   s     r   fmt_percentr>   N   sh      eE1oo**uqyyx eE1oo**uqyyyCir   Fr9   num_secondsdetailed	max_unitsc                    ddddgddddd	gdd
dddgddddg dddddg ddddddgdddddgdddd d!gdd"d#d$d%gdg	}d7d't           d(t          d)t          fd*}d+t          t          t
          t          f         d)t          fd,}d-t          t                   d)t          fd.}d8d't           d/t          d0t          t                   d)t          fd1} ||           } | dk     r|s | ||           d          S g }t          j
        t          |                     } t          t          ||rd2nd3d                              }	|	D ]}
t          j
        t          |
d4                             }| |z  }| |z  } |
|	d5         k    rt          |          }n ||          }|d6vr,|                     |||
d/         |
d0                              t          |          dk    r|d2         S |s
|d |         } ||          S )9N&.>
nanosecondnanosecondsns)dividersingularpluralabbreviationsư>microsecondmicrosecondsusgMbP?millisecondmillisecondsmsr:   secondseconds)ssecsecs<   minuteminutes)mminminsi  hourhourshiQ daydaysdi:	 weekweekswi yearyearsyFcount
keep_widthr   c                     t          |           d}|s,t          j        dd|          }t          j        dd|          }|S )Nz.2fz0+$r*   z\.$)floatresub)ri   rj   r   s      r   round_numberz"fmt_timespan.<locals>.round_number   sF    ,,$$ 	,6%T**D6&"d++Dr   r6   c                 r    t          | t                    r|                                 S t          |           S N)r   r   total_secondsrl   r6   s    r   coerce_secondsz$fmt_timespan.<locals>.coerce_seconds   s2    eY'' 	)&&(((U||r   itemsc                     t          |           } t          |           dk    r)d                    | d d                   dz   | d         z   S | r| d         S dS )Nr:   z, z and r   r*   )r   lenjoin)ru   s    r   concatenatez!fmt_timespan.<locals>.concatenate   sZ    Uu::>>99U3B3Z((72U2Y>> 	8O2r   rH   rI   c                 l    |s|dz   }|  dt          j        t          |                     dk    r|n| S )NrT   r2   r:   )mathfloorrl   )ri   rH   rI   s      r   	pluralizezfmt_timespan.<locals>.pluralize   sE     	$^FQQdju&>&>!&C&C((QQQr   r   r9   rG   rw   )r   0)Frq   )r   boolstrr	   r   intrl   r   r   decimalDecimalr   reversedappendrx   )r?   r@   rA   
time_unitsro   rt   rz   r~   resultrelevant_unitsr4   rG   ri   s                r   fmt_timespanr   a   s)    $#"V		
 	
 %$"V		
 	
 %$"V		
 	
  111		
 	
  111		
 	
 !U		
 	
 $!U		
 	
 (!U		
 	
 -!U		
 	
c7(Jr C T c    eIsE$9: u    
49     R R R RXc] Rc R R R R
 !.--KRyk22H=== oc+&6&677hzx2F!!Q2H2H'IJJKK" 	R 	RDoc$y/&:&:;;G')E7"K~b)))E

 %U++H$$iitJ/?hPPQQQv;;!!9 ,

+;v&&&r   
   delta	precisionc                     t          | t          j                  rU|                                 }| j        dk    r|| j        dz  z  }| j        dk    r|| j        dz  z  }t          |||          S t          | |          S )Nr   rK   rC   )r   pd	Timedeltarr   rM   rE   r   fmt_numeric)r   r@   rA   r   r?   s        r   fmt_timespan_timedeltar      s     %&& -))++!!5-44Kq  5,t33KK9===5),,,r   c                     d| d                     |           }dD ]V}||v rP|dv rdnd}|                    |d          dz   }|                    d	d
          }|                    d
d
|           }W|S )zFormat any numeric value.

    Args:
        value: The numeric value to format.
        precision: The numeric precision

    Returns:
        The numeric value with the given precision.
    z{:.zg})ze+e-r   -r*   u    × 10<sup>z</sup>z<sup>0z<sup>)formatreplace)r6   r   fmttedr   signs        r   r   r      s     #I"""))%00F = =;;t))33D^^A}55@F^^Hg66F^^G^T^^<<FMr   c                 
    | dS )zFormat any numeric value.

    Args:
        value: The numeric value to format.

    Returns:
        The numeric value with the given precision.
    nr   rs   s    r   
fmt_numberr     s     <<r   	thresholdc                     t          j        d|          5  t          |           }ddd           n# 1 swxY w Y   |S )zFormat numpy arrays.

    Args:
        value: Array to format.
        threshold: Threshold at which to show ellipsis

    Returns:
        The string representation of the numpy array.
    r9   )r   	edgeitemsN)npprintoptionsr   )r6   r   return_values      r   	fmt_arrayr     s     
1		:	:	: " "5zz" " " " " " " " " " " " " " " s   377c                     t          |           t          t          fv rt          |           S t	          t          |                     S )zFormat any value.

    Args:
        value: The value to format.

    Returns:
        The numeric formatting if the value is float or int, the string formatting otherwise.
    )typerl   r   r   r   r
   rs   s    r   fmtr   !  s;     E{{ucl""5!!!6%==!!!r   c                 p    | dk    rdS | dk    rdS | dk    rdS | dk    rdS | d	k    rd
S t          d          )N   zStrictly increasingr:   
Increasingr   zNot monotonicrw   
DecreasingzStrictly decreasingz-Value should be integer ranging from -2 to 2.)
ValueErrorrs   s    r   fmt_monotonicr   1  sY    zz$$	!|	!	"|	"$$HIIIr   titleurlc                 $    |	d| d|  dS d|  dS )zCreat help badge

    Args:
        title: help text
        url: url to open in new tab (optional)

    Returns:
        HTML formatted help badge
    Nz	<a href="zt"><span class="badge text-bg-secondary float-end" data-bs-toggle="tooltip" data-bs-placement="right" data-bs-title="z">?</span></a>zr<span class="badge text-bg-secondary float-end" data-bs-toggle="tooltip" data-bs-placement="right" data-bs-title="z
">?</span>r   )r   r   s     r   helpr   A  sa      j3  j  j  UZ  j  j  j  	j V  EJ  V  V  V  	Vr   c                 .    t          j        dd|           S )Nz	\((\d+)\)z><span class="badge text-bg-secondary align-text-top">\1</span>)rm   rn   rs   s    r   	fmt_badger   Q  s    6I  r   )r&   )T)Fr9   )Fr9   r   )r   rq   )'__doc__r   r|   rm   datetimer   typingr   r   r   r   r   r	   numpyr   pandasr   
markupsafer
   r   r   r"   r%   rl   r5   r   r>   r   r   r   r   r   nanndarrayr   r   r   r   r   r   r   r   <module>r      s   9 9   				       = = = = = = = = = = = = = = = =              H     & 
8C 
8 
8 
8 
8 
8 
8 
0C 
0c 
0c 
0 
0 
0 
0 # #e #S #3 # # # #"    u  $  #        $ y' y'c y'T y'c y'RU y' y' y' y'x MO- ---36-GJ-- - - -  u  c    * 	c 	c 	 	 	 	 24&  RZ C S      "s "s " " " " J J J J J JV V V(3- V3 V V V V  S S      r   