§
    ìóÉj,k  ã                  óæ  — d dl mZ d dlZd dl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 d dl	mZ d dl	mZ d dlmZ d d	lmZ erd d
lmZ edeeeef         ZdZdZ G d„ dej        ¦  «        Z G d„ de¦  «        Z edde¬¦  «         G d„ de¦  «        ¦   «         Z edde¬¦  «         G d„ de¦  «        ¦   «         Z edde¬¦  «         G d„ de¦  «        ¦   «         Z  G d„ de¦  «        Z! edde¬¦  «         G d„ de!¦  «        ¦   «         Z" edde¬¦  «         G d„ de!¦  «        ¦   «         Z#d>d%„Z$ G d&„ d'e¦  «        Z%e!e#e"eeee e%fZ&d?d*„Z'd@d,„Z(dAd0„Z)dBd5„Z*dCd7„Z+dDd:„Z,	 dEdFd=„Z-dS )Gé    )ÚannotationsN)ÚReal)ÚAny)Úcast)ÚTYPE_CHECKING)ÚUnion)Údeprecated_class©Úoptuna_warn)ÚSequencez=Use :class:`~optuna.distributions.FloatDistribution` instead.z;Use :class:`~optuna.distributions.IntDistribution` instead.c                  ó    — e Zd ZdZdd„Zej        dd„¦   «         Zej        dd
„¦   «         Zej        dd„¦   «         Z	dd„Z
dd„Zdd„Zdd„ZdS )ÚBaseDistributionzÒBase class for distributions.

    Note that distribution classes are not supposed to be called by library users.
    They are used by :class:`~optuna.trial.Trial` and :class:`~optuna.samplers` internally.
    Úparam_value_in_internal_reprÚfloatÚreturnr   c                ó   — |S )a0  Convert internal representation of a parameter value into external representation.

        Args:
            param_value_in_internal_repr:
                Optuna's internal representation of a parameter value.

        Returns:
            Optuna's external representation of a parameter value.
        © ©Úselfr   s     úw/home/lighthouse/badge-speaker-benchmark/.benchmark-venv-community/lib/python3.11/site-packages/optuna/distributions.pyÚto_external_reprz!BaseDistribution.to_external_repr&   s
   € ð ,Ð+ó    Úparam_value_in_external_reprc                ó   — t           ‚)a0  Convert external representation of a parameter value into internal representation.

        Args:
            param_value_in_external_repr:
                Optuna's external representation of a parameter value.

        Returns:
            Optuna's internal representation of a parameter value.
        ©ÚNotImplementedError)r   r   s     r   Úto_internal_reprz!BaseDistribution.to_internal_repr3   s
   € õ "Ð!r   Úboolc                ó   — t           ‚)zàTest whether the range of this distribution contains just a single value.

        Returns:
            :obj:`True` if the range of this distribution contains just a single value,
            otherwise :obj:`False`.
        r   ©r   s    r   ÚsinglezBaseDistribution.singleA   s
   € õ "Ð!r   c                ó   — t           ‚)ag  Test if a parameter value is contained in the range of this distribution.

        Args:
            param_value_in_internal_repr:
                Optuna's internal representation of a parameter value.

        Returns:
            :obj:`True` if the parameter value is contained in the range of this distribution,
            otherwise :obj:`False`.
        r   r   s     r   Ú	_containszBaseDistribution._containsL   s
   € õ "Ð!r   Údictc                ó   — | j         S ©N)Ú__dict__r    s    r   Ú_asdictzBaseDistribution._asdict[   s
   € ØŒ}Ðr   Úotherc                óš   — t          |t          ¦  «        st          S t          | ¦  «        t          |¦  «        urdS | j        |j        k    S )NF)Ú
