Ë
    êÿæiqH  ã                   ó    — d Z ddlZddlZddlmZ ddlmZ ddlmZ  G d„ de	«      Z
 G d„ d	e
«      Zd
„ Z G d„ dej                  «      Zdd„Zy)ztThis module contains the _EstimatorPrettyPrinter class used in
BaseEstimator.__repr__ for pretty-printing estimatorsé    N)Ú
get_config)ÚBaseEstimator)Úis_scalar_nanc                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚKeyValTuplez@Dummy class for correctly rendering key-value tuples from dicts.c                 ó    •— t         ‰| �  «       S )N)ÚsuperÚ__repr__)ÚselfÚ	__class__s    €új/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/sklearn/utils/_pprint.pyr
   zKeyValTuple.__repr__P   s   ø€ ä‰wÑÓ!Ð!ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   Ú__classcell__©r   s   @r   r   r   M   s   ø„ ÙJ÷"ð "r   r   c                   ó   — e Zd ZdZy)ÚKeyValTupleParamzEDummy class for correctly rendering key-value tuples from parameters.N)r   r   r   r   © r   r   r   r   U   s   „ ÙOàr   r   c                 ó‚  ‡— | j                  d¬«      }t        | j                  d| j                  «      }t        j                  |«      j
                  Š‰j                  «       D ��ci c]  \  }}||j                  “Œ c}}Šˆfd„}|j                  «       D ��ci c]  \  }} |||«      sŒ||“Œ c}}S c c}}w c c}}w )zgReturn dict (param_name: value) of parameters that were given to
    estimator with non-default values.F©ÚdeepÚdeprecated_originalc                 ó   •— | ‰vry‰|    t         j                  k(  ryt        |t        «      r|j                  ‰|    j                  k7  ryt        |«      t        ‰|    «      k7  rt        ‰|    «      rt        |«      syy)NTF)ÚinspectÚ_emptyÚ
isinstancer   r   Úreprr   )ÚkÚvÚinit_paramss     €r   Úhas_changedz$_changed_params.<locals>.has_changedd   sq   ø€ Ø�KÑØØ�q‰>œWŸ^™^Ò+Øä�aœÔ'¨A¯K©K¸;Àq¹>×;SÑ;SÒ,SØä�‹7”d˜; q™>Ó*Ò*Ü˜+ a™.Ô)¬m¸AÔ.>àØr   )Ú
get_paramsÚgetattrÚ__init__r   Ú	signatureÚ
parametersÚitemsÚdefault)	Ú	estimatorÚparamsÚ	init_funcÚnameÚparamr$   r!   r"   r#   s	           @r   Ú_changed_paramsr1   [   s´   ø€ ð ×!Ñ! uÐ!Ó-€FÜ˜	×*Ñ*Ð,AÀ9×CUÑCUÓV€IÜ×#Ñ# IÓ.×9Ñ9€KØ:E×:KÑ:KÔ:MÔNÑ:M©;¨4°�4˜Ÿ™Ñ&Ð:MÒN€Kôð $Ÿ\™\œ^ÔA™^‘T�Q˜©{¸1¸aÕ/@ˆAˆq‰D˜^ÒAÐAùó# Oùó" Bs   Á'B5ÂB;Â,B;c                   óä   ‡ — e Zd ZdZ	 	 	 	 dddddœˆ fd„Zd„ Zd„ Zd	„ Zd
„ Zd„ Z	d„ Z
d„ Zej                  j                  j                  «       Zeeej"                  <   eeej"                  <   ˆ xZS )Ú_EstimatorPrettyPrintera
  Pretty Printer class for estimator objects.

    This extends the pprint.PrettyPrinter class, because:
    - we need estimators to be printed with their parameters, e.g.
      Estimator(param1=value1, ...) which is not supported by default.
    - the 'compact' parameter of PrettyPrinter is ignored for dicts, which
      may lead to very long representations that we want to avoid.

    Quick overview of pprint.PrettyPrinter (see also
    https://stackoverflow.com/questions/49565047/pprint-with-hex-numbers):

    - the entry point is the _format() method which calls format() (overridden
      here)
    - format() directly calls _safe_repr() for a first try at rendering the
      object
    - _safe_repr formats the whole object recursively, only calling itself,
      not caring about line length or anything
    - back to _format(), if the output string is too long, _format() then calls
      the appropriate _pprint_TYPE() method (e.g. _pprint_list()) depending on
      the type of the object. This where the line length and the compact
      parameters are taken into account.
    - those _pprint_TYPE() methods will internally use the format() method for
      rendering the nested objects of an object (e.g. the elements of a list)

    In the end, everything has to be implemented twice: in _safe_repr and in
    the custom _pprint_TYPE methods. Unfortunately PrettyPrinter is really not
    straightforward to extend (especially when we want a compact output), so
    the code is a bit convoluted.

    This class overrides:
    - format() to support the changed_only parameter
    - _safe_repr to support printing of estimators (for when they fit on a
      single line)
    - _format_dict_items so that dict are correctly 'compacted'
    - _format_items so that ellipsis is used on long lists and tuples

    When estimators cannot be printed on a single line, the builtin _format()
    will call _pprint_estimator() because it was registered to do so (see
    _dispatch[BaseEstimator.__repr__] = _pprint_estimator).

    both _format_dict_items() and _pprint_estimator() use the
    _format_params_or_dict_items() method that will format parameters and
    key-value pairs respecting the compact parameter. This method needs another
    subroutine _pprint_key_val_tuple() used when a parameter or a key-value
    pair is too long to fit on a single line. This subroutine is called in
    _format() and is registered as well in the _dispatch dict (just like
    _pprint_estimator). We had to create the two classes KeyValTuple and
    KeyValTupleParam for this.
    NFT)ÚcompactÚindent_at_nameÚn_max_elements_to_showc                ó”   •— t         ‰| �  |||||¬«       || _        | j                  rd| _        t	        «       d   | _        || _        y )N)r4   é   Úprint_changed_only)r	   r'   Ú_indent_at_nameÚ_indent_per_levelr   Ú_changed_onlyr6   )	r   ÚindentÚwidthÚdepthÚstreamr4   r5   r6   r   s	           €r   r'   z _EstimatorPrettyPrinter.__init__©   sP   ø€ ô 	‰Ñ˜ ¨¨v¸wÐÔGØ-ˆÔØ×ÒØ%&ˆDÔ"Ü'›\Ð*>Ñ?ˆÔð '=ˆÕ#r   c                 ó6   — t        ||||| j                  ¬«      S )N©Úchanged_only)Ú
