ó
    Ñ]j  ã                   óX   • S SK r S SKJr  S SKJr  S SKJr   " S S5      r " S S5      rg)	é    N)Ú__version__)Ú
get_config)Úparse_versionc                   óZ   • \ rS rSrSrSrSr\S 5       r\R                  S 5       rS r
Srg)	Ú_HTMLDocumentationLinkMixiné   a†  Mixin class allowing to generate a link to the API documentation.

This mixin relies on three attributes:
- `_doc_link_module`: it corresponds to the root module (e.g. `sklearn`). Using this
  mixin, the default value is `sklearn`.
- `_doc_link_template`: it corresponds to the template used to generate the
  link to the API documentation. Using this mixin, the default value is
  `"https://scikit-learn.org/{version_url}/modules/generated/
  {estimator_module}.{estimator_name}.html"`.
- `_doc_link_url_param_generator`: it corresponds to a function that generates the
  parameters to be used in the template when the estimator module and name are not
  sufficient.

The method :meth:`_get_doc_link` generates the link to the API documentation for a
given estimator.

This mixin provides all the necessary states for
:func:`sklearn.utils.estimator_html_repr` to generate a link to the API
documentation for the estimator HTML diagram.

Examples
--------
If the default values for `_doc_link_module`, `_doc_link_template` are not suitable,
then you can override them and provide a method to generate the URL parameters:
>>> from sklearn.base import BaseEstimator
>>> doc_link_template = "https://address.local/{single_param}.html"
>>> def url_param_generator(estimator):
...     return {"single_param": estimator.__class__.__name__}
>>> class MyEstimator(BaseEstimator):
...     # use "builtins" since it is the associated module when declaring
...     # the class in a docstring
...     _doc_link_module = "builtins"
...     _doc_link_template = doc_link_template
...     _doc_link_url_param_generator = url_param_generator
>>> estimator = MyEstimator()
>>> estimator._get_doc_link()
'https://address.local/MyEstimator.html'

If instead of overriding the attributes inside the class definition, you want to
override a class instance, you can use `types.MethodType` to bind the method to the
instance:
>>> import types
>>> estimator = BaseEstimator()
>>> estimator._doc_link_template = doc_link_template
>>> estimator._doc_link_url_param_generator = types.MethodType(
...     url_param_generator, estimator)
>>> estimator._get_doc_link()
'https://address.local/BaseEstimator.html'
ÚsklearnNc                 ó˜   • [        [        5      nUR                  c  UR                   SUR                   3nOSn[        U SSU S35      $ )NÚ.ÚdevÚ__doc_link_templatezhttps://scikit-learn.org/z;/modules/generated/{estimator_module}.{estimator_name}.html)r   r   r   ÚmajorÚminorÚgetattr)ÚselfÚsklearn_versionÚversion_urls      ÚZ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sklearn/utils/_repr_html/base.pyÚ_doc_link_templateÚ._HTMLDocumentationLinkMixin._doc_link_templateA   s_   € ä'¬Ó4ˆØ×ÑÑ&Ø,×2Ñ2Ð3°1°_×5JÑ5JÐ4KÐL‰KàˆKÜØØ!à+¨K¨=ð 9;ð ;ó	
ð 	
ó    c                 ó   • [        U SU5        g )Nr   )Úsetattr)r   Úvalues     r   r   r   Q   s   € ä�Ð+¨UÕ3r   c                 óÐ  • U R                   R                  R                  S5      S   U R                  :w  a  gU R                  cy  U R                   R
                  nSR                  [        R                  " S U R                   R                  R                  S5      5      5      nU R                  R                  X!S9$ U R                  R                  " S0 U R	                  5       D6$ )a‘  Generates a link to the API documentation for a given estimator.

This method generates the link to the estimator's documentation page
by using the template defined by the attribute `_doc_link_template`.

Returns
-------
url : str
    The URL to the API documentation for this estimator. If the estimator does
    not belong to module `_doc_link_module`, the empty string (i.e. `""`) is
    returned.