isinstancer   ÚNotImplementedÚtyper'   )r   r)   s     r   Ú__eq__zBaseDistribution.__eq__^   sF   € Ý˜%Õ!1Ñ2Ô2ð 	"Ý!Ð!Ý�‰:Œ:�T %™[œ[Ð(Ð(Ø�5ØŒ} ¤Ò.Ð.r   Úintc           	     ó”   — t          | j        ft          t          | j                             ¦   «         ¦  «        ¦  «        z   ¦  «        S r&   )ÚhashÚ	__class__ÚtupleÚsortedr'   Úitemsr    s    r   Ú__hash__zBaseDistribution.__hash__e   s8   € Ý�T”^Ð%­­f°T´]×5HÒ5HÑ5JÔ5JÑ.KÔ.KÑ(LÔ(LÑLÑMÔMÐMr   Ústrc                óÆ   — d                      d„ t          |                      ¦   «                              ¦   «         ¦  «        D ¦   «         ¦  «        }| j        j        › d|› d�S )Nú, c              3  ó*   K  — | ]\  }}|› d |› �V — ŒdS )ú=Nr   )Ú.0ÚkÚvs      r   ú	<genexpr>z,BaseDistribution.__repr__.<locals>.<genexpr>i   s0   è è € ÐQÐQ©$¨!¨Q˜a˜:˜: !˜:˜:ÐQÐQÐQÐQÐQÐQr   ú(ú))Újoinr4   r(   r5   r2   Ú__name__)r   Úkwargss     r   Ú__repr__zBaseDistribution.__repr__h   sZ   € Ø—’ÐQÐQµ&¸¿º¹¼×9MÒ9MÑ9OÔ9OÑ2PÔ2PÐQÑQÔQÑQÔQˆØ”.Ô)Ð5Ð5¨FÐ5Ð5Ð5Ð5r   N)r   r   r   r   )r   r   r   r   ©r   r   ©r   r   r   r   ©r   r$   ©r)   r   r   r   )r   r/   )r   r7   )rC   Ú
__module__Ú__qualname__Ú__doc__r   ÚabcÚabstractmethodr   r!   r#   r(   r.   r6   rE   r   r   r   r   r      sò   € € € € € ðð ð,ð ,ð ,ð ,ð 	Ôð"ð "ð "ñ Ôð"ð 	Ôð"ð "ð "ñ Ôð"ð 	Ôð"ð "ð "ñ Ôð"ðð ð ð ð/ð /ð /ð /ðNð Nð Nð Nð6ð 6ð 6ð 6ð 6ð 6r   r   c                  ó6   — e Zd ZdZ	 ddd„Zdd„Zdd„Zdd„ZdS )ÚFloatDistributionaa  A distribution on floats.

    This object is instantiated by :func:`~optuna.trial.Trial.suggest_float`, and passed to
    :mod:`~optuna.samplers` in general.

    .. note::
        When ``step`` is not :obj:`None`, if the range :math:`[\mathsf{low}, \mathsf{high}]`
        is not divisible by :math:`\mathsf{step}`, :math:`\mathsf{high}` will be replaced
        with the maximum of :math:`k \times \mathsf{step} + \mathsf{low} < \mathsf{high}`,
        where :math:`k` is an integer.

    Attributes:
        low:
            Lower endpoint of the range of the distribution. ``low`` is included in the range.
            ``low`` must be less than or equal to ``high``. If ``log`` is :obj:`True`,
            ``low`` must be larger than 0.
        high:
            Upper endpoint of the range of the distribution. ``high`` is included in the range.
            ``high`` must be greater than or equal to ``low``.
        log:
            If ``log`` is :obj:`True`, this distribution is in log-scaled domain.
            In this case, all parameters enqueued to the distribution must be positive values.
            This parameter must be :obj:`False` when the parameter ``step`` is not :obj:`None`.
        step:
            A discretization step. ``step`` must be larger than 0.
            This parameter must be :obj:`None` when the parameter ``log`` is :obj:`True`.

    FNÚlowr   ÚhighÚlogr   ÚstepúNone | floatr   ÚNonec                ó�  — |r|�t          d¦  «        ‚||k    rt          d|›d|›d�¦  «        ‚|r|dk    rt          d|›d|›d�¦  «        ‚|�|dk    rt          d|›d	�¦  «        ‚d | _        |�%t          |||¦  «        }t          |¦  «        | _        t          |¦  «        | _        t          |¦  «        | _        || _        d S )
Nz9The parameter `step` is not supported when `log` is true.ú&`low <= high` must hold, but got (low=ú, high=ú).ç        z1`low > 0` must hold for `log=True`, but got (low=r   ú#`step > 0` must hold, but got step=ú.)Ú
ValueErrorrT   Ú_adjust_discrete_uniform_highr   rQ   rR   rS   ©r   rQ   rR   rS   rT   s        r   Ú__init__zFloatDistribution.__init__‹   sø   € ð ð 	Z�4Ð#ÝÐXÑYÔYÐYà�Š:ˆ:ÝÐSÀ#ÐSÐSÈ$ÐSÐSÐSÑTÔTÐTàð 	`�3˜#’:�:ÝÐ^ÈSÐ^Ð^ÐUYÐ^Ð^Ð^Ñ_Ô_Ð_àÐ ¨¢	 	ÝÐF¸dÐFÐFÐFÑGÔGÐGàˆŒ	ØÐÝ0°°d¸DÑAÔAˆDÝ˜d™œˆDŒIå˜‘:”:ˆŒÝ˜$‘K”KˆŒ	ØˆŒˆˆr   c                óJ  — | j         €| j        | j        k    S | j        | j        k    rdS t          j        t          | j        ¦  «        ¦  «        }t          j        t          | j        ¦  «        ¦  «        }t          j        t          | j         ¦  «        ¦  «        }||z
  |k     S ©NT)rT   rQ   rR   ÚdecimalÚDecimalr7   )r   rR   rQ   rT   s       r   r!   zFloatDistribution.single£   s�   € ØŒ9ÐØ”8˜tœyÒ(Ð(àŒx˜4œ9Ò$Ð$Ø�tÝ”?¥3 t¤y¡>¤>Ñ2Ô2ˆDÝ”/¥# d¤h¡-¤-Ñ0Ô0ˆCÝ”?¥3 t¤y¡>¤>Ñ2Ô2ˆDØ˜3‘J $Ò&Ð&r   r   c                óæ   — |}| j         €| j        |cxk    o
| j        k    nc S || j        z
  | j         z  }| j        |cxk    o
| j        k    nc o"t          |t	          |¦  «        z
  ¦  «        dk     S )Ng:Œ0âŽyE>)rT   rQ   rR   ÚabsÚround)r   r   Úvaluer=   s       r   r#   zFloatDistribution._contains®   sŠ   € Ø,ˆØŒ9ÐØ”8˜uÐ1Ð1Ò1Ð1¨¬	Ò1Ð1Ð1Ð1Ð1à˜œÑ! T¤YÑ.ˆAØ”8˜uÐ1Ð1Ò1Ð1¨¬	Ò1Ð1Ð1Ð1ÐPµc¸!½eÀA¹h¼h¹,Ñ6GÔ6GÈ&Ò6PÐPr   r   c                ó  — 	 t          |¦  «        }n-# t          t          f$ r}t          d|› d�¦  «        |‚d }~ww xY wt          j        |¦  «        rt          d|› d�¦  «        ‚| j        r|dk    rt          d|› d�¦  «        ‚|S ©Nú'z8' is not a valid type. float-castable value is expected.ú`z` is invalid value.r[   z)` is invalid value for the case log=True.©r   r^   Ú	TypeErrorÚmathÚisnanrS   ©r   r   Úinternal_reprÚes       r   r   z"FloatDistribution.to_internal_repr¶   óÖ   € ð	Ý!Ð">Ñ?Ô?ˆMˆMøÝ�IÐ&ð 	ð 	ð 	Ýð4Ð0ð 4ð 4ð 4ñô ð ðøøøøð	øøøõ Œ:�mÑ$Ô$ð 	TÝÐRÐ!=ÐRÐRÐRÑSÔSÐSØŒ8ð 	˜¨Ò,Ð,ÝØ[Ð0Ð[Ð[Ð[ñô ð ð Ðó   ‚ ’<£7·<)FN)
