
    (^ik                       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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j4                        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'	 	 	 	 	 	 d-d$Z(d.d%Z)d/d&Z*d0d'Z+	 d1	 	 	 	 	 d2d(Z,d3d)Z-y)4    )annotationsN)Real)Any)cast)TYPE_CHECKING)Union)deprecated_class)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y
)BaseDistributionzBase 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.
    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.
         selfparam_value_in_internal_reprs     U/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/optuna/distributions.pyto_external_reprz!BaseDistribution.to_external_repr&   s
     ,+    c                    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   param_value_in_external_reprs     r   to_internal_reprz!BaseDistribution.to_internal_repr3   s
     "!r   c                    t         )zTest 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   c                    | j                   S N)__dict__r   s    r   _asdictzBaseDistribution._asdict[   s    }}r   c                    t        |t              st        S t        |       t        |      ury| j                  |j                  k(  S NF)
isinstancer   NotImplementedtyper!   )r   others     r   __eq__zBaseDistribution.__eq__^   s9    %!12!!:T%[(}}..r   c           	         t        | j                  ft        t        | j                  j                                     z         S r    )hash	__class__tuplesortedr!   itemsr   s    r   __hash__zBaseDistribution.__hash__e   s0    T^^%fT]]5H5H5J.K(LLMMr   c                    dj                  d t        | j                         j                               D              }| j                  j
                   d| dS )N, c              3  0   K   | ]  \  }}| d |   yw)=Nr   ).0kvs      r   	<genexpr>z,BaseDistribution.__repr__.<locals>.<genexpr>i   s     Q$!QaS!:Qs   ())joinr.   r"   r/   r,   __name__)r   kwargss     r   __repr__zBaseDistribution.__repr__h   sH    Q&9M9M9O2PQQ..))*!F8155r   N)r   floatreturnr   )r   r   r@   r?   r@   boolr   r?   r@   rB   r@   dictr(   r   r@   rB   )r@   int)r@   str)r<   
__module____qualname____doc__r   abcabstractmethodr   r   r   r"   r)   r0   r>   r   r   r   r   r      so    , 	" " 	" " 	" "/N6r   r   c                  F    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZd	dZd
dZddZy)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`.

    Nc                H   |r|t        d      ||kD  rt        d|d|d      |r|dk  rt        d|d|d      ||dk  rt        d|d	      d | _        |t        |||      }t        |      | _        t        |      | _        t        |      | _        || _        y )
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=.)
ValueErrorstep_adjust_discrete_uniform_highr?   lowhighlogr   rZ   r[   r\   rX   s        r   __init__zFloatDistribution.__init__   s     4#XYY:F#x$PRSTT3#:QSFRZUYT[[]^__	CdWAFGG	0dDADdDI:$K	r   c                   | j                   | j                  | j                  k(  S | j                  | j                  k(  ryt        j                  t        | j                              }t        j                  t        | j                              }t        j                  t        | j                               }||z
  |k  S NT)rX   rZ   r[   decimalDecimalrH   )r   r[   rZ   rX   s       r   r   zFloatDistribution.single   s    9988tyy((xx499$??3tyy>2D//#dhh-0C??3tyy>2D3J$&&r   c                   |}| j                   $| j                  |cxk  xr | j                  k  S c S || j                  z
  | j                   z  }| j                  |cxk  xr | j                  k  nc xr t        |t	        |      z
        dk  S )Ng:0yE>)rX   rZ   r[   absround)r   r   valuer6   s       r   r   zFloatDistribution._contains   su    ,9988u1		1111!TYY.A88u1		1Pc!eAh,6G&6PPr   c                    	 t        |      }t        j                  |      rt        d| d      | j
                  r|dk  rt        d| d      |S # t        t        f$ r}t        d| d      |d }~ww xY wN'z8' is not a valid type. float-castable value is expected.`z` is invalid value.rT   z)` is invalid value for the case log=True.r?   rW   	TypeErrormathisnanr\   r   r   internal_repres       r   r   z"FloatDistribution.to_internal_repr       	!">?M ::m$q!= >>QRSS88,011Z[   I& 	01 24 4 	   A A7"A22A7)FN)
rZ   r?   r[   r?   r\   rB   rX   zNone | floatr@   NonerA   rC   )r   r?   r@   r?   )r<   rI   rJ   rK   r^   r   r   r   r   r   r   rO   rO   m   sK    < PT %,0@L	0	'Qr   rO   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``.

    c                ,    t         |   ||dd        y NFrZ   r[   r\   rX   superr^   r   rZ   r[   r,   s      r   r^   zUniformDistribution.__init__       StTBr   c                    t        j                  | j                        }|j                  d       |j                  d       |S Nr\   rX   copydeepcopyr!   popr   ds     r   r"   zUniformDistribution._asdict   /    MM$--(	e	fr   rZ   r?   r[   r?   r@   rt   rD   r<   rI   rJ   rK   r^   r"   __classcell__r,   s   @r   rw   rw      s    Cr   rw   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``.

    c                ,    t         |   ||dd        y NTrz   r{   r}   s      r   r^   zLogUniformDistribution.__init__       StDAr   c                    t        j                  | j                        }|j                  d       |j                  d       |S r   r   r   s     r   r"   zLogUniformDistribution._asdict   r   r   r   rD   r   r   s   @r   r   r      s    Br   r   c                  d     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.

    c                *    t         |   |||       y )NrZ   r[   rX   r{   )r   rZ   r[   qr,   s       r   r^   z$DiscreteUniformDistribution.__init__  s    St!4r   c                    t        j                  | j                        }|j                  d       |j                  d      }||d<   |S )Nr\   rX   r   r   )r   r   rX   s      r   r"   z#DiscreteUniformDistribution._asdict  s:    MM$--(	euuV}#r   c                .    t        d| j                        S )zDiscretization step.

        :class:`~optuna.distributions.DiscreteUniformDistribution` is a subtype of
        :class:`~optuna.distributions.FloatDistribution`.
        This property is a proxy for its ``step`` attribute.
        r?   )r   rX   r   s    r   r   zDiscreteUniformDistribution.q'  s     GTYY''r   c                    || _         y r    )rX   )r   r7   s     r   r   zDiscreteUniformDistribution.q1  s	    	r   )rZ   r?   r[   r?   r   r?   r@   rt   rD   )r@   r?   )r7   r?   r@   rt   )