r   r   Ú c                 ó.   • U R                  S5      (       + $ )NÚ_)Ú
startswith)Úparts    r   Ú<lambda>Ú;_HTMLDocumentationLinkMixin._get_doc_link.<locals>.<lambda>l   s   €  T§_¡_°SÓ%9Õ!9r   )Úestimator_moduleÚestimator_name© )Ú	__class__Ú
__module__ÚsplitÚ_doc_link_moduleÚ_doc_link_url_param_generatorÚ__name__ÚjoinÚ	itertoolsÚ	takewhiler   Úformat)r   r$   r#   s      r   Ú_get_doc_linkÚ)_HTMLDocumentationLinkMixin._get_doc_linkU   sÌ   € ð �>‰>×$Ñ$×*Ñ*¨3Ó/°Ñ2°d×6KÑ6KÓKØà×-Ñ-Ñ5Ø!Ÿ^™^×4Ñ4ˆNð  #Ÿx™xÜ×#Ò#Ù9Ø—N‘N×-Ñ-×3Ñ3°CÓ8óó Ðð ×*Ñ*×1Ñ1Ø!1ð 2ð ð ð ×&Ñ&×-Ò-ÑU°×0RÑ0RÓ0TÑUÐUr   r%   )r+   r'   Ú__qualname__Ú__firstlineno__Ú__doc__r)   r*   Úpropertyr   Úsetterr0   Ú__static_attributes__r%   r   r   r   r      sH   † ñ0ðd !ÐØ$(Ð!àñ
ó ð
ð ×Ññ4ó ð4õVr   r   c                   ó4   • \ rS rSrSr\S 5       rS rS rSr	g)ÚReprHTMLMixinév   zËMixin to handle consistently the HTML representation.

When inheriting from this class, you need to define an attribute `_html_repr`
which is a callable that returns the HTML representation to be shown.
c                 óR   • [        5       S   S:w  a  [        S5      eU R                  $ )zãHTML representation of estimator.
This is redundant with the logic of `_repr_mimebundle_`. The latter
should be favored in the long term, `_repr_html_` is only
implemented for consumers who do not interpret `_repr_mimbundle_`.
ÚdisplayÚdiagramzW_repr_html_ is only defined when the 'display' configuration option is set to 'diagram')r   ÚAttributeErrorÚ_repr_html_inner©r   s    r   Ú_repr_html_ÚReprHTMLMixin._repr_html_}   s3   € ô ‹<˜	Ñ" iÓ/Ü ðóð ð
 ×$Ñ$Ð$r   c                 ó"   • U R                  5       $ )z¥This function is returned by the @property `_repr_html_` to make
`hasattr(estimator, "_repr_html_") return `True` or `False` depending
on `get_config()["display"]`.
)Ú
_html_reprr@   s    r   r?   ÚReprHTMLMixin._repr_html_innerŒ   s   € ð
 �‰Ó Ð r   c                 óh   • S[        U 5      0n[        5       S   S:X  a  U R                  5       US'   U$ )z8Mime bundle used by jupyter kernels to display estimatorz
text/plainr<   r=   z	text/html)Úreprr   rD   )r   ÚkwargsÚoutputs      r   Ú_repr_mimebundle_ÚReprHTMLMixin._repr_mimebundle_“   s5   € à¤ T£
Ð+ˆÜ‹<˜	Ñ" iÓ/Ø"&§/¡/Ó"3ˆF�;ÑØˆr   r%   N)
r+   r'   r2   r3   r4   r5   rA   r?   rJ   r7   r%   r   r   r9   r9   v   s%   † ñð ñ%ó ð%ò!õr   r9   )	r-   r	   r   Úsklearn._configr   Úsklearn.utils.fixesr   r   r9   r%   r   r   Ú<module>rN      s,   ðó å Ý &Ý -÷hVñ hV÷V"ò "r   