
    ,YHhxn                       d dl mZ d dlZd dlm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Zd dlZ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*d/d&Z+	 d0	 	 	 	 	 d1d'Z,d2d(Z-y)3    )annotationsN)Sequence)Real)Any)cast)Union)deprecated_classz=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     M/var/www/html/planif/env/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_repr0   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.single>   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._containsI   s
     "!r   c                    | j                   S N)__dict__r   s    r   _asdictzBaseDistribution._asdictX   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__b   s0    T^^%fT]]5H5H5J.K(LLMMr   c                    dj                  d t        | j                         j                               D              }dj	                  | j
                  j                  |      S )Nz, c              3  F   K   | ]  \  }}d j                  ||        yw)z{}={}N)format).0kvs      r   	<genexpr>z,BaseDistribution.__repr__.<locals>.<genexpr>f   s     [DAq7>>!Q/[s   !z{}({}))joinr-   r!   r.   r2   r+   __name__)r   kwargss     r   __repr__zBaseDistribution.__repr__e   sE    [F4<<>CWCWCY<Z[[t~~66??r   N)r   floatreturnr   )r   r   r<   r;   r<   boolr   r;   r<   r>   r<   dictr'   r   r<   r>   )r<   int)r<   str)r8   
__module____qualname____doc__r   abcabstractmethodr   r   r   r!   r(   r/   r:   r   r   r   r   r      sp    , 	" " 	" " 	" "/N@r   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                   |r|t        d      ||kD  rt        dj                  ||            |r |dk  rt        dj                  ||            ||dk  rt        dj                  |            d | _        |t        |||      }t	        |      | _        t	        |      | _        t	        |      | _        || _        y )Nz9The parameter `step` is not supported when `log` is true.TThe `low` value must be smaller than or equal to the `high` value (low={}, high={}).        zOThe `low` value must be larger than 0 for a log distribution (low={}, high={}).r   >The `step` value must be non-zero positive value, but step={}.)
ValueErrorr2   step_adjust_discrete_uniform_highr;   lowhighlogr   rS   rT   rU   rQ   s        r   __init__zFloatDistribution.__init__   s     4#XYY:%%+VC%6 
 3#:%%+VC%6 
 	SZZ[_`  	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)rQ   rS   rT   decimalDecimalrD   )r   rT   rS   rQ   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>)rQ   rS   rT   absround)r   r   valuer4   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.rN   z)` is invalid value for the case log=True.r;   rP   	TypeErrornpisnanrU   r   r   internal_repres       r   r   z"FloatDistribution.to_internal_repr       	!">?M 88M"q!= >>QRSS88,011Z[   I& 	01 24 4 	   A A7"A22A7)FN)
rS   r;   rT   r;   rU   r>   rQ   zNone | floatr<   Noner=   r?   )r   r;   r<   r;   )r8   rE   rF   rG   rW   r   r   r   r   r   r   rK   rK   j   sL    < PT %,0@L	@	'Qr   rK   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rS   rT   rU   rQ   superrW   r   rS   rT   r+   s      r   rW   zUniformDistribution.__init__       StTBr   c                    t        j                  | j                        }|j                  d       |j                  d       |S NrU   rQ   copydeepcopyr    popr   ds     r   r!   zUniformDistribution._asdict   /    MM$--(	e	fr   rS   r;   rT   r;   r<   rm   r@   r8   rE   rF   rG   rW   r!   __classcell__r+   s   @r   rp   rp      s    Cr   rp   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 NTrs   rt   rv   s      r   rW   zLogUniformDistribution.__init__       StDAr   c                    t        j                  | j                        }|j                  d       |j                  d       |S ry   rz   r~   s     r   r!   zLogUniformDistribution._asdict   r   r   r   r@   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rS   rT   rQ   rt   )r   rS   rT   qr+   s       r   rW   z$DiscreteUniformDistribution.__init__!  s    St!4r   c                    t        j                  | j                        }|j                  d       |j                  d      }||d<   |S )NrU   rQ   r   rz   )r   r   rQ   s      r   r!   z#DiscreteUniformDistribution._asdict$  s:    MM$--(	euuV}#r   c                6    t        t        | 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;   rQ   r   s    r   r   zDiscreteUniformDistribution.q,  s     E499%%r   c                    || _         y r   )rQ   )r   r5   s     r   r   zDiscreteUniformDistribution.q6  s	    	r   )rS   r;   rT   r;   r   r;   r<   rm   r@   )r<   r;   )r5   r;   r<   rm   )
r8   rE   rF   rG   rW   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j                  ||            |r |dk  rt        dj                  ||            |dk  rt        dj                  |            || _        t        |      | _        t        |      | _        t        |      }t        | j
                  || j                        | _        y )N   zZSamplers and other components in Optuna only accept step is 1 when `log` argument is True.rM   z\The `low` value must be equal to or greater than 1 for a log distribution (low={}, high={}).r   rO   )rP   r2   rU   rC   rQ   rS   _adjust_int_uniform_highrT   rV   s        r   rW   zIntDistribution.__init__Y  s    419/ 
 :%%+VC%6 
 37%%+VC%6 
 19PWWX\]  I	s84y,TXXtTYYG	r   c                    t        |      S r   )rC   r   s     r   r   z IntDistribution.to_external_reprw  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ra   rd   rh   s       r   r   z IntDistribution.to_internal_reprz  rk   rl   c                    | j                   r| j                  | j                  k(  S | j                  | j                  k(  ry| j                  | j                  z
  | j                  k  S rY   )rU   rS   rT   rQ   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   r_   s      r   r   zIntDistribution._contains  s<    ,xx5-DII-U54883Ctyy2PTU2UUr   N)Fr   )
