
     Ti%)                        S r SSKJr  SSKJr  SSKJrJrJr  Sr	Sr
SrSrS	rS
rSrSrSrSrSrSrSrSrSrSrSrSr/ SQrS rS rSrSSS.S jrg)zModule to generate ascii charts.

This module provides a single function `plot` that can be used to generate an
ascii chart from a series of numbers. The chart can be configured via several
options to tune the output.
    )annotations)Mapping)ceilfloorisnanz[30mz[31mz[32mz[33mz[34mz[35mz[36mz[37mz[39mz[90mz[91mz[92mz[93mz[94mz[95mz[96mz[97mz[0m)plotblackredgreenyellowbluemagentacyan	lightgraydefaultdarkgraylightred
lightgreenlightyellow	lightbluelightmagenta	lightcyanwhiteresetc                "    [        U 5      (       + $ Nr   )ns    _/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx_ir/_thirdparty/asciichartpy.py_isnumr    R   s    Qx<    c                *    U(       d  U $ X-   [         -   $ r   )r   )charcolors     r   coloredr%   V   s    |e##r!   )
u   ┼u   ┤u   ╶u   ╴u   ─u   ╰u   ╭u   ╮u   ╯u   │N)	bin_edgescfgc                 ^-^.^/^0^1 [        U 5      S:X  a  g[        U S   [        5      (       d  [        S U  5       5      (       a  gU /n Ub   [        U[        5      (       d  [        S5      eU=(       d    0 nUR                  SS/5      nUR                  S[        [        [        U  VVs/ s H  oD  H  oUPM     M     snn5      5      5      m0UR                  S[        [        [        U  VVs/ s H  oD  H  oUPM     M     snn5      5      5      m.UR                  S	[        5      nT0T.:  a  [        S
5      eT.T0-
  nUR                  SS5      nUR                  SU5      n	US:  a  X-  OSm1[        T0T1-  5      m/[        T.T1-  5      n
U.U04S jm-U-U/U14S jnU
T/-
  nSnU  H  n[        U[        U5      5      nM     X-  nUR                  SS5      nUR                  SS5      n[        US-   5       Vs/ s H	  nS/U-  PM     nn[        T/U
S-   5       Hf  nUR!                  T.UT/-
  U-  U(       a  UOS-  -
  5      nUUUT/-
     [        U[        U5      -
  S5      '   US:X  a  US   OUS   UUT/-
     US-
  '   Mh     U S   S   n[        U5      (       a  US   UX" U5      -
     US-
  '   [#        U 5       GH  u  pNX4[        U5      -     n[        [        U5      S-
  5       GH  nUUS-      nUUS-      n[%        U5      (       a  [%        U5      (       a  M6  [%        U5      (       a2  [        U5      (       a"  ['        US   U5      UX" U5      -
     UU-   '   Mx  [        U5      (       a2  [%        U5      (       a"  ['        US   U5      UX" U5      -
     UU-   '   M  U" U5      nU" U5      nUU:X  a  ['        US   U5      UUU-
     UU-   '   M  UU:  a  ['        US   U5      O['        US   U5      UUU-
     UU-   '   UU:  a  ['        US   U5      O['        US   U5      UUU-
     UU-   '   [        UU5      S-   n[        UU5      n[        UU5       H  n['        US   U5      UUU-
     UU-   '   M      GM     GM     SR)                  U Vs/ s H"  nSR)                  U5      R+                  5       PM$     sn5      nUb  [        U5      S:X  a  U$ SnU[        W5      -   nUR!                  US   5      n [        U 5      n![        SUU!-
  5      n"/ n#UU!S-  -   n$Sn%UU!U%-   -  n&[        U5      n'[        U'U&5      n(U(S-
  n)[        U%U$U(U!-  -
  U)-  5      n*UU$:  aO  [-        UU$-  U'-  5      n+UR!                  UU+   5      n U#R/                  U 5        U[        U 5      U*-   -  nUU$:  a  MO  SU"-  SU*-  R)                  U#5      -   n,US-   U,-   $ s  snnf s  snnf s  snf s  snf )u0
  Generate an ascii chart for a series of numbers.

`series` should be a list of ints or floats. Missing data values in the
series can be specified as a NaN. In Python versions less than 3.5, use
float("nan") to specify an NaN. With 3.5 onwards, use math.nan to specify a
NaN.

    >>> series = [1,2,3,4,float("nan"),4,3,2,1]
    >>> print(plot(series))
        4.00  ┤  ╭╴╶╮
        3.00  ┤ ╭╯  ╰╮
        2.00  ┤╭╯    ╰╮
        1.00  ┼╯      ╰

`series` can also be a list of lists to support multiple data series.

    >>> series = [[10,20,30,40,30,20,10], [40,30,20,10,20,30,40]]
    >>> print(plot(series, cfg={'height': 3}))
       40.00  ┤╮ ╭╮ ╭
       30.00  ┤╰╮╯╰╭╯
       20.00  ┤╭╰╮╭╯╮
       10.00  ┼╯ ╰╯ ╰

`bin_edges` is an optional list of bin edges to display on the x-axis. If
provided, the x-axis will be labeled with the bin edges. If there are too
many bin edges to fit on the x-axis, some labels will be dropped and they
will be spaced out evenly to fit the width of the chart.
The labels will be formatted using the `x_format` option in `cfg`.

`cfg` is an optional dictionary of various parameters to tune the appearance
of the chart. `min` and `max` will clamp the y-axis and all values:

    >>> series = [1,2,3,4,float("nan"),4,3,2,1]
    >>> print(plot(series, cfg={'min': 0}))
        4.00  ┼  ╭╴╶╮
        3.00  ┤ ╭╯  ╰╮
        2.00  ┤╭╯    ╰╮
        1.00  ┼╯      ╰
        0.00  ┤

    >>> print(plot(series, cfg={'min': 2}))
        4.00  ┤  ╭╴╶╮
        3.00  ┤ ╭╯  ╰╮
        2.00  ┼─╯    ╰─

    >>> print(plot(series, cfg={'min': 2, 'max': 3}))
        3.00  ┤ ╭─╴╶─╮
        2.00  ┼─╯    ╰─

`height` specifies the number of rows the graph should occupy. It can be
used to scale down a graph with large data values:

    >>> series = [10,20,30,40,50,40,30,20,10]
    >>> print(plot(series, cfg={'height': 4}))
       50.00  ┤   ╭╮
       40.00  ┤  ╭╯╰╮
       30.00  ┤ ╭╯  ╰╮
       20.00  ┤╭╯    ╰╮
       10.00  ┼╯      ╰

`format` specifies a Python format string used to format the labels on the
y-axis. The default value is "{:8.2f} ". This can be used to remove the
decimal point:

    >>> series = [10,20,30,40,50,40,30,20,10]
    >>> print(plot(series, cfg={'height': 4, 'format':'{:8.0f}'}))
          50 ┤   ╭╮
          40 ┤  ╭╯╰╮
          30 ┤ ╭╯  ╰╮
          20 ┤╭╯    ╰╮
          10 ┼╯      ╰
r    c              3  8   #    U  H  n[        U5      v   M     g 7fr   r   ).0r   s     r   	<genexpr>plot.<locals>.<genexpr>   s     (AuQxxs   Nz cfg must be a dictionary or Nonecolorsminmaxsymbolsz*The min value cannot exceed the max value.offset   height   c                0   > [        [        U T5      T5      $ r   )r/   r0   )r   maximumminimums    r   clampplot.<locals>.clamp   s    3q'?G,,r!   c                D   > [        [        T" U 5      T-  5      T-
  5      $ r   )intround)yr9   min2ratios    r   scaledplot.<locals>.scaled   s!    5qE)*T122r!   formatz{:8.2f} x_formatz{:4.4f}                   	   
)len
isinstancelistallr   	TypeErrorgetr/   filterr    r0   _DEFAULT_SYMBOLS
ValueErrorr   r   rangerC   	enumerater   r%   joinrstripr<   append)2seriesr&   r'   r.   ijr1   intervalr2   r4   max2rA   rowswidthseries_iplaceholderx_placeholderresultr>   labeld0r$   xd1y0y1startendrowthe_plotcurrent_locationleading_spacex_labelx_label_sizex_leading_spacex_labelsworkable_widthmin_spacingnum_labels_can_fitlabels_countnum_labels_to_display
num_spacesspacing	bin_indexx_labels_textr9   r7   r?   r8   r@   s2                                                @@@@@r   r   r   `   s   R 6{afQi&&((((XF
z#w77:;;
)CWWXv&FggeSF0NFqAqAF0N!OPQGggeSF0NFqAqAF0N!OPQGggi!12GEFF HWWXq!FWWXx(F!)AF1E5!D% D-3 $;DEE3x=) 	OE''(J/KGGJ	2M%*4!8_5_seem_F5 4"""7q4x8.CttYZ.[#\]8=q4xVc%j0!4556!Vwqzq4x!$ # 
1Bbzz07
tfRj !&1*- (3v;' s8}q()A!a%B!a%BRyyU2YYRyyVBZZ8?
E8RtfRj()!f*5bzzeBii8?
E8RtfRj()!f*5BBRx07
E0Jtby!!f*- /12g
E*771:u;U 4"9a&j) /12g
E*771:u;U 4"9a&j) BK!OEb"+C5#&/6wqz5/Itax V, '= *	 )J yy6B6C"''#,--/6BCHC	Na/ SZ'M""9Q<0G w<L!]\9:OH \Q..N K<+#=>y>L.@A&*J	/,>	>:MG
 ^
+)N:lJK	&&y';< CL722 ^
+ /)S7],@,@,JJMd?]**{ 1O0N> 6d Cs   *W.W6W )W%) __doc__
__future__r   collections.abcr   mathr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __all__r    r%   rU   r    r!   r   <module>r      s   . # # # #	
	

		6$ Z  # V+r!   