rQ   r   rR   r   rS   r   rT   rU   r   rV   rF   rG   )r   r   r   r   )rC   rJ   rK   rL   ra   r!   r#   r   r   r   r   rP   rP   m   s~   € € € € € ðð ð< PTðð ð ð ð ð0	'ð 	'ð 	'ð 	'ðQð Qð Qð Qðð ð ð ð ð r   rP   z3.0.0z6.0.0)Útextc                  ó,   ‡ — e Zd ZdZd
ˆ fd„Zdd	„Zˆ xZS )ÚUniformDistributiona  A uniform distribution in the linear domain.

    This object is instantiated by :func:`~optuna.trial.Trial.suggest_float`, and passed to
    :mod:`~optuna.samplers` in general.

    Attributes:
        low:
            Lower endpoint of the range of the distribution. ``low`` is included in the range.
            ``low`` must be less than or equal to ``high``.
        high:
            Upper endpoint of the range of the distribution. ``high`` is included in the range.
            ``high`` must be greater than or equal to ``low``.

    rQ   r   rR   r   rV   c                óR   •— t          ¦   «                              ||dd ¬¦  «         d S ©NF©rQ   rR   rS   rT   ©Úsuperra   ©r   rQ   rR   r2   s      €r   ra   zUniformDistribution.__init__Ù   ó*   ø€ Ý‰Œ×Ò˜S t°¸TÐÑBÔBÐBÐBÐBr   r$   c                óŒ   — t          j        | j        ¦  «        }|                     d¦  «         |                     d¦  «         |S ©NrS   rT   ©ÚcopyÚdeepcopyr'   Úpop©r   Úds     r   r(   zUniformDistribution._asdictÜ   ó6   € ÝŒM˜$œ-Ñ(Ô(ˆØ	�Šˆe‰ŒˆØ	�Šˆf‰ŒˆØˆr   ©rQ   r   rR   r   r   rV   rH   ©rC   rJ   rK   rL   ra   r(   Ú__classcell__©r2   s   @r   ry   ry   È   sa   ø€ € € € € ðð ðCð Cð Cð Cð Cð Cðð ð ð ð ð ð ð r   ry   c                  ó,   ‡ — e Zd ZdZd
ˆ fd„Zdd	„Zˆ xZS )ÚLogUniformDistributionaK  A uniform distribution in the log domain.

    This object is instantiated by :func:`~optuna.trial.Trial.suggest_float` with ``log=True``,
    and passed to :mod:`~optuna.samplers` in general.

    Attributes:
        low:
            Lower endpoint of the range of the distribution. ``low`` is included in the range.
            ``low`` must be larger than 0. ``low`` must be less than or equal to ``high``.
        high:
            Upper endpoint of the range of the distribution. ``high`` is included in the range.
            ``high`` must be greater than or equal to ``low``.

    rQ   r   rR   r   rV   c                óR   •— t          ¦   «                              ||dd ¬¦  «         d S ©NTr|   r}   r   s      €r   ra   zLogUniformDistribution.__init__ô   ó*   ø€ Ý‰Œ×Ò˜S t°¸DÐÑAÔAÐAÐAÐAr   r$   c                óŒ   — t          j        | j        ¦  «        }|                     d¦  «         |                     d¦  «         |S r‚   rƒ   r‡   s     r   r(   zLogUniformDistribution._asdict÷   r‰   r   rŠ   rH   r‹   r�   s   @r   r�   r�   ã   sa   ø€ € € € € ðð ðBð Bð Bð Bð Bð Bðð ð ð ð ð ð ð r   r�   c                  óf   ‡ — e Zd ZdZdˆ fd„Zdd
„Zedd„¦   «         Zej        dd„¦   «         Zˆ xZ	S )ÚDiscreteUniformDistributionao  A discretized uniform distribution in the linear domain.

    This object is instantiated by :func:`~optuna.trial.Trial.suggest_float` with ``step``
    argument, and passed to :mod:`~optuna.samplers` in general.

    .. note::
        If the range :math:`[\mathsf{low}, \mathsf{high}]` is not divisible by :math:`q`,
        :math:`\mathsf{high}` will be replaced with the maximum of :math:`k q + \mathsf{low}
        < \mathsf{high}`, where :math:`k` is an integer.

    Args:
        low:
            Lower endpoint of the range of the distribution. ``low`` is included in the range.
            ``low`` must be less than or equal to ``high``.
        high:
            Upper endpoint of the range of the distribution. ``high`` is included in the range.
            ``high`` must be greater than or equal to ``low``.
        q:
            A discretization step. ``q`` must be larger than 0.

    Attributes:
        low:
            Lower endpoint of the range of the distribution. ``low`` is included in the range.
        high:
            Upper endpoint of the range of the distribution. ``high`` is included in the range.

    rQ   r   rR   Úqr   rV   c                óP   •— t          ¦   «                              |||¬¦  «         d S )N©rQ   rR   rT   r}   )r   rQ   rR   r–   r2   s       €r   ra   z$DiscreteUniformDistribution.__init__  s(   ø€ Ý‰Œ×Ò˜S t°!ÐÑ4Ô4Ð4Ð4Ð4r   r$   c                ó–   — t          j        | j        ¦  «        }|                     d¦  «         |                     d¦  «        }||d<   |S )NrS   rT   r–   rƒ   )r   rˆ   rT   s      r   r(   z#DiscreteUniformDistribution._asdict  s?   € ÝŒM˜$œ-Ñ(Ô(ˆØ	�Šˆe‰Œˆà�uŠu�V‰}Œ}ˆØˆˆ#‰Øˆr   c                ó,   — t          d| j        ¦  «        S )zèDiscretization step.

        :class:`~optuna.distributions.DiscreteUniformDistribution` is a subtype of
        :class:`~optuna.distributions.FloatDistribution`.
        This property is a proxy for its ``step`` attribute.
        r   )r   rT   r    s    r   r–   zDiscreteUniformDistribution.q'  s   € õ �G˜TœYÑ'Ô'Ð'r   r>   c                ó   — || _         d S r&   )rT   )r   r>   s     r   r–   zDiscreteUniformDistribution.q1  s   € àˆŒ	ˆ	ˆ	r   )rQ   r   rR   r   r–   r   r   rV   rH   )r   r   )r>   r   r   rV   )