_safe_reprr<   )r   ÚobjectÚcontextÚ	maxlevelsÚlevels        r   Úformatz_EstimatorPrettyPrinter.format¾   s    € ÜØ�G˜Y¨¸D×<NÑ<Nô
ð 	
r   c                 ó†  — |j                  |j                  j                  dz   «       | j                  r"|t	        |j                  j                  «      z  }| j
                  rt        |«      }n|j                  d¬«      }| j                  t        |j                  «       «      |||dz   ||«       |j                  d«       y )NÚ(Fr   r8   Ú))Úwriter   r   r:   Úlenr<   r1   r%   Ú_format_paramsÚsortedr*   )r   rE   r@   r=   Ú	allowancerF   rH   r-   s           r   Ú_pprint_estimatorz)_EstimatorPrettyPrinter._pprint_estimatorÃ   s¡   € Ø�‰�V×%Ñ%×.Ñ.°Ñ4Ô5Ø×ÒØ”c˜&×*Ñ*×3Ñ3Ó4Ñ4ˆFà×ÒÜ$ VÓ,‰Fà×&Ñ&¨EÐ&Ó2ˆFà×ÑÜ�6—<‘<“>Ó" F¨F°IÀ±MÀ7ÈEô	
ð 	�‰�SÕr   c           	      ó2   — | j                  ||||||d¬«      S )NT©Úis_dict©Ú_format_params_or_dict_items©r   r*   r@   r=   rQ   rF   rH   s          r   Ú_format_dict_itemsz*_EstimatorPrettyPrinter._format_dict_itemsÒ   s)   € Ø×0Ñ0Ø�6˜6 9¨g°uÀdð 1ó 
ð 	
r   c           	      ó2   — | j                  ||||||d¬«      S )NFrT   rV   rX   s          r   rO   z&_EstimatorPrettyPrinter._format_params×   s)   € Ø×0Ñ0Ø�6˜6 9¨g°uÀeð 1ó 
ð 	
r   c                 óî  — |j                   }|| j                  z  }dd|z  z   }	d}
| j                  |z
  dz   x}}t        |«      }	 t	        |«      }d}d}|sõ|| j                  k(  r	 |d«       y|dz  }|}	 t	        |«      }| j                  r‚|\  }}| j                  |||«      }| j                  |||«      }|s|j                  d
