
    3;ji                     f    d dl Z d dlmZ d dlmZ d dlmZ  G d d          Z G d d          ZdS )	    N)__version__)
get_config)parse_versionc                   V    e Zd ZdZdZdZed             Zej        d             Zd Z	dS )_HTMLDocumentationLinkMixina2	  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                     t          t                    }|j        |j         d|j         }nd}t          | dd| d          S )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      W/root/voice-cloning/.venv/lib/python3.11/site-packages/sklearn/utils/_repr_html/base.py_doc_link_templatez._HTMLDocumentationLinkMixin._doc_link_templateA   sf    '44&,2LL_5JLLKKK!;K ; ; ;	
 
 	
    c                 (    t          | d|           d S )Nr   )setattr)r   values     r   r   z._HTMLDocumentationLinkMixin._doc_link_templateQ   s    +U33333r   c                    | j         j                            d          d         | j        k    rdS | j        n| j         j        }d                    t          j        d | j         j                            d                              }| j	        
                    ||          S  | j	        j
        di |                                 S )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    Nc                 .    |                      d           S )N_)
startswith)parts    r   <lambda>z;_HTMLDocumentationLinkMixin._get_doc_link.<locals>.<lambda>l   s    T__S%9%9!9 r   )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_linkz)_HTMLDocumentationLinkMixin._get_doc_linkU   s     >$**3//2d6KKK2-5!^4N  #xx#99N-33C88     *11!1. 2    .t&-UU0R0R0T0TUUUr   )
r(   r$   __qualname____doc__r&   r'   propertyr   setterr-   r"   r   r   r   r      sy        0 0d !$(!
 
 X
 4 4 4V V V V Vr   r   c                   4    e Zd ZdZed             Zd Zd ZdS )ReprHTMLMixinzMixin 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                 ^    t                      d         dk    rt          d          | j        S )a  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_zReprHTMLMixin._repr_html_}   s:     <<	"i//   
 $$r   c                 *    |                                  S )zThis function is returned by the @property `_repr_html_` to make
        `hasattr(estimator, "_repr_html_") return `True` or `False` depending
        on `get_config()["display"]`.
        )
_html_reprr9   s    r   r8   zReprHTMLMixin._repr_html_inner   s    
    r   c                     dt          |           i}t                      d         dk    r|                                 |d<   |S )z8Mime bundle used by jupyter kernels to display estimatorz
text/plainr5   r6   z	text/html)reprr   r<   )r   kwargsoutputs      r   _repr_mimebundle_zReprHTMLMixin._repr_mimebundle_   s?    T

+<<	"i//"&//"3"3F;r   N)r(   r$   r.   r/   r0   r:   r8   rA   r"   r   r   r3   r3   v   sW          % % X%! ! !    r   r3   )	r*   r   r   sklearn._configr   sklearn.utils.fixesr   r   r3   r"   r   r   <module>rD      s              & & & & & & - - - - - -hV hV hV hV hV hV hV hVV" " " " " " " " " "r   