rC   rJ   rK   rL   ra   r(   Úpropertyr–   ÚsetterrŒ   r�   s   @r   r•   r•   þ   s�   ø€ € € € € ðð ð85ð 5ð 5ð 5ð 5ð 5ðð ð ð ð ð(ð (ð (ñ „Xð(ð „Xðð ð ñ „Xðð ð ð ð r   r•   c                  ó<   — e Zd ZdZddd„Zdd„Zdd„Zdd„Zdd„ZdS )ÚIntDistributiona^  A distribution on integers.

    This object is instantiated by :func:`~optuna.trial.Trial.suggest_int`, and passed to
    :mod:`~optuna.samplers` in general.

    .. note::
        When ``step`` is not :obj:`None`, if the range :math:`[\mathsf{low}, \mathsf{high}]`
        is not divisible by :math:`\mathsf{step}`, :math:`\mathsf{high}` will be replaced
        with the maximum of :math:`k \times \mathsf{step} + \mathsf{low} < \mathsf{high}`,
        where :math:`k` is an integer.

    Attributes:
        low:
            Lower endpoint of the range of the distribution. ``low`` is included in the range.
            ``low`` must be less than or equal to ``high``. If ``log`` is :obj:`True`,
            ``low`` must be larger than or equal to 1.
        high:
            Upper endpoint of the range of the distribution. ``high`` is included in the range.
            ``high`` must be greater than or equal to ``low``.
        log:
            If ``log`` is :obj:`True`, this distribution is in log-scaled domain.
            In this case, all parameters enqueued to the distribution must be positive values.
            This parameter must be :obj:`False` when the parameter ``step`` is not 1.
        step:
            A discretization step. ``step`` must be a positive integer. This parameter must be 1
            when the parameter ``log`` is :obj:`True`.

    Fé   rQ   r/   rR   rS   r   rT   r   rV   c                ó–  — |r|dk    rt          d¦  «        ‚||k    rt          d|›d|›d�¦  «        ‚|r|dk     rt          d|›d|›d�¦  «        ‚|dk    rt          d|›d	�¦  «        ‚|| _        t          |¦  «        | _        t          |¦  «        | _        t          |¦  «        }t          | j        || j        ¦  «        | _        d S )
Nr    zZSamplers and other components in Optuna only accept step is 1 when `log` argument is True.rX   rY   rZ   z2`low >= 1` must hold for `log=True`, but got (low=r   r\   r]   )r^   rS   r/   rT   rQ   Ú_adjust_int_uniform_highrR   r`   s        r   ra   zIntDistribution.__init__T  sô   € Øð 	�4˜1’9�9Ýð/ñô ð ð
 �Š:ˆ:ÝÐSÀ#ÐSÐSÈ$ÐSÐSÐSÑTÔTÐTàð 	a�3˜’7�7ÝÐ_ÈcÐ_Ð_ÐVZÐ_Ð_Ð_Ñ`Ô`Ð`à�1Š9ˆ9ÝÐF¸dÐFÐFÐFÑGÔGÐGàˆŒÝ˜‘I”IˆŒ	Ý�s‘8”8ˆŒÝ�4‰yŒyˆÝ,¨T¬X°t¸T¼YÑGÔGˆŒ	ˆ	ˆ	r   r   r   c                ó    — t          |¦  «        S r&   )r/   r   s     r   r   z IntDistribution.to_external_reprj  s   € ÝÐ/Ñ0Ô0Ð0r   r   c                ó  — 	 t          |¦  «        }n-# t          t          f$ r}t          d|› d�¦  «        |‚d }~ww xY wt          j        |¦  «        rt          d|› d�¦  «        ‚| j        r|dk    rt          d|› d�¦  «        ‚|S rk   rn   rr   s       r   r   z IntDistribution.to_internal_reprm  ru   rv   c                ó„   — | j         r| j        | j        k    S | j        | j        k    rdS | j        | j        z
  | j        k     S rc   )rS   rQ   rR   rT   r    s    r   r!   zIntDistribution.single~  sE   € ØŒ8ð 	)Ø”8˜tœyÒ(Ð(àŒ8�t”yÒ Ð Ø�4Ø”	˜DœHÑ$¨¬	Ò1Ð1r   c                óf   — |}| j         |cxk    o
| j        k    nc o|| j         z
  | j        z  dk    S ©Nr   r˜   )r   r   ri   s      r   r#   zIntDistribution._contains†  sF   € Ø,ˆØŒx˜5Ð-Ð-Ò-Ð- D¤IÒ-Ð-Ð-Ð-ÐU°5¸4¼8Ñ3CÀtÄyÑ2PÐTUÒ2UÐUr   N)Fr    )