«      }|rdnd}||z   |z   }t        |«      dz   }||k  r|}|
r|	}
||k\  r||z  } ||
«       d}
 ||«       Œ» ||
«       |	}
|rt        nt        }| j                   ||«      |||r|nd||«       |sŒôyy# t
        $ r Y yw xY w# t
        $ r d	}||z  }||z  }Y Œñw xY w)a-  Format dict items or parameters respecting the compact=True
        parameter. For some reason, the builtin rendering of dict items doesn't
        respect compact=True and will use one line per key-value if all cannot
        fit in a single line.
        Dict items will be rendered as <'key': value> while params will be
        rendered as <key=value>. The implementation is mostly copy/pasting from
        the builtin _format_items().
        This also adds ellipsis if the number of items is greater than
        self.n_max_elements_to_show.
        ú,
Ú Ú r8   NFr   ú, ...TÚ'ú: Ú=é   ú, )rM   r;   Ú_widthÚiterÚnextÚStopIterationr6   Ú_compactÚ_reprÚstriprN   r   r   Ú_format)r   rE   r@   r=   rQ   rF   rH   rU   rM   ÚdelimnlÚdelimr>   Ú	max_widthÚitÚnext_entÚlastÚn_itemsÚentr!   r"   ÚkreprÚvreprÚmiddleÚrepÚwÚclass_s                             r   rW   z4_EstimatorPrettyPrinter._format_params_or_dict_itemsÜ   sÂ  € ð —‘ˆØ�$×(Ñ(Ñ(ˆØ˜# ™,Ñ&ˆØˆØ ŸK™K¨&Ñ0°1Ñ4Ð4ˆ�	Ü�&‹\ˆð	Ü˜B“xˆHð ˆØˆÙØ˜$×5Ñ5Ò5Ù�g”ØØ�q‰LˆGØˆCð#Ü ›8�ð
 �}Š}Ø‘��1ØŸ
™
 1 g¨uÓ5�ØŸ
™
 1 g¨uÓ5�ÙØ!ŸK™K¨Ó,�EÙ!(™¨c�Ø˜f‘n uÑ,�Ü˜“H˜q‘L�Ø˜1’9Ø%�EÙØ '˜Ø˜A’:Ø˜Q‘J�EÙ˜%”LØ �EÙ˜#”JØÙ�%ŒLØˆEÙ$+•[Ô1AˆFØ�L‰LÙ�s“˜V V¹$©YÀAÀwÐPUôôE øô	 ò 	Ùð	ûô !ò #Ø�Ø˜YÑ&�	Ø˜Ñ"’ð#ús$   ÁE Á7E Å	EÅEÅE4Å3E4c                 ó¢  — |j                   }|| j                  z  }| j                  dkD  r || j                  dz
  dz  «       dd|z  z   }d}	| j                  |z
  dz   x}
}t        |«      }	 t	        |«      }d}d}|s¨|| j                  k(  r	 |d«       y|dz  }|}	 t	        |«      }| j                  rI| j                  |||«      }t        |«      d
z   }|
|k  r|}
|	r|}	|
|k\  r|
|z  }
 ||	«       d}	 ||«       Œ‚ ||	«       |}	| j                  ||||r|nd||«       |sŒ§yy# t
        $ r Y yw xY w# t
        $ r d	}||z  }|
