
    e?                         d Z 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ej                  Z G d	 d
          Z G d dej                  Zdd
gZdS )a  
HoloViews can be used to build highly-nested data-structures
containing large amounts of raw data. As a result, it is difficult to
generate a readable representation that is both informative yet
concise.

As a result, HoloViews does not attempt to build representations that
can be evaluated with eval; such representations would typically be
far too large to be practical. Instead, all HoloViews objects can be
represented as tree structures, showing how to access and index into
your data.
    N)
ParamPager)
bothmethod   )group_sanitizerlabel_sanitizerc                   D    e Zd ZdZddZej        j        d             ZdS )ParamFiltera  
    Given a parameterized object, return a proxy parameterized object
    holding only the parameters that match some filter criterion.

    A filter is supplied with the parameter name and the parameter
    object and must return a boolean. A regular expression filter has
    been supplied and may be used to search for parameters mentioning
    'bounds' as follows:

    filtered = ParamFilter(obj, ParamFilter.regexp_filter('bounds'))

    This may be used to filter documentation generated by param.
    Nc                    |S t          |t                    r|j        n|j        j        }t          |t          j        ffd|j                            d                                          D                       }t          |t                    r|S |j                                                                        } |            fd|D             } j        j	        di | S )Nc                 4    i | ]\  }} ||          ||S  r   ).0kv	filter_fns      5lib/python3.11/site-packages/holoviews/core/pprint.py
<dictcomp>z(ParamFilter.__call__.<locals>.<dictcomp>-   s=     * * *sq#)Aa..*q * * *    existingc                 x    i | ]6\  }}|j         v j                             d           |         j        3||7S )r   )paramobjectsconstant)r   r   r   	obj_proxys      r   r   z(ParamFilter.__call__.<locals>.<dictcomp>5   sX     U U U!00$-O$;$;J$G$G$J$S 1 !000r   r   )

isinstancetype__name__	__class__r   Parameterizedr   itemsvaluesupdate)selfobjr   nameclass_proxyinstance_paramsfilteredr   s     `    @r   __call__zParamFilter.__call__'   s   J)#d33Os||9O4%"5!7* * * *ci&7&7
&C&C&I&I&K&K * * *+ + c$ 		!i..006688O#IU U U U U U UH #IO"..X...r   c                     fd}|S )z{
        Builds a parameter filter using the supplied pattern (may be a
        general Python regular expression)
        c                     t          j        |           }|dS |j        t          j        |j                  }|dS dS )NTF)researchdoc)r$   p
name_match	doc_matchpatterns       r   inner_filterz/ParamFilter.regexp_filter.<locals>.inner_filterA   sJ    7400J%tu Igae44	(45r   r   )self_or_clsr1   r2   s    ` r   regexp_filterzParamFilter.regexp_filter;   s$    	 	 	 	 	 r   N)	r   
__module____qualname____doc__r(   r   parameterizedr   r4   r   r   r   r	   r	      sT            ( #  $#  r   r	   c                      e Zd ZdZddgZ ej        d          Z e            Z	dZ
g Ze	 	 dd	            Zedd            Zed             Ze	 	 dd            Zed             Zedd            Zedd            Zedd            ZdS )InfoPrinterzc
    Class for printing other information related to an object that is
    of use to the user.
    z[1;35m%s[0mz[1;32m%s[0m
\x1b[^m]*mNFT(   c                     | j         dS |Ot          |t                              |                    }t          t	          |j                            dk    rdS | j                             |          }| j                             |          }|s5|s| j        	                    d|          n|}| 
                    ||          S |                      |          }	|du r| j        	                    d|	          }	| 
                    ||	          S )zN
        Get parameter information from the supplied class or object.
        N r   F)ppagerr	   r4   lenlistr   get_param_infoparam_docstringsansi_escapesub	highlight)
clsr#   ansishow_valuesr1   max_col_len
param_info
param_listretvalinfos
             r   get_parameter_infozInfoPrinter.get_parameter_infoX   s     :bbc;#<#<W#E#EFFC4	??##q((tZ..s33