rQ   r/   rR   r/   rS   r   rT   r/   r   rV   )r   r   r   r/   )r   r/   r   r   rF   rG   )	rC   rJ   rK   rL   ra   r   r   r!   r#   r   r   r   rŸ   rŸ   6  s’   € € € € € ðð ð:Hð Hð Hð Hð Hð,1ð 1ð 1ð 1ðð ð ð ð"2ð 2ð 2ð 2ðVð Vð Vð Vð Vð Vr   rŸ   c                  ó.   ‡ — e Zd ZdZddˆ fd	„Zdd„Zˆ xZS )ÚIntUniformDistributionaŽ  A uniform distribution on integers.

    This object is instantiated by :func:`~optuna.trial.Trial.suggest_int`, and passed to
    :mod:`~optuna.samplers` in general.

    .. note::
        If the range :math:`[\mathsf{low}, \mathsf{high}]` is not divisible by
        :math:`\mathsf{step}`, :math:`\mathsf{high}` will be replaced with the maximum of
        :math:`k \times \mathsf{step} + \mathsf{low} < \mathsf{high}`, where :math:`k` is
        an integer.

    Attributes:
        low:
            Lower endpoint of the range of the distribution. ``low`` is included in the range.
            ``low`` must be less than or equal to ``high``.
        high:
            Upper endpoint of the range of the distribution. ``high`` is included in the range.
            ``high`` must be greater than or equal to ``low``.
        step:
            A discretization step. ``step`` must be a positive integer.

    r    rQ   r/   rR   rT   r   rV   c                óR   •— t          ¦   «                              ||d|¬¦  «         d S r{   r}   ©r   rQ   rR   rT   r2   s       €r   ra   zIntUniformDistribution.__init__¤  r€   r   r$   c                ób   — t          j        | j        ¦  «        }|                     d¦  «         |S ©NrS   rƒ   r‡   s     r   r(   zIntUniformDistribution._asdict§  ó'   € ÝŒM˜$œ-Ñ(Ô(ˆØ	�Šˆe‰ŒˆØˆr   ©r    ©rQ   r/   rR   r/   rT   r/   r   rV   rH   r‹   r�   s   @r   r©   r©   ‹  sg   ø€ € € € € ðð ð.Cð Cð Cð Cð Cð Cð Cðð ð ð ð ð ð ð r   r©   c                  ó.   ‡ — e Zd ZdZddˆ fd	„Zdd„Zˆ xZS )ÚIntLogUniformDistributiona   A uniform distribution on integers in the log domain.

    This object is instantiated by :func:`~optuna.trial.Trial.suggest_int`, and passed to
    :mod:`~optuna.samplers` in general.

    Attributes:
        low:
            Lower endpoint of the range of the distribution. ``low`` is included in the range
            and must be larger than or equal to 1. ``low`` must be less than or equal to ``high``.
        high:
            Upper endpoint of the range of the distribution. ``high`` is included in the range.
            ``high`` must be greater than or equal to ``low``.
        step:
            A discretization step. ``step`` must be a positive integer.

    r    rQ   r/   rR   rT   r   rV   c                óR   •— t          ¦   «                              ||d|¬¦  «         d S r‘   r}   r«   s       €r   ra   z"IntLogUniformDistribution.__init__À  r’   r   r$   c                ób   — t          j        | j        ¦  «        }|                     d¦  «         |S r­   rƒ   r‡   s     r   r(   z!IntLogUniformDistribution._asdictÃ  r®   r   r¯   r°   rH   r‹   r�   s   @r   r²   r²   ­  sg   ø€ € € € € ðð ð"Bð Bð Bð Bð Bð Bð Bðð ð ð ð ð ð ð r   r²   Úvalue1ÚCategoricalChoiceTypeÚvalue2r   r   c                óî   — t          | t          ¦  «        o t          j        t	          | ¦  «        ¦  «        }t          |t          ¦  «        o t          j        t	          |¦  «        ¦  «        }| |k    p|o|S )z‡A function to check two choices equal considering NaN.

    This function can handle NaNs like np.float32("nan") other than float.
    )r+   r   rp   rq   r   )rµ   r·   Úvalue1_is_nanÚvalue2_is_nans       r   Ú_categorical_choice_equalr»   É  sa   € õ ˜v¥tÑ,Ô,ÐJµ´½EÀ&¹M¼MÑ1JÔ1J€MÝ˜v¥tÑ,Ô,ÐJµ´½EÀ&¹M¼MÑ1JÔ1J€MØ�fÒÐB -Ð"A°MÐBr   c                  óP   — e Zd ZdZdd„Zdd