|z  }
Y Œ¤w xY w)zÏFormat the items of an iterable (list, tuple...). Same as the
        built-in _format_items, with support for ellipsis if the number of
        elements is greater than self.n_max_elements_to_show.
        r8   r]   r\   r^   NFr   r_   Trc   rd   )rM   r;   re   rf   rg   rh   r6   ri   rj   rN   rl   )r   r*   r@   r=   rQ   rF   rH   rM   rm   rn   r>   ro   rp   rq   rr   rs   rt   rx   ry   s                      r   Ú_format_itemsz%_EstimatorPrettyPrinter._format_items  s“  € ð
 —‘ˆØ�$×(Ñ(Ñ(ˆØ×!Ñ! AÒ%Ù�4×)Ñ)¨AÑ-°Ñ4Ô5Ø˜# ™,Ñ&ˆØˆØ ŸK™K¨&Ñ0°1Ñ4Ð4ˆ�	Ü�%‹[ˆð	Ü˜B“xˆHð ˆØˆÙØ˜$×5Ñ5Ò5Ù�g”ØØ�q‰LˆGØˆCð#Ü ›8�ð
 �}Š}Ø—j‘j  g¨uÓ5�Ü˜“H˜q‘L�Ø˜1’9Ø%�EÙØ '˜Ø˜A’:Ø˜Q‘J�EÙ˜%”LØ �EÙ˜#”JØÙ�%ŒLØˆEØ�L‰L˜˜f f¹4©iÀQÈÐQVÔWô7 øô	 ò 	Ùð	ûô !ò #Ø�Ø˜YÑ&�	Ø˜Ñ"’ð#ús$   Á-D' ÂD6 Ä'	D3Ä2D3Ä6EÅEc                 ó   — |\  }}| j                  |||«      }	t        |t        «      r|	j                  d«      }	d}