Z00<<
 	0@DTS_((Z888*F==&111::c??Du}}**2t44==$///r   =r   c                 v    |r| j         |         nd}||| dz  S |t          |          z  }|| d| d| z  S )zs
        Turn the supplied heading text into a suitable heading with
        optional underline and color.
        z%sN
)headingsrA   )rH   heading_textcharlevelrI   heading_color
heading_uls          r   headingzInfoPrinter.headingn   sf     04=U++< l#6#6#666c,///J j#P#PL#P#PJ#P#PPPr   c                 N    ||S t          j        |d|t           j                  S )Nz[43;1;30m\g<0>[0m)flags)r+   rF   
IGNORECASE)rH   r1   strings      r   rG   zInfoPrinter.highlight|   s0    ?6Mvg;BM3 3 3 	3r   
matplotlibc                    |g }|| _         t          j        d          }t          |t                    }|r|j        n|j        j        }	| j        j        	                    |i           }
|
	                    |r|nt	          |          d          }t          |d          r3t          t          |j                                                            }|du s||Ut          |t                              |                    }t#          t%          |j                            dk    rd|	d|S t'          j                                        |          }|du r|                    d|          }|                     ||          S |r|	n|	 d	|j         d
|j         }|}||                     ||	||          g}|s|d|                     ||          gz  }||d|                     |||          gz  }d                    |          S )z~
        Show information about an object in the given category. ANSI
        color codes may be enabled or disabled.
        Nr<   plot_classesFr   No - parameters found matching specified pattern r?   z:  )backendrI   )rI   )r1   rS   )elementsr+   compiler   r   r   r   storeregistrygethasattrnextiterra   r    r	   r4   rA   rB   r   ipythonr   rF   rG   grouplabelobject_infotarget_infooptions_infojoin)rH   r#   rI   re   visualizationr1   rf   rE   isclassr$   backend_registry
plot_classrO   rZ   prefixliness                   r   rO   zInfoPrinter.info   s    Hj//S$''&Cs||S]-C9-11'2>>%))*G##d3iiNN
:~.. 	GtJ$;$B$B$D$DEEFFJ E!!Z%7"!#{'@'@'I'IJJtCI''1,,b$bbW^bbc=++--c22Du}}"r400==$///!I$$$'I'I#)'I'Ici'I'IdG$OOP 	;b#//#D/99::E!b#**:tW*MMNNEyyr   c                     |j         j        }t          |j                  }|j        rdt          |j                  z   nd}| d| | }t          |d          rd |fn|d fS )N.r?   r    )r   r   r   ro   rp   r   rk   )rH   r#   objtypero   rp   targets         r   
get_targetzInfoPrinter.get_target   st    &	**58YFsy1111B,,e,U,,!(h!7!7Kf~~fd^Kr   c                    t          |t                    rdS |                    | j                  }t	          | \  }}d |D             }d |D             }d }t          |          dk    r dt          t          |                     }n8t          |          dk    r%dd                    t          |                    z  }d }	t          |          dk    r dt          t          |                     }	n8t          |          dk    r%d	d                    t          |                    z  }	| 
                    d
|d          }
d}|r
|	r| d|	 }n|r|n|	}d}|
 d| d| d| S )Nr?   c                     h | ]}||S r5   r   )r   els     r   	<setcomp>z*InfoPrinter.target_info.<locals>.<setcomp>   s    ???brr   c                     h | ]}||S r5   r   )r   cs     r   r   z*InfoPrinter.target_info.<locals>.<setcomp>   s    @@@q!----r   r   z	Element: zElements:
   %sz
   zContainer: zContainers:
   %szTarget Specifications-rI   rV   z5
Targets in this object available for customization:
z