r<   rI   rJ   rK   r^   r"   propertyr   setterr   r   s   @r   r   r      s>    85 ( ( XX 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y)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`.

    c                `   |r|dk7  rt        d      ||kD  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                        | _        y )
N   zZSamplers and other components in Optuna only accept step is 1 when `log` argument is True.rQ   rR   rS   z2`low >= 1` must hold for `log=True`, but got (low=r   rU   rV   )rW   r\   rG   rX   rZ   _adjust_int_uniform_highr[   r]   s        r   r^   zIntDistribution.__init__T  s    419/ 
 :F#x$PRSTT37RcVS[VZU\\^_``19CdWAFGGI	s84y,TXXtTYYG	r   c                    t        |      S r    )rG   r   s     r   r   z IntDistribution.to_external_reprj  s    /00r   c                    	 t        |      }t        j                  |      rt        d| d      | j
                  r|dk  rt        d| d      |S # t        t        f$ r}t        d| d      |d }~ww xY wrh   rk   ro   s       r   r   z IntDistribution.to_internal_reprm  rr   rs   c                    | j                   r| j                  | j                  k(  S | j                  | j                  k(  ry| j                  | j                  z
  | j                  k  S r`   )r\   rZ   r[   rX   r   s    r   r   zIntDistribution.single~  sK    8888tyy((88tyy 		DHH$		11r   c                    |}| j                   |cxk  xr | j                  k  nc xr || j                   z
  | j                  z  dk(  S Nr   r   )r   r   rf   s      r   r   zIntDistribution._contains  s<    ,xx5-DII-U54883Ctyy2PTU2UUr   N)Fr   )