„Zdd„Zdd„Zdd„Zdd„Z	e
j        ZdS )ÚCategoricalDistributionaT  A categorical distribution.

    This object is instantiated by :func:`~optuna.trial.Trial.suggest_categorical`, and
    passed to :mod:`~optuna.samplers` in general.

    Args:
        choices:
            Parameter value candidates. ``choices`` must have one element at least.

    .. note::

        Not all types are guaranteed to be compatible with all storages. It is recommended to
        restrict the types of the choices to :obj:`None`, :class:`bool`, :class:`int`,
        :class:`float` and :class:`str`.

    Attributes:
        choices:
            Parameter value candidates.

    ÚchoicesúSequence[CategoricalChoiceType]r   rV   c                ó$  — t          |¦  «        dk    rt          d¦  «        ‚|D ]V}|�Rt          |t          t          t
          t          f¦  «        s*d|› dt          |¦  «        j        › d�}t          |¦  «         ŒWt          |¦  «        | _        d S )Nr   z0The `choices` must contain one or more elements.zChoices for a categorical distribution should be a tuple of None, bool, int, float and str for persistent storage but contains z which is of type r]   )Úlenr^   r+   r   r/   r   r7   r-   rC   r   r3   r¾   )r   r¾   ÚchoiceÚmessages       r   ra   z CategoricalDistribution.__init__ì  sª   € Ýˆw‰<Œ<˜1ÒÐÝÐOÑPÔPÐPØð 	%ð 	%ˆFØÐ!­*°V½dÅCÍÕPSÐ=TÑ*UÔ*UÐ!ðJàðJð Jå15°f±´Ô1FðJð Jð Jð õ
 ˜GÑ$Ô$Ð$øå˜W‘~”~ˆŒˆˆr   r   r   r¶   c                ó6   — | j         t          |¦  «                 S r&   )r¾   r/   r   s     r   r   z(CategoricalDistribution.to_external_reprú  s   € ØŒ|�CÐ <Ñ=Ô=Ô>Ð>r   r   c                óî   — 	 | j                              |¦  «        S # t          $ r3 t          | j         ¦  «        D ]\  }}t	          ||¦  «        r|c cY S ŒY nw xY wt          d|› d| j         › d�¦  «        ‚)Nrl   z	' not in r]   )r¾   Úindexr^   Ú	enumerater»   )r   r   rÆ   rÂ   s       r   r   z(CategoricalDistribution.to_internal_reprý  s®   € ð
	!ð
 ”<×%Ò%Ð&BÑCÔCÐCøÝð 	!ð 	!ð 	!å!*¨4¬<Ñ!8Ô!8ð !ð !‘��vÝ,Ð-IÈ6ÑRÔRð !Ø �L�L�L�L�Lð!ð!ð !ð	!øøøõ ÐSÐ9ÐSÐSÀDÄLÐSÐSÐSÑTÔTÐTs   ‚ œ7AÁAÁAr   c                ó2   — t          | j        ¦  «        dk    S )Nr    )rÁ   r¾   r    s    r   r!   zCategoricalDistribution.single  s   € Ý�4”<Ñ Ô  AÒ%Ð%r   c                ód   — t          |¦  «        }d|cxk    ot          | j        ¦  «        k     nc S r§   )r/   rÁ   r¾   )r   r   rÆ   s      r   r#   z!CategoricalDistribution._contains  s<   € ÝÐ0Ñ1Ô1ˆØ�EÐ-Ð-Ò-Ð-�C ¤Ñ-Ô-Ò-Ð-Ð-Ð-Ð-r   r)   r   c                ó$  — t          |t          ¦  «        st          S t          || j        ¦  «        sdS | j                             ¦   «         |j                             ¦   «         k    rdS | j                             ¦   «         D ]Œ\  }}|dk    rjt          |¦  «        t          t          ||¦  «        ¦  «        k    r dS t          |t          ||¦  «        ¦  «        D ]\  }}t          ||¦  «        s  dS ŒŒu|t          ||¦  «        k    r dS Œ�dS )NFr¾   T)r+   r   r,   r2   r'   Úkeysr5   rÁ   ÚgetattrÚzipr»   )r   r)   Úkeyri   rÂ   Úother_choices         r   r.   zCategoricalDistribution.__eq__  s+  € Ý˜%Õ!1Ñ2Ô2ð 	"Ý!Ð!Ý˜% ¤Ñ0Ô0ð 	Ø�5ØŒ=×ÒÑÔ 5¤>×#6Ò#6Ñ#8Ô#8Ò8Ð8Ø�5Øœ-×-Ò-Ñ/Ô/ð 		!ð 		!‰JˆC�Ø�iÒÐÝ�u‘:”:¥¥W¨U°CÑ%8Ô%8Ñ!9Ô!9Ò9Ð9Ø ˜5˜5Ý,/°µw¸uÀcÑ7JÔ7JÑ,KÔ,Kð %ð %Ñ(�F˜LÝ4°V¸\ÑJÔJð %Ø$˜u˜u˜uð%ð%ð �G E¨3Ñ/Ô/Ò/Ð/Ø ˜5˜5ð 0àˆtr   N)r¾   r¿   r   rV   )r   r   r   r¶   )r   r¶   r   r   rF   rG   rI   )rC   rJ   rK   rL   ra   r   r   r!   r#   r.   r   r6   r   r   r   r½   r½   Ö  sž   € € € € € ðð ð*&ð &ð &ð &ð?ð ?ð ?ð ?ðUð Uð Uð Uð&ð &ð &ð &ð.ð .ð .ð .ðð ð ð ð&  Ô(€H€H€Hr   r½   Újson_strr7   c                ó”  — t          j        | ¦  «        }d|v r}|d         t          j        k    r$t	          |d         d         ¦  «        |d         d<   t
          D ]#}|d         |j        k    r |di |d         ¤Žc S Œ$t          d|d         › �¦  «        ‚|d         dk    rt          |d         ¦  «        S |d         dv rq|d         }|d	         }|                     d
