ó
    ¦ñ:i\H  ã                   ó®   • S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
   " S	 S
\5      r " S S\5      rS r " S S\R                  5      rSS jrg)ztThis module contains the _EstimatorPrettyPrinter class used in
BaseEstimator.__repr__ for pretty-printing estimatorsé    N)ÚOrderedDicté   )Ú
get_config)ÚBaseEstimatoré   )Úis_scalar_nanc                   ó,   ^ • \ rS rSrSrU 4S jrSrU =r$ )ÚKeyValTupleéK   z@Dummy class for correctly rendering key-value tuples from dicts.c                 ó    >• [         TU ]  5       $ ©N)ÚsuperÚ__repr__)ÚselfÚ	__class__s    €ÚX/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/sklearn/utils/_pprint.pyr   ÚKeyValTuple.__repr__N   s   ø€ ä‰wÑÓ!Ð!ó    © )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__Ú__classcell__©r   s   @r   r
   r
   K   s   ø† ÙJ÷"ó "r   r
   c                   ó   • \ rS rSrSrSrg)ÚKeyValTupleParaméS   zEDummy class for correctly rendering key-value tuples from parameters.r   N)r   r   r   r   r   r   r   r   r   r   r   S   s   † ÙOâr   r   c                 óŽ  ^• U R                  SS9n[        U R                  SU R                  5      n[        R                  " U5      R
                  mTR                  5        VVs0 s H  u  p4X4R                  _M     snnmU4S jnUR                  5        VVs0 s H  u  pgU" Xg5      (       d  M  Xg_M     snn$ s  snnf s  snnf )zcReturn dict (param_name: value) of parameters that were given to
estimator with non-default values.F©ÚdeepÚdeprecated_originalc                 ó(  >• U T;  a  gTU    [         R                  :X  a  g[        U[        5      (       a  UR                  TU    R                  :w  a  g[        U5      [        TU    5      :w  a$  [        TU    5      (       a  [        U5      (       d  gg)NTF)ÚinspectÚ_emptyÚ
isinstancer   r   Úreprr   )ÚkÚvÚinit_paramss     €r   Úhas_changedÚ$_changed_params.<locals>.has_changedb   sz   ø€ Ø�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_paramsr;   Y   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×/@‹DˆAŠD™^ÒAÐAùó# Oùó" Bs   Á%B;ÂCÂ1Cc                   óò   ^ • \ rS rSrSr    SSSSS.U 4S jjjrS rS	 rS
 rS r	S r
S rS r\R                  R                  R!                  5       r\\\R$                  '   \\\R$                  '   SrU =r$ )Ú_EstimatorPrettyPrinterét   at	  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U ]  XX4US9  X`l        U R                  (       a  SU l        [	        5       S   U l        Xpl        g )N)r?   r   Úprint_changed_only)r   r1   Ú_indent_at_nameÚ_indent_per_levelr   Ú_changed_onlyrA   )	r   ÚindentÚwidthÚdepthÚstreamr?   r@   rA   r   s	           €r   r1   Ú _EstimatorPrettyPrinter.__init__§   sH   ø€ ô 	‰Ñ˜¨¸wÐÑGØ-ÔØ××Ø%&ˆDÔ"Ü'›\Ð*>Ñ?ˆÔð '=Õ#r   c                 ó,   • [        XX4U R                  S9$ )N©Úchanged_only)Ú
_safe_reprrF   )r   ÚobjectÚcontextÚ	maxlevelsÚlevels        r   ÚformatÚ_EstimatorPrettyPrinter.format¼   s   € ÜØ˜Y¸D×<NÑ<Nñ
ð 	
r   c                 óÐ  • UR                  UR                  R                  S-   5        U R                  (       a"  U[	        UR                  R                  5      -  nU R
                  (       a  [        U5      nOUR                  SS9n[        S [        UR                  5       5       5       5      nU R                  UR                  5       X#US-   XV5        UR                  S5        g )NÚ(Fr"   c              3   ó,   #   • U  H
  u  pX4v •  M     g 7fr   r   )Ú.0r9   Úvals      r   Ú	<genexpr>Ú<_EstimatorPrettyPrinter._pprint_estimator.<locals>.<genexpr>Ë   s   é € ÐSÒ<R©[¨d˜d�[Ò<Rùs   ‚r   Ú))Úwriter   r   rD   ÚlenrF   r;   r/   r   Úsortedr4   Ú_format_params)r   rP   rJ   rG   Ú	allowancerQ   rS   r7   s           r   Ú_pprint_estimatorÚ)_EstimatorPrettyPrinter._pprint_estimatorÁ   s³   € Ø�‰�V×%Ñ%×.Ñ.°Ñ4Ô5Ø××Ø”c˜&×*Ñ*×3Ñ3Ó4Ñ4ˆFà××Ü$ VÓ,‰Fà×&Ñ&¨EÐ&Ð2ˆFäÑS¼FÀ6Ç<Á<Ã>Ô<RÓSÓSˆà×ÑØ�L‰L‹N˜F¨I¸©M¸7ô	
ð 	�‰�SÕr   c           
      ó&   • U R                  XX4XVSS9$ )NT©Úis_dict©Ú_format_params_or_dict_items©r   r4   rJ   rG   rb   rQ   rS   s          r   Ú_format_dict_itemsÚ*_EstimatorPrettyPrinter._format_dict_itemsÒ   s#   € Ø×0Ñ0Ø˜6¨gÀdð 1ð 
ð 	
r   c           
      ó&   • U R                  XX4XVSS9$ )NFrf   rh   rj   s          r   ra   Ú&_EstimatorPrettyPrinter._format_params×   s#   € Ø×0Ñ0Ø˜6¨gÀeð 1ð 
ð 	
r   c                 óB  • UR                   nX0R                  -  nSSU-  -   n	Sn
U R                  U-
  S-   =p¼[        U5      n [	        U5      nSnSnU(       Gd  UU R                  :X  a	  U" S5        gUS-  nUn [	        U5      nU R                  (       a’  Uu  nnU R                  UXV5      nU R                  UXV5      nU(       d  UR                  S
5      nU(       a  SOSnUU-   U-   n[        U5      S-   nUU:  a  UnU
(       a  U	n
UU:¼  a  UU-  nU" U
5        Sn
U" U5        M×  U" U
5        U	n
U(       a  [        O[        nU R                  U" U5      X#U(       a  UOSXV5        U(       d  GM  gg! [
         a     gf = f! [
         a    S	nXÄ-  nX´-  n GNf = f)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.
ú,
Ú Ú r   NFr   ú, ...TÚ'ú: Ú=r   ú, )r^   rE   Ú_widthÚiterÚnextÚStopIterationrA   Ú_compactÚ_reprÚstripr_   r
   r   Ú_format)r   rP   rJ   rG   rb   rQ   rS   rg   r^   ÚdelimnlÚdelimrH   Ú	max_widthÚitÚnext_entÚlastÚn_itemsÚentr*   r+   ÚkreprÚvreprÚmiddleÚrepÚwÚclass_s                             r   ri   Ú4_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Ó5�ØŸ
™
 1 gÓ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¾$©YÀAÀwô÷E “$øô	 ó 	Ùð	ûô !ó #Ø�ØÑ&�	ØÑ"“ð#ús$   ÁE6 Á<F Å6
FÆFÆFÆFc                 óÔ  • UR                   nX0R                  -  nU R                  S:”  a  U" U R                  S-
  S-  5        SSU-  -   nSn	U R                  U-
  S-   =p«[        U5      n [	        U5      nSnSnU(       d½  XðR                  :X  a	  U" S5        gUS-  nUn [	        U5      nU R                  (       aP  U R                  UXV5      n[        U5      S
-   nU
U:  a  Un
U	(       a  Un	U
U:¼  a  U
U-  n
U" U	5        Sn	U" U5        M“  U" U	5        Un	U R                  UX#U(       a  UOSXV5        U(       d  M¼  gg! [
         a     gf = f! [
         a    S	nX´-  nX¤-  n
 N¹f = f)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.
r   rq   rp   rr   NFr   rs   Tr   rw   )r^   rE   rx   ry   rz   r{   rA   r|   r}   r_   r   )r   r4   rJ   rG   rb   rQ   rS   r^   r€   r�   rH   r‚   rƒ   r„   r…   r†   r‡   r‹   rŒ   s                      r   Ú_format_itemsÚ%_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Ó5�Ü˜“H˜q‘L�Ø˜1“9Ø%�EÞØ '˜Ø˜A“:Ø˜Q‘J�EÙ˜%”LØ �EÙ˜#”JÙÙ�%ŒLØˆEØ�L‰L˜˜f¾4©iÀQÈÔW÷7 ’$øô	 ó 	Ùð	ûô !ó #Ø�ØÑ&�	ØÑ"’ð#ús$   Á,E  Â"E Å 
EÅEÅE'Å&E'c                 ó"  • Uu  pxU R                  XuU5      n	[        U[        5      (       a  U	R                  S5      n	Sn
OSn
UR	                  U	5        UR	                  U
5        U R                  X‚U[        U	5      -   [        U
5      -   XEU5        g)z=Pretty printing for key-value tuples from dict or parameters.rt   rv   ru   N)r}   r(   r   r~   r^   r   r_   )r   rP   rJ   rG   rb   rQ   rS   r*   r+   r‹   rŠ   s              r   Ú_pprint_key_val_tupleÚ-_EstimatorPrettyPrinter._pprint_key_val_tupleK  s}   € à‰ˆØ�j‰j˜ UÓ+ˆÜ�fÔ.×/Ñ/Ø—)‘)˜C“.ˆCØ‰FàˆFØ�‰�SÔØ�‰�VÔØ�‰Ø�v¤ C£Ñ(¬3¨v«;Ñ6¸	ÈEõ	
r   )rF   rD   rE   rA   )r   éP   NN)r   r   r   r   r   r1   rT   rc   rk   ra   ri   r�   r“   ÚpprintÚPrettyPrinterÚ	_dispatchÚcopyr   r   r
   r   r   r   s   @r   r=   r=   t   s“   ø† ñ0ðh ØØØð=ð ØØ#÷=ñ =ò*
ò
ò"
ò

ò
=ò~.Xò`
ð& ×$Ñ$×.Ñ.×3Ñ3Ó5€IØ(9€Iˆm×$Ñ$Ñ%Ø&;€Iˆk×"Ñ"×#r   r=   c           	      ó  • [        U 5      nU[        R                  ;   a  [        U 5      SS4$ [	        USS5      n[        U[        5      (       Ga  U[        R                  L aû  U (       d  g[        U 5      nU(       a  X2:¼  a  SSXq;   4$ Xq;   a  [        R                  " U 5      SS4$ SX'   SnSn	/ n
U
R                  nUS-  n[        n[        U R                  5       [        R                  S9nU HR  u  pïU" XáX#US	9u  nnnU" XñX#US	9u  nnnU" U< S
U< 35        U=(       a    U=(       a    UnU(       d	  U(       d  MP  Sn	MT     X	 SSR                  U
5      -  X‰4$ [        U[         5      (       a  U[         R                  L d(  [        U["        5      (       aõ  U["        R                  L aâ  [        U[         5      (       a  U (       d  gSnO[%        U 5      S:X  a  SnO
U (       d  gSn[        U 5      nU(       a  X2:¼  a
  US-  SXq;   4$ Xq;   a  [        R                  " U 5      SS4$ SX'   SnSn	/ n
U
R                  nUS-  nU  H.  n[        UXX4S	9u  nnnU" U5        U(       d  SnU(       d  M,  Sn	M0     X	 USR                  U
5      -  X‰4$ [        U[&        5      (       Ga3  [        U 5      nU(       a  X2:¼  a  SSXq;   4$ Xq;   a  [        R                  " U 5      SS4$ SX'   SnSn	U(       a  [)        U 5      nOU R+                  SS9n/ n
U
R                  nUS-  n[        n[        UR                  5       [        R                  S9nU Ha  u  pïU" XáX#US	9u  nnnU" XñX#US	9u  nnnU" UR-                  S5      < SU< 35        U=(       a    U=(       a    UnU(       d	  U(       d  M_  Sn	Mc     X	 UR.                  < SSR                  U
5      < S3X‰4$ [        U 5      nUU=(       a    UR1                  S5      (       + S4$ )zISame as the builtin _safe_repr, with added support for Estimator
objects.TFr   N)z{}TFz{...}r   )ÚkeyrM   ru   z{%s}rw   )z[]TFz[%s]z(%s,))z()TFz(%s)z...r"   rt   rv   rW   r]   Ú<)Útyper–   Ú_builtin_scalarsr)   r0   Ú
issubclassÚdictr   ÚidÚ
_recursionÚappendrO   r`   r4   Ú_safe_tupleÚjoinÚlistÚtupler_   r   r;   r/   r~   r   Ú
startswith)rP   rQ   rR   rS   rN   ÚtypÚrÚobjidÚreadableÚ	recursiveÚ
componentsr£   Úsafereprr4   r*   r+   rˆ   Ú	kreadableÚkrecurr‰   Ú	vreadableÚvrecurrT   ÚoÚoreprÚ	oreadableÚorecurr7   r‹   s                                r   rO   rO   c  s  € ô ˆv‹,€Cà
Œf×%Ñ%Ó%Ü�F‹|˜T 5Ð(Ð(ä��Z Ó&€AÜ�#”t×Ò ¤d§m¡mÒ!3ÞØ$Ü�6“
ˆÞ˜Ó+Ø˜E 5Ñ#3Ð3Ð3ØÓÜ×$Ò$ VÓ,¨e°TÐ9Ð9Øˆ‰ØˆØˆ	Øˆ
Ø×"Ñ"ˆØ�‰
ˆÜˆÜ�v—|‘|“~¬6×+=Ñ+=Ñ>ˆÛ‰DˆAÙ'/Ø˜I¸<ñ(Ñ$ˆE�9˜fñ (0Ø˜I¸<ñ(Ñ$ˆE�9˜fñ ›u¢eÐ,Ô-Ø×; I×;°)ˆHÞŸ˜Ø ’	ñ ð ˆNØ˜Ÿ	™	 *Ó-Ñ-¨xÐBÐBä�3œ×Ñ !¤t§}¡}Ò"4Ü�3œ×Ñ 1¬¯©Ò#6ä�cœ4× Ñ ÞØ(Ø‰FÜ�‹[˜AÓØ‰FæØ(ØˆFÜ�6“
ˆÞ˜Ó+Ø˜E‘> 5¨%Ñ*:Ð:Ð:ØÓÜ×$Ò$ VÓ,¨e°TÐ9Ð9Øˆ‰ØˆØˆ	Øˆ
Ø×"Ñ"ˆØ�‰
ˆÛˆAÜ'1Ø�7 uñ(Ñ$ˆE�9˜fñ �5ŒMÞØ �ßˆvØ ’	ñ ð ˆNØ˜Ÿ	™	 *Ó-Ñ-¨xÐBÐBä�#”}×%Ò%Ü�6“
ˆÞ˜Ó+Ø˜E 5Ñ#3Ð3Ð3ØÓÜ×$Ò$ VÓ,¨e°TÐ9Ð9Øˆ‰ØˆØˆ	ÞÜ$ VÓ,‰Fà×&Ñ&¨EÐ&Ð2ˆFØˆ
Ø×"Ñ"ˆØ�‰
ˆÜˆÜ�v—|‘|“~¬6×+=Ñ+=Ñ>ˆÛ‰DˆAÙ'/Ø˜I¸<ñ(Ñ$ˆE�9˜fñ (0Ø˜I¸<ñ(Ñ$ˆE�9˜fñ ˜eŸk™k¨#Ö.²Ð6Ô7Ø×; I×;°)ˆHÞŸ˜Ø ’	ñ ð ˆNØŸLœL¨$¯)©)°JÖ*?Ð@À(ÐVÐVä
ˆv‹,€CØ�×0˜SŸ^™^¨CÓ0Ô0°5Ð8Ð8r   )F)r   r&   r–   Úcollectionsr   Ú_configr   Úbaser   Ú_missingr   r§   r
   r   r;   r—   r=   rO   r   r   r   Ú<module>r¼      sX   ðñ9óB Û Ý #å  Ý  Ý #ô"�%ô "ô	�{ô 	òBô6l<˜f×2Ñ2ô l<õ^l9r   