rS   rC   rT   rC   rU   r>   rQ   rC   r<   rm   )r   r;   r<   rC   )r   rC   r<   r;   r=   r?   )	r8   rE   rF   rG   rW   r   r   r   r   r   r   r   r   r   ;  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 rr   rt   r   rS   rT   rQ   r+   s       r   rW   zIntUniformDistribution.__init__  rw   r   c                f    t        j                  | j                        }|j                  d       |S NrU   rz   r~   s     r   r!   zIntUniformDistribution._asdict  $    MM$--(	er   r   rS   rC   rT   rC   rQ   rC   r<   rm   r@   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   rt   r   s       r   rW   z"IntLogUniformDistribution.__init__  r   r   c                f    t        j                  | j                        }|j                  d       |S r   rz   r~   s     r   r!   z!IntLogUniformDistribution._asdict  r   r   r   r   r@   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   rf   rg   r;   )value1value2value1_is_nanvalue2_is_nans       r   _categorical_choice_equalr     sU     vt,H%-1HMvt,H%-1HM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 ]`  }|t        |t        t        t
        t        f      r'dj                  |t        |      j                        }t        j                  |       b t        |      | _        y )Nr   z0The `choices` must contain one or more elements.zChoices for a categorical distribution should be a tuple of None, bool, int, float and str for persistent storage but contains {} which is of type {}.)lenrP   r$   r>   rC   r;   rD   r2   r&   r8   warningswarnr,   choices)r   r   choicemessages       r   rW   z CategoricalDistribution.__init__  s}    w<1OPP 	'F!*VdCPS=T*U &f)>)>? 
 g&	' W~r   c                2    | j                   t        |         S r   )r   rC   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      )Nrb   z	' not in .)r   indexrP   	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   )rC   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'   keyr_   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<   rm   )r   r;   r<   CategoricalChoiceType)r   r   r<   r;   r=   r?   rB   )r8   rE   rF   rG   rW   r   r   r   r   r(   r   r/   r   r   r   r   r     s3    *&?U&.&  ((Hr   r   c                >   t        j                  |       }d|v rt|d   t        j                  k(  rt	        |d   d         |d   d<   t
        D ]!  }|d   |j                  k(  s |di |d   c S  t        dj                  |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j                  |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;   rC   rS   rT   rQ   rU   Fr;   )rU   rQ   r   rs   zUnknown distribution type: {}r   )jsonloadsr   r8   r,   DISTRIBUTION_CLASSESrP   r2   getrK   r   )json_str	json_dictclsrS   rT   rQ   rU   s          r   json_to_distributionr   B  sS    

8$IV 7 @ @@16y7Ny7Y1ZIl#I.' 	6C CLL05Y|455	6 9@@6ARSTT V-*9Y+?@@v"22E"CV$D==(D--u-C G+(d$GG <D&3TsNN8??	&@QRSSr   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+   r8   r!   )dists    r   distribution_to_jsonr   n  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+   rP   r$   rK   r   rU   r   r8   )dist_olddist_news     r    check_distribution_compatibilityr   |  s    $ X///]^^(.@A(%6$HIII<<8<<'abbh 78h 788#,,/WW
 	
 r   c                v   t        j                  t        |            }t        j                  t        |             }t        j                  t        |            }||z
  }||z  t        j                  d      k7  r>|}t        ||z  |z  |z         }t	        j
                  dj                  | |||             |S )N0The distribution is specified by [{low}, {old_high}] and step={step}, but the range is not divisible by `step`. It will be replaced by [{low}, {high}].rS   old_highrT   rQ   )rZ   r[   rD   r;   r   r   r2   )rS   rT   rQ   d_highd_lowd_stepd_rr   s           r   rR   rR     s    __SY'FOOCH%E__SY'F
5.C
V|ws++cVmv-56RRXRX(D SY S	
 Kr   c                    || z
  }||z  dk7  r5|}||z  |z  | z   }t        j                  dj                  | |||             |S )Nr   r   r   )r   r   r2   )rS   rT   rQ   rr   s        r   r   r     sc    s
A4x1}Dy4#%RRXRX(D SY S	
 Kr   c                    | j                         sJ t        | t        t        f      r| j                  S t        | t
              r| j                  d   S J r   )r   r$   rK   r   rS   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 )NFrs   Tz+ is deprecated and internally converted to z3. See https://github.com/optuna/optuna/issues/2941.)r$   rp   rK   rS   rT   r   r   r   r   r   rQ   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$   rK   r   rU   r   s    r   _is_distribution_logr     s!    ,!2O DEr   )r   r   r   r   r<   r>   )r   rD   r<   r   )r   r   r<   rD   )r   r   r   r   r<   rm   )rS   r;   rT   r;   rQ   r;   r<   r;   )rS   rC   rT   rC   rQ   rC   r<   rC   )r   r   r<   z#int | float | CategoricalChoiceType)F)r   r   r   r>   r<   r   )r   r   r<   r>   ).
__future__r   rH   collections.abcr   r{   rZ   r   numbersr   typingr   r   r   r   numpyrf   optuna._deprecatedr	   r>   rC   r;   rD   r   "_float_distribution_deprecated_msg _int_distribution_deprecated_msgABCr   rK   rp   r   r   r   r   r   r   r   r   r   r   r   rR   r   r   r   r   r   r   r   <module>r      s	   " 
 $          / dD#uc9:  D # $a  K@sww K@\`( `F '7)KL+  M4 '7)KL.  M4 '7)KL4"3 4 M4nZV& ZVz '7)IJ_  KB '7)IJ  K6
C!
C+@
C	
CP). P)h 	 )TXW#
#
*:#
	#
L(( #8"88 8vr   