rZ   rG   r[   rG   r\   rB   rX   rG   r@   rt   )r   r?   r@   rG   )r   rG   r@   r?   rA   rC   )	r<   rI   rJ   rK   r^   r   r   r   r   r   r   r   r   r   6  s"    :H,1"2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.

    c                ,    t         |   ||d|       y ry   r{   r   rZ   r[   rX   r,   s       r   r^   zIntUniformDistribution.__init__  r~   r   c                f    t        j                  | j                        }|j                  d       |S Nr\   r   r   s     r   r"   zIntUniformDistribution._asdict  $    MM$--(	er   r   rZ   rG   r[   rG   rX   rG   r@   rt   rD   r   r   s   @r   r   r     s    .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.

    c                ,    t         |   ||d|       y r   r{   r   s       r   r^   z"IntLogUniformDistribution.__init__  r   r   c                f    t        j                  | j                        }|j                  d       |S r   r   r   s     r   r"   z!IntLogUniformDistribution._asdict  r   r   r   r   rD   r   r   s   @r   r   r     s    "Br   r   c                    t        | t              xr t        j                  t	        |             }t        |t              xr t        j                  t	        |            }| |k(  xs |xr |S )zA function to check two choices equal considering NaN.

    This function can handle NaNs like np.float32("nan") other than float.
    )r%   r   rm   rn   r?   )value1value2value1_is_nanvalue2_is_nans       r   _categorical_choice_equalr     sU     vt,JE&M1JMvt,JE&M1JMfB-"AMBr   c                  X    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y)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.

    c                   t        |      dk(  rt        d      |D ]W  }|t        |t        t        t
        t        f      r'd| dt        |      j                   d}t        j                  |       Y t        |      | _        y )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 rV   )lenrW   r%   rB   rG   r?   rH   r'   r<   warningswarnr-   choices)r   r   choicemessages       r   r^   z CategoricalDistribution.__init__  s    w<1OPP 	'F!*VdCPS=T*UIh0f1F1F0GqJ 
 g&	' W~r   c                2    | j                   t        |         S r    )r   rG   r   s     r   r   z(CategoricalDistribution.to_external_repr  s    ||C <=>>r   c                    	 | j                   j                  |      S # t        $ r2 t        | j                         D ]  \  }}t	        ||      s|c cY S  Y nw xY wt        d| d| j                    d      )Nri   z	' not in rV   )r   indexrW   	enumerater   )r   r   r   r   s       r   r   z(CategoricalDistribution.to_internal_repr  s}    
	!
 <<%%&BCC 	!!*4<<!8 !v,-I6R L!	! 19:)DLL>QRSTTs    0AAAAc                2    t        | j                        dk(  S )Nr   )r   r   r   s    r   r   zCategoricalDistribution.single  s    4<< A%%r   c                ^    t        |      }d|cxk  xr t        | j                        k  S c S r   )rG   r   r   )r   r   r   s      r   r   z!CategoricalDistribution._contains  s,    01E-C-----r   c                   t        |t              st        S t        || j                        sy| j                  j                         |j                  j                         k7  ry| j                  j                         D ]l  \  }}|dk(  rQt        |      t        t        ||            k7  r yt        |t        ||            D ]  \  }}t        ||      r  y \|t        ||      k7  sl y y)NFr   T)r%   r   r&   r,   r!   keysr/   r   getattrzipr   )r   r(   keyrf   r   other_choices         r   r)   zCategoricalDistribution.__eq__  s    %!12!!%0==5>>#6#6#88----/ 		!JCiu:WUC%8!99 ,/wuc7J,K %(FL4V\J$% GE3// 		! r   N)r   zSequence[CategoricalChoiceType]r@   rt   )r   r?   r@   CategoricalChoiceType)r   r   r@   r?   rA   rC   rF   )r<   rI   rJ   rK   r^   r   r   r   r   r)   r   r0   r   r   r   r   r     s3    *&?U&.&  ((Hr   r   c                   t        j                  |       }d|v rh|d   t        j                  k(  rt	        |d   d         |d   d<   t
        D ]!  }|d   |j                  k(  s |di |d   c S  t        d|d          |d   dk(  rt        |d         S |d   dv rW|d   }|d	   }|j                  d
      }|j                  dd      }|d   dk(  rt        ||||      S |d}t        ||||      S t        d|d          )zDeserialize 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?   rG   rZ   r[   rX   r\   Fr?   )r\   rX   r   rz   zUnknown distribution type: r   )