¦  «        }|                     dd¦  «        }|d         dk    rt          ||||¬¦  «        S |€d}t          ||||¬¦  «        S t          d|d         › �¦  «        ‚)z Deserialize a distribution in JSON format.

    Args:
        json_str: A JSON-serialized distribution.

    Returns:
        A deserialized distribution.

    ÚnameÚ
attributesr¾   zUnknown distribution class: r-   Úcategorical)r   r/   rQ   rR   rT   rS   Fr   )rS   rT   Nr    r|   zUnknown distribution type: r   )
ÚjsonÚloadsr½   rC   r3   ÚDISTRIBUTION_CLASSESr^   ÚgetrP   rŸ   )rÐ   Ú	json_dictÚclsrQ   rR   rT   rS   s          r   Újson_to_distributionrÛ   5  sŒ  € õ ”
˜8Ñ$Ô$€Ià�ÐÐØ�VÔÕ 7Ô @Ò@Ð@Ý16°yÀÔ7NÈyÔ7YÑ1ZÔ1ZˆI�lÔ# IÑ.å'ð 	6ð 	6ˆCØ˜Ô  C¤LÒ0Ð0Ø�sÐ5Ð5˜Y |Ô4Ð5Ð5Ð5Ð5Ð5ð 1õ ÐK¸	À&Ô8IÐKÐKÑLÔLÐLð �VÔ Ò-Ð-Ý*¨9°YÔ+?Ñ@Ô@Ð@Ø�vÔÐ"2Ð2Ð2Ø˜EÔ"ˆCØ˜VÔ$ˆDØ—=’= Ñ(Ô(ˆDØ—-’-  uÑ-Ô-ˆCà˜Ô  GÒ+Ð+Ý(¨¨d¸À$ÐGÑGÔGÐGð �<Ø�DÝ&¨3°T¸sÈÐNÑNÔNÐNåÐJ°yÀÔ7HÐJÐJÑKÔKÐKr   Údistc                óh   — t          j        | j        j        |                      ¦   «         dœ¦  «        S )z¥Serialize a distribution to JSON format.

    Args:
        dist: A distribution to be serialized.

    Returns:
        A JSON string of a given distribution.

    )rÒ   rÓ   )rÕ   Údumpsr2   rC   r(   )rÜ   s    r   Údistribution_to_jsonrß   a  s)   € õ Œ:˜tœ~Ô6ÀdÇlÂlÁnÄnÐUÐUÑVÔVÐVr   Údist_oldÚdist_newrV   c                ó–  — | j         |j         k    rt          d¦  «        ‚t          | t          t          f¦  «        r=t          |t          t          f¦  «        sJ ‚| j        |j        k    rt          d¦  «        ‚t          | t          ¦  «        sdS t          |t          ¦  «        sdS | |k    rt          t          j        dz   ¦  «        ‚dS )a!  A function to check compatibility of two distributions.

    It checks whether ``dist_old`` and ``dist_new`` are the same kind of distributions.
    If ``dist_old`` is :class:`~optuna.distributions.CategoricalDistribution`,
    it further checks ``choices`` are the same between ``dist_old`` and ``dist_new``.
    Note that this method is not supposed to be called by library users.

    Args:
        dist_old:
            A distribution previously recorded in storage.
        dist_new:
            A distribution newly added to storage.

    zBCannot set different distribution kind to the same parameter name.zBCannot set different log configuration to the same parameter name.Nz& does not support dynamic value space.)r2   r^   r+   rP   rŸ   rS   r½   rC   )rà   rá   s     r   Ú check_distribution_compatibilityrã   o  sØ   € ð$ Ô˜XÔ/Ò/Ð/ÝÐ]Ñ^Ô^Ð^å�(Õ.µÐ@ÑAÔAð cå˜(Õ%6½Ð$HÑIÔIÐIÐIÐIàŒ<˜8œ<Ò'Ð'ÝÐaÑbÔbÐbå�hÕ 7Ñ8Ô8ð ØˆÝ�hÕ 7Ñ8Ô8ð ØˆØ�8ÒÐÝÝ#Ô,Ð/WÑWñ
ô 
ð 	
ð Ðr   rQ   r   rR   rT   c                ó~  — t          j        t          |¦  «        ¦  «        }t          j        t          | ¦  «        ¦  «        }t          j        t          |¦  «        ¦  «        }||z
  }||z  t          j        d¦  «        k    r9|}t          ||z  |z  |z   ¦  «        }t	          d| › d|› d|›d| › d|› d�¦  «         |S )NÚ0ú"The distribution is specified by [r9   ú] and step=úF, but the range is not divisible by `step`. It will be replaced with [ú].)rd   re   r7   r   r   )rQ   rR   rT   Úd_highÚd_lowÚd_stepÚd_rÚold_highs           r   r_   r_   •  sð   € ÝŒ_�S ™YœYÑ'Ô'€FÝŒO�C ™HœHÑ%Ô%€EÝŒ_�S ™YœYÑ'Ô'€Fà
�5‰.€Cà
ˆV�|•w” sÑ+Ô+Ò+Ð+ØˆÝ�c˜V‘m vÑ-°Ñ5Ñ6Ô6ˆÝðR°ð Rð R¸ð Rð RÈð Rð RØBEðRð RØIMðRð Rð Rñ	
ô 	
ð 	
ð
 €Kr   r/   c                óz   — || z
  }||z  dk    r,|}||z  |z  | z   }t          d| › d|› d|›d| › d|› d�¦  «         |S )Nr   ræ   r9   rç   rè   ré   r
   )rQ   rR   rT   Úrrî   s        r   r¢   r¢   §  s�   € Øˆs‰