z
To see the options info for one of these target specifications,
which are of the form {type}[.{group}[.{label}]], do holoviews.help({type}).rS   )r   r   traverser   ziprA   rl   rm   rt   sortedrZ   )rH   r#   rI   targetsrf   
containerselement_setcontainer_setelement_infocontainer_inforZ   target_headerrr   target_footers                 r   rr   zInfoPrinter.target_info   s   c4  +,,s~.."G}*??H???@@J@@@{q  @tD,=,='>'>@@LL!!-f[>Q>Q1R1RRL}""F4]0C0C+D+DFFNN!##1W\\&BWBW5X5XXN++5Ds+KKQ 	KN 	K)??~??KK*6J,,NKj LL]LLkLL]LLLr   c                    t          |dd           }d}d}|r|n|}|                    ||          }	|r|| j        vrd n|	}	|	rdnd}
d                    |
                    ||                                |		          g          S )
N_deep_indexableFz<http://holoviews.org/reference/elements/{backend}/{obj}.htmlz>http://holoviews.org/reference/containers/{backend}/{obj}.html)r#   re   z
Online example: {link}zV
Help for the data object: holoviews.help({obj}) or holoviews.help(<{lower}_instance>)rS   )r#   lowerlink)getattrformatrf   rt   r   )rH   r#   r$   re   rI   elementelement_urlcontainer_urlurlr   msgs              r   rq   zInfoPrinter.object_info   s    c#4e<<<SW$7kk-zzdGz44GD$<$<tt4-1 :)) 8: yy#**TZZ\\*MMNOOOr   c           	         |j         r2|j        }d| d}dd                    |j                    }| d| }nd}|                     |||          }|                     d|d	
          d|d|                     d|d	
          dg}	||	d|gz  }	n$||	d|j        d|dgz  }	n|	d|j        dgz  }	d                    |	          S )Nz

(Consult z''s documentation for more information.)	z, rS   z	<No style options available>)rI   r1   zStyle Optionsr   r   r?   zPlot Optionsz;The plot options are the parameters of the plotting class:
rb   rc   r|   z parameters found.)
style_optsre   rt   rP   rZ   r   )
rH   rx   rI   r1   backend_name
style_infostyle_keywords	style_msgrL   rz   s
             r   rs   zInfoPrinter.options_info   s*     	9%-L\|\\\JD$))J,A"B"BDDN)99Z99II8I++JT7+SS
++oDs+CCRR++n4c+BBBH !T " "EE k:.kk_fkkkllEED:.DDDEEEyyr   )FTNr=   )rQ   r   F)Fr_   TNN)F)FN)r   r6   r7   r8   rT   r+   rg   rE   r   r@   rh   rf   classmethodrP   rZ   rG   rO   r   rr   rq   rs   r   r   r   r;   r;   M   sb         &'<=H"*]++KZ\\FEH>B570 0 0 [0* 
Q 
Q 
Q [
Q 3 3 [3 GK$(&  &  &  [& P L L [L M M M [MB P P P [P       [     r   r;   c                   p   e Zd ZdZ ej        dd          Z ej        dd          ZdZdZ	e
d             Ze
d	             Ze
dd            Ze
d             Ze
d             Ze
dd            Ze
d             Ze
d             Ze
d             Ze
dd            Ze
d             Ze
d             ZdS )PrettyPrinterzY
    The PrettyPrinter used to print all HoloView objects via the
    pprint method.
    Fzo
        Whether to show default options as part of the repr.
        If show_options=False this has no effect.)defaultr-   z5
        Whether to show options as part of the repr.z   z:{type}c                 R    |                      |                     |                    S r5   )	serializerecurse
cls_or_slfnodes     r   pprintzPrettyPrinter.pprint  s$    ##J$6$6t$<$<===r   c                     g }|D ]%\  }}|                     || j        z  |z              &d                    |          S )NrS   )appendtabrt   )r   rz   accumulatorrW   lines        r   r   zPrettyPrinter.serialize  sO      	? 	?KE4z~ 5=>>>>yy%%%r   r   c                      fd|D             S )Nc                 $    g | ]\  }}|z   |fS r   r   )r   lvlr   shifts      r   
<listcomp>z'PrettyPrinter.shift.<locals>.<listcomp>  s&    ;;;ksDUD!;;;r   r   )r   rz   r   s     `r   r   zPrettyPrinter.shift  s    ;;;;U;;;;r   c                     t          |          dk    rt          d |D                       nt          |d                   S )Nr   c              3   4   K   | ]}t          |          V  d S r5   )rA   )r   r.   s     r   	<genexpr>z(PrettyPrinter.padding.<locals>.<genexpr>"  s(      ))a3q66))))))r   r   )rA   max)r   r   s     r   paddingzPrettyPrinter.padding   s<    -0ZZ!^^s))5))))))U1XNr   c                 ~    |dS | j                             t          t          |          j                            S )z.Return the type.group.label dotted informationNr?   )r   )type_formatterr   strr   r   r   s     r   component_typezPrettyPrinter.component_type$  s8     <(//Sd9L5M5M/NNNr   NTc           
      @   |g }|g }|                      |||||          \  }}t          d          rd                                 D             ng }fd|D             }|D ]6}||                                         |          ||||dz   |          z  }7|S )za
        Recursive function that builds up an ASCII tree given an
        AttrTree node.
        Nchildrenc                 8    g | ]}d                      |          S )r|   )rt   )r   r   s     r   r   z)PrettyPrinter.recurse.<locals>.<listcomp>5  s"    666QSXXa[[666r   c                 :    g | ]}                     |          S r   )rj   )r   childr   s     r   r   z)PrettyPrinter.recurse.<locals>.<listcomp>6  s#    ;;;DHHUOO;;;r   r   )	attrpathssiblingsrW   