nd}
|j	                  |	«       |j	                  |
«       | j                  |||t        |	«      z   t        |
«      z   |||«       y)z=Pretty printing for key-value tuples from dict or parameters.r`   rb   ra   N)rj   r   r   rk   rM   rl   rN   )r   rE   r@   r=   rQ   rF   rH   r!   r"   rx   rw   s              r   Ú_pprint_key_val_tuplez-_EstimatorPrettyPrinter._pprint_key_val_tupleK  s‚   € à‰ˆˆ1Ø�j‰j˜˜G UÓ+ˆÜ�fÔ.Ô/Ø—)‘)˜C“.ˆCØ‰FàˆFØ�‰�SÔØ�‰�VÔØ�‰Øˆv�v¤ C£Ñ(¬3¨v«;Ñ6¸	À7ÈEõ	
r   )r8   éP   NN)r   r   r   r   r'   rI   rR   rY   rO   rW   r|   r~   ÚpprintÚPrettyPrinterÚ	_dispatchÚcopyr   r
   r   r   r   s   @r   r3   r3   v   sŽ   ø„ ñ0ðh ØØØð=ð ØØ#ö=ò*
ò
ò
ò

ò
=ò~.Xò`
ð& ×$Ñ$×.Ñ.×3Ñ3Ó5€IØ(9€Iˆm×$Ñ$Ñ%Ø&;€Iˆk×"Ñ"Õ#r   r3   c                 ó\  — t        | «      }|t        j                  v rt        | «      ddfS t	        |dd«      }t        |t        «      rù|t        j                  u rç| syt        | «      }|r||k\  rdd||v fS ||v rt        j                  | «      ddfS d||<   d}d}	g }
|
j                  }|dz  }t        }t        | j                  «       t        j                  ¬«      }|D ]E  \  }} ||||||¬	«      \  }}} ||||||¬	«      \  }}} ||›d
|›�«       |xr |xr |}|s|sŒDd}	ŒG ||= ddj                  |
«      z  ||	fS t        |t         «      r|t         j                  u s"t        |t"        «      rØ|t"        j                  u rÆt        |t         «      r| syd}nt%        | «      dk(  rd}n| syd}t        | «      }|r||k\  r
|dz  d||v fS ||v rt        j                  | «      ddfS d||<   d}d}	g }
|
j                  }|dz  }| D ]'  }t        |||||¬	«      \  }}} ||«       |sd}|sŒ&d}	Œ) ||= |dj                  |
«      z  ||	fS t        |t&        «      �r-t        | «      }|r||k\  r|j(                  › d�d||v fS ||v rt        j                  | «      ddfS d||<   d}d}	|rt+        | «      }n| j-                  d¬«      }g }
|
j                  }|dz  }t        }t        |j                  «       t        j                  ¬«      }|D ]T  \  }} ||||||¬	«      \  }}} ||||||¬	«      \  }}} ||j/                  d«      ›d|›�«       |xr |xr |}|s|sŒSd}	ŒV ||= |j(                  ›ddj                  |
«      ›d�||	fS t        | «      }||xr |j1                  d«       dfS )zMSame as the builtin _safe_repr, with added support for Estimator
    objects.TFr
   N)z{}TFz{...}r8   )ÚkeyrB   ra   z{%s}rd   )z[]TFz[%s]z(%s,))z()TFz(%s)z...z(...)r   r`   rb   rK   rL   Ú<)Útyper€   Ú_builtin_scalarsr    r&   Ú
issubclassÚdictr
   ÚidÚ
_recursionÚappendrD   rP   r*   Ú_safe_tupleÚjoinÚlistÚtuplerN   r   r   r1   r%   rk   Ú
startswith)rE   rF   rG   rH   rC   ÚtypÚrÚobjidÚreadableÚ	recursiveÚ
componentsr�   Úsafereprr*   r!   r"   ru   Ú	kreadableÚkrecurrv   Ú	vreadableÚvrecurrI   ÚoÚoreprÚ	oreadableÚorecurr-   rx   s                                r   rD   rD   c  s5  € ô ˆv‹,€Cà
Œf×%Ñ%Ñ%Ü�F‹|˜T 5Ð(Ð(ä��Z Ó&€AÜ�#”tÔ ¤d§m¡mÑ!3ÙØ$Ü�6“
ˆÙ˜ )Ò+Ø˜E 5¨GÐ#3Ð3Ð3Ø�GÑÜ×$Ñ$ VÓ,¨e°TÐ9Ð9Øˆ�‰ØˆØˆ	Øˆ
Ø×"Ñ"ˆØ�‰
ˆÜˆÜ�v—|‘|“~¬6×+=Ñ+=Ô>ˆÛ‰DˆAˆqÙ'/Ø�7˜I u¸<ô(Ñ$ˆE�9˜fñ (0Ø�7˜I u¸<ô(Ñ$ˆE�9˜fñ šu¡eÐ,Ô-ØÒ; IÒ;°)ˆHÙšØ ‘	ð ð �EˆNØ˜Ÿ	™	 *Ó-Ñ-¨x¸ÐBÐBä�3œÔ !¤t§}¡}Ñ"4Ü�3œÔ 1¬¯©Ñ#6ä�cœ4Ô ÙØ(Ø‰FÜ�‹[˜AÒØ‰FáØ(ØˆFÜ�6“
ˆÙ˜ )Ò+Ø˜E‘> 5¨%°7Ð*:Ð:Ð:Ø�GÑÜ×$Ñ$ VÓ,¨e°TÐ9Ð9Øˆ�‰ØˆØˆ	Øˆ
Ø×"Ñ"ˆØ�‰
ˆÛˆAÜ'1Ø�7˜I u¸<ô(Ñ$ˆE�9˜fñ �5ŒMÙØ �ÚØ ‘	ð ð �EˆNØ˜Ÿ	™	 *Ó-Ñ-¨x¸ÐBÐBä�#”}Õ%Ü�6“
ˆÙ˜ )Ò+Ø—l‘l�^ 5Ð)¨5°%¸7Ð2BÐBÐBØ�GÑÜ×$Ñ$ VÓ,¨e°TÐ9Ð9Øˆ�‰ØˆØˆ	ÙÜ$ VÓ,‰Fà×&Ñ&¨EÐ&Ó2ˆFØˆ
Ø×"Ñ"ˆØ�‰
ˆÜˆÜ�v—|‘|“~¬6×+=Ñ+=Ô>ˆÛ‰DˆAˆqÙ'/Ø�7˜I u¸<ô(Ñ$ˆE�9˜fñ (0Ø�7˜I u¸<ô(Ñ$ˆE�9˜fñ ˜eŸk™k¨#Õ.±Ð6Ô7ØÒ; IÒ;°)ˆHÙšØ ‘	ð ð �EˆNØŸL›L¨$¯)©)°JÕ*?Ð@À(ÈIÐVÐVä
ˆv‹,€CØ�Ò0˜SŸ^™^¨CÓ0Ð0°5Ð8Ð8r   )F)r   r   r€   Úsklearn._configr   Úsklearn.baser   Úsklearn.utils._missingr   r‘   r   r   r1   r�   r3   rD   r   r   r   Ú<module>r¥      sU   ðñ9óH Û å &Ý &Ý 0ô"�%ô "ô	�{ô 	òBô6j<˜f×2Ñ2ô j<ôZl9r   