€AØˆ4�x�1‚}€}ØˆØ�D‰y˜4Ñ #Ñ%ˆÝðR°ð Rð R¸ð Rð RÈð Rð RØBEðRð RØIMðRð Rð Rñ	
ô 	
ð 	
ð €Kr   Údistributionú#int | float | CategoricalChoiceTypec                ó¼   — |                       ¦   «         sJ ‚t          | t          t          f¦  «        r| j        S t          | t
          ¦  «        r| j        d         S J ‚r§   )r!   r+   rP   rŸ   rQ   r½   r¾   )rñ   s    r   Ú_get_single_valuerô   ³  sk   € Ø×ÒÑ Ô Ð Ð Ð åØåÝð	
ñô ð 	'ð ÔÐÝ	�LÕ"9Ñ	:Ô	:ð 'ØÔ# AÔ&Ð&Ø€Lr   FÚsuppress_warningc                óp  — t          | t          ¦  «        rt          | j        | j        dd ¬¦  «        }nÝt          | t
          ¦  «        rt          | j        | j        dd ¬¦  «        }nªt          | t          ¦  «        r#t          | j        | j        d| j        ¬¦  «        }nrt          | t          ¦  «        r#t          | j        | j        d| j
        ¬¦  «        }n:t          | t          ¦  «        r#t          | j        | j        d| j
        ¬¦  «        }n| }|| k    r|s| › d|› d�}t          |t          ¦  «         |S )NFr|   Tz+ is deprecated and internally converted to z3. See https://github.com/optuna/optuna/issues/2941.)r+   ry   rP   rQ   rR   r�   r•   r–   r©   rŸ   rT   r²   r   ÚFutureWarning)rñ   rõ   Únew_distributionrÃ   s       r   Ú-_convert_old_distribution_to_new_distributionrù   Å  sŸ  € õ �,Õ 3Ñ4Ô4ð ((Ý,ØÔ ØÔ"ØØð	
ñ 
ô 
ÐÐõ 
�LÕ"8Ñ	9Ô	9ð !(Ý,ØÔ ØÔ"ØØð	
ñ 
ô 
ÐÐõ 
�LÕ"=Ñ	>Ô	>ð (Ý,ØÔ ØÔ"ØØ”ð	
ñ 
ô 
ÐÐõ 
�LÕ"8Ñ	9Ô	9ð (Ý*ØÔ ØÔ"ØØÔ"ð	
ñ 
ô 
ÐÐõ 
�LÕ";Ñ	<Ô	<ð 
(Ý*ØÔ ØÔ"ØØÔ"ð	
ñ 
ô 
ÐÐð (Ðà˜<Ò'Ð'Ð0@Ð'àð Vð VØ ðVð Vð Vð 	õ 	�G�]Ñ+Ô+Ð+àÐr   )rµ   r¶   r·   r¶   r   r   )rÐ   r7   r   r   )rÜ   r   r   r7   )rà   r   rá   r   r   rV   )rQ   r   rR   r   rT   r   r   r   )rQ   r/   rR   r/   rT   r/   r   r/   )rñ   r   r   rò   )F)rñ   r   rõ   r   r   r   ).Ú
__future__r   rM   r„   rd   rÕ   rp   Únumbersr   Útypingr   r   r   r   Úoptuna._deprecatedr	   Úoptuna._warningsr   Úcollections.abcr   r   r/   r   r7   r¶   Ú"_float_distribution_deprecated_msgÚ _int_distribution_deprecated_msgÚABCr   rP   ry   r�   r•   rŸ   r©   r²   r»   r½   r×   rÛ   rß   rã   r_   r¢   rô   rù   r   r   r   ú<module>r     sC  ðØ "Ð "Ð "Ð "Ð "Ð "à 
€
€
€
Ø €€€Ø €€€Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð à /Ð /Ð /Ð /Ð /Ð /Ø (Ð (Ð (Ð (Ð (Ð (ð ð )Ø(Ð(Ð(Ð(Ð(Ð(ð ˜d D¨#¨u°cÐ9Ô:Ð ð Dð #ð $aÐ  ðK6ð K6ð K6ð K6ð K6�s”wñ K6ô K6ð K6ð\Xð Xð Xð Xð XÐ(ñ Xô Xð Xðv Ð�'˜7Ð)KÐLÑLÔLðð ð ð ð Ð+ñ ô ñ MÔLðð4 Ð�'˜7Ð)KÐLÑLÔLðð ð ð ð Ð.ñ ô ñ MÔLðð4 Ð�'˜7Ð)KÐLÑLÔLð4ð 4ð 4ð 4ð 4Ð"3ñ 4ô 4ñ MÔLð4ðnRVð RVð RVð RVð RVÐ&ñ RVô RVð RVðj Ð�'˜7Ð)IÐJÑJÔJðð ð ð ð ˜_ñ ô ñ KÔJððB Ð�'˜7Ð)IÐJÑJÔJðð ð ð ð  ñ ô ñ KÔJðð6
Cð 
Cð 
Cð 
CðP)ð P)ð P)ð P)ð P)Ð.ñ P)ô P)ð P)ðh ØØØØØØØð	Ð ð)Lð )Lð )Lð )LðXWð Wð Wð Wð#
ð #
ð #
ð #
ðLð ð ð ð$	ð 	ð 	ð 	ðð ð ð ð( #ð8ð 8ð 8ð 8ð 8ð 8ð 8r   