value_dims)	node_infork   keysr   rj   )r   r   attrpathr   r   rW   r   rz   s    `      r   r   zPrettyPrinter.recurse*  s     HI!++D(IxQVXbccu;B4;T;T\66$))++6666Z\	;;;;;;;! 	Z 	ZHZ''(:(:HPY*2%'j ( Z Z ZEEr   c                    d}t          |d          r0|||                     |          fg}	}|                     |          }nt          |d          r|                     ||||          \  }}	nt	          |dd          r|                     ||||          \  }}	nUt          |d          r||t          |          fg}	}n0|                     ||||          \  }}	|                     |          }|F|                     |          }
|	d         \  }d|	                    |
          z   d	z   |z   }|f|	d<   n|| j
        r-|r+|j        r$|	fd
|                     |          D             z  }	||	fS )z<
        Given a node, return relevant information.
        Nr   mainr   Funit_formatr   r|   rd   c                     g | ]}|fS r   r   )r   lfst_lvls     r   r   z+PrettyPrinter.node_info.<locals>.<listcomp>Y  s    LLLqwlLLLr   )rk   r   option_infoadjointlayout_infor   ndmapping_inforeprr   r   ljustshow_optionskwargsformat_options)r   r   r   r   r   rW   r   optsr   rz   r   fst_liner   r   s                @r   r   zPrettyPrinter.node_info<  s   
 4$$ 	0!UJ,E,Ed,K,K$L#M%S))$//DDT6"" 	0%88xPZ[[LS%%T,e44 	0%44T8UJWWLS%%T=)) 	0 E4::#6"7%SS%2245*UULS%))$//D  ((33G"'(Whx~~g...3h>DE!HHG" 	Mt 	M 	MLLLLJ,E,Ed,K,KLLLLEU|r   c                 j   |                      |          }t          |j                  dk    r3|| j        dd                    d |j        D                        dz   z  }|rKt          |j                  dk    r3|| j        dd                    d |j        D                        dz   z  }|||fgfS )	z
        Return the information summary for an Element. This consists
        of the dotted name followed by an value dimension names.
        r   [,c              3   $   K   | ]}|j         V  d S r5   r$   r   ds     r   r   z-PrettyPrinter.element_info.<locals>.<genexpr>d  $      1M1MQ!&1M1M1M1M1M1Mr   ](c              3   $   K   | ]}|j         V  d S r5   r   r   s     r   r   z-PrettyPrinter.element_info.<locals>.<genexpr>f  r   r   ))r   rA   kdimsr   rt   vdims)r   r   r   rW   r   rO   s         r   r   zPrettyPrinter.element_info\  s     ((..tz??aJN%P1M1M$*1M1M1M)M)M%P%P%PPPD 	Q#dj//Q..JN%P1M1M$*1M1M1M)M)M%P%P%PPPDt}o%%r   c                    | j         sd S ddlm}m} i }|j        D ]A}|                    |j        ||| j                  }|r|                    |j	                   B |di d |
                                D             }|S )Nr   )OptionsStore)defaultsc                 &    i | ]\  }}|d k    ||S )re   r   )r   r   r   s      r   r   z-PrettyPrinter.option_info.<locals>.<dictcomp>t  s#    KKK#!AANN!ANNNr   r   )r   optionsr   r   _option_groupslookup_optionscurrent_backendshow_defaultsr!   r   r   )r   r   r   r   r   ggoptsr   s           r   r   zPrettyPrinter.option_infoi  s    & 	4++++++++' 	- 	-A(()>a2<2J ) L LE -u|,,,wLLKKKKKLLr   d   c                     t          |          }t          |          j        }dt          |          dz   z  }t	          j        ||          }d |                    |          D             S )Nrd   r   )widthsubsequent_indentc                     g | ]}d |z   S )z | r   )r   r   s     r   r   z0PrettyPrinter.format_options.<locals>.<listcomp>}  s    888Aa888r   )r   r   r   rA   textwrapTextWrapperwrap)r   r   
wrap_countopt_reprcls_nameindentwrappers          r   r   zPrettyPrinter.format_optionsw  sd    t99::&c(mmAo&&Z6RRR88h!7!78888r   c                     |                      |          }||fg}g }t          |j                                                  D ]}||                     ||          z  }||                     |d          z  }||fS )N)rW   r   )r   rB   datar    r   r   )	r   r   r   rW   r   
first_linerz   additional_lines	components	            r   r   z PrettyPrinter.adjointlayout_info  s    ..t44
$%di..0011 	K 	KI
 2 29E 2 J JJ!!"2A666e|r   c                    dd                     d |j        D                        d}|                     |          | j        z   |z   }|fg}|                     |          }| j        r-|r+|j        r$|fd|                     |          D             z  }t          |j	                  dk    r|fS t          |j	                                                  d         }	|	3|	j        r,t          |	d          s|                     |	g |          \  }
n|                     |	|	          }
||                     |
d
          z  }|fS )Nr   r   c              3   $   K   | ]}|j         V  d S r5   r   r   s     r   r   z/PrettyPrinter.ndmapping_info.<locals>.<genexpr>  s$      #?#?qAF#?#?#?#?#?#?r   r   c                     g | ]}|fS r   r   )r   r   rW   s     r   r   z0PrettyPrinter.ndmapping_info.<locals>.<listcomp>  s    JJJQuajJJJr   r   r   )rW   r   r   )rt   r   r   r   r   r   r   r   rA   r  rB   r    r   rk   r   r   r   )r   r   r   rW   r   key_dim_infor  rz   r   lastr  s      `       r   r   zPrettyPrinter.ndmapping_info  sx   B388#?#?DJ#?#?#???BBB..t44z~ET
$%%%d++" 	Kt 	K 	KJJJJ**C*CD*I*IJJJJEty>>Q%<DI$$&&''+ 4WT:=V=V&0&?&?b%Q[&\&\#E##)11$ePZ1[[!!"2A666e|r   )r   )NNNr   T)r   )r   r6   r7   r8   r   Booleanr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s        
 "EM% 65 6 6 6M !5= 58 9 9 9L CN> > Z> & & Z& < < < Z< O O ZO O O ZO
    Z"   Z> 
& 
& Z
&   Z 9 9 9 Z9   Z   Z  r   r   )r8   r+   r   r   param.ipythonr   param.parameterizedr   utilr   r   ParameterizedFunctionr	   r;   r   r   __all__r   r   r   <module>r     s    
			   $ $ $ $ $ $ * * * * * * 2 2 2 2 2 2 2 22 2 2 2 2%- 2 2 2jp  p  p  p  p  p  p  p f\ \ \ \ \E' \ \ \~ M
*r   