jsonloadsr   r<   r-   DISTRIBUTION_CLASSESrW   getrO   r   )json_str	json_dictclsrZ   r[   rX   r\   s          r   json_to_distributionr   5  sM    

8$IV 7 @ @@16y7Ny7Y1ZIl#I.' 	6C CLL05Y|455	6 7	&8I7JKLL V-*9Y+?@@v"22E"CV$D==(D--u-C G+(d$GG <D&3TsNN6y7H6IJKKr   c                v    t        j                  | j                  j                  | j	                         d      S )zSerialize a distribution to JSON format.

    Args:
        dist: A distribution to be serialized.

    Returns:
        A JSON string of a given distribution.

    )r   r   )r   dumpsr,   r<   r"   )dists    r   distribution_to_jsonr   a  s(     ::t~~66dllnUVVr   c                v   | j                   |j                   k7  rt        d      t        | t        t        f      r<t        |t        t        f      sJ | j
                  |j
                  k7  rt        d      t        | t              syt        |t              sy| |k7  rt        t        j                  dz         y)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.)r,   rW   r%   rO   r   r\   r   r<   )dist_olddist_news     r    check_distribution_compatibilityr   o  s    $ X///]^^(.@A(%6$HIII<<8<<'abbh 78h 788#,,/WW
 	
 r   c                p   t        j                  t        |            }t        j                  t        |             }t        j                  t        |            }||z
  }||z  t        j                  d      k7  r;|}t        ||z  |z  |z         }t	        j
                  d|  d| d|d|  d| d       |S )N0"The distribution is specified by [r2   ] and step=F, but the range is not divisible by `step`. It will be replaced with [].)ra   rb   rH   r?   r   r   )rZ   r[   rX   d_highd_lowd_stepd_rold_highs           r   rY   rY     s    __SY'FOOCH%E__SY'F
5.C
V|ws++cVmv-560Rzw OBBEbbR	

 Kr   c                    || z
  }||z  dk7  r2|}||z  |z  | z   }t        j                  d|  d| d|d|  d| d       |S )Nr   r   r2   r   r   r   )r   r   )rZ   r[   rX   rr   s        r   r   r     sn    s
A4x1}Dy4#%0Rzw OBBEbbR	
 Kr   c                    | j                         sJ t        | t        t        f      r| j                  S t        | t
              r| j                  d   S J r   )r   r%   rO   r   rZ   r   r   distributions    r   _get_single_valuer     sY       	
 	L"9	:##A&&5r   c                   t        | t              r$t        | j                  | j                  dd       }nt        | t
              r$t        | j                  | j                  dd       }nt        | t              r.t        | j                  | j                  d| j                        }n~t        | t              r.t        | j                  | j                  d| j                        }n@t        | t              r.t        | j                  | j                  d| j                        }n| }|| k7  r$|s"|  d| d}t        j                  |t               |S )NFrz   Tz+ is deprecated and internally converted to z3. See https://github.com/optuna/optuna/issues/2941.)r%   rw   rO   rZ   r[   r   r   r   r   r   rX   r   r   r   FutureWarning)r   suppress_warningnew_distributionr   s       r   -_convert_old_distribution_to_new_distributionr     sI    , 34,  ""	
 
L"8	9,  ""	
 
L"=	>,  ""	
 
L"8	9*  """"	
 
L";	<*  """"	
 (<'0@n  !!TV 	 	g}-r   c                H    t        | t        t        f      r| j                  S yr$   )r%   rO   r   r\   r   s    r   _is_distribution_logr      s!    ,!2O DEr   )r   r   r   r   r@   rB   )r   rH   r@   r   )r   r   r@   rH   )r   r   r   r   r@   rt   )rZ   r?   r[   r?   rX   r?   r@   r?   )rZ   rG   r[   rG   rX   rG   r@   rG   )r   r   r@   z#int | float | CategoricalChoiceType)F)r   r   r   rB   r@   r   )r   r   r@   rB   ).
__future__r   rL   r   ra   r   rm   numbersr   typingr   r   r   r   r   optuna._deprecatedr	   collections.abcr
   rB   rG   r?   rH   r   "_float_distribution_deprecated_msg _int_distribution_deprecated_msgABCr   rO   rw   r   r   r   r   r   r   r   r   r   r   r   rY   r   r   r   r   r   r   r   <module>r     s   " 
            / ( dD#uc9:  D # $a  K6sww K6\X( Xv '7)KL+  M4 '7)KL.  M4 '7)KL4"3 4 M4nRV& RVj '7)IJ_  KB '7)IJ  K6
C!
C+@
C	
CP). P)h 	 )LXW#
#
*:#
	#
L$	( #8"88 8vr   