
    Dik                       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j6                        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*d0d'Z+d1d(Z,	 d2	 	 	 	 	 d3d)Z-d4d*Z.y)5    )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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     Z/home/ubuntu/crypto_trading_bot/.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   ())joinr0   r$   r1   r.   __name__)r   kwargss     r   __repr__zBaseDistribution.__repr__h   sH    Q&9M9M9O2PQQ..))*!F8155r   N)r   floatreturnr   )r   r   rB   rA   rB   boolr   rA   rB   rD   rB   dictr*   r   rB   rD   )rB   int)rB   str)r>   
__module____qualname____doc__r   abcabstractmethodr   r   r    r$   r+   r2   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_highrA   lowhighlogr   r\   r]   r^   rZ   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)rZ   r\   r]   decimalDecimalrJ   )r   r]   r\   rZ   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>)rZ   r\   r]   absround)r   r   valuer8   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.rV   z)` is invalid value for the case log=True.rA   rY   	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)
r\   rA   r]   rA   r^   rD   rZ   zNone | floatrB   NonerC   rE   )r   rA   rB   rA   )r>   rK   rL   rM   r`   r   r    r   r   r   r   rQ   rQ   m   sK    < PT %,0@L	0	'Qr   rQ   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r\   r]   r^   rZ   superr`   r   r\   r]   r.   s      r   r`   zUniformDistribution.__init__       StTBr   c                    t        j                  | j                        }|j                  d       |j                  d       |S Nr^   rZ   copydeepcopyr#   popr   ds     r   r$   zUniformDistribution._asdict   /    MM$--(	e	fr   r\   rA   r]   rA   rB   rv   rF   r>   rK   rL   rM   r`   r$   __classcell__r.   s   @r   ry   ry      s    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``.

    c                ,    t         |   ||dd        y NTr|   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   rF   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r\   r]   rZ   r}   )r   r\   r]   qr.   s       r   r`   z$DiscreteUniformDistribution.__init__  s    St!4r   c                    t        j                  | j                        }|j                  d       |j                  d      }||d<   |S )Nr^   rZ   r   r   )r   r   rZ   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.
        rA   )r   rZ   r   s    r   r   zDiscreteUniformDistribution.q'  s     GTYY''r   c                    || _         y r"   )rZ   )r   r9   s     r   r   zDiscreteUniformDistribution.q1  s	    	r   )r\   rA   r]   rA   r   rA   rB   rv   rF   )rB   rA   )r9   rA   rB   rv   )
r>   rK   rL   rM   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.rS   rT   rU   z2`low >= 1` must hold for `log=True`, but got (low=r   rW   rX   )rY   r^   rI   rZ   r\   _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"   )rI   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rj   rm   rq   s       r   r   z IntDistribution.to_internal_reprm  rt   ru   c                    | j                   r| j                  | j                  k(  S | j                  | j                  k(  ry| j                  | j                  z
  | j                  k  S rb   )r^   r\   r]   rZ   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   rh   s      r   r    zIntDistribution._contains  s<    ,xx5-DII-U54883Ctyy2PTU2UUr   N)Fr   )
r\   rI   r]   rI   r^   rD   rZ   rI   rB   rv   )r   rA   rB   rI   )r   rI   rB   rA   rC   rE   )	r>   rK   rL   rM   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 r{   r}   r   r\   r]   rZ   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   r\   rI   r]   rI   rZ   rI   rB   rv   rF   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   rF   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   ro   rp   rA   )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 ]M  }|t        |t        t        t
        t        f      r'd| dt        |      j                   d}t        |       O 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 rX   )lenrY   r'   rD   rI   rA   rJ   r)   r>   r   r/   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   rI   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      )Nrk   z	' not in rX   )r   indexrY   	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   )rI   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#   keysr1   r   getattrzipr   )r   r*   keyrh   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]rB   rv   )r   rA   rB   CategoricalChoiceType)r   r   rB   rA   rC   rE   rH   )r>   rK   rL   rM   r`   r   r   r   r    r+   r   r2   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)rA   rI   r\   r]   rZ   r^   FrA   )r^   rZ   r   r|   zUnknown distribution type: r   )
jsonloadsr   r>   r/   DISTRIBUTION_CLASSESrY   getrQ   r   )json_str	json_dictclsr\   r]   rZ   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.   rY   r'   rQ   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                \   t        j                  t        |            }t        j                  t        |             }t        j                  t        |            }||z
  }||z  t        j                  d      k7  r1|}t        ||z  |z  |z         }t	        d|  d| d|d|  d| d       |S )N0"The distribution is specified by [r4   ] and step=F, but the range is not divisible by `step`. It will be replaced with [].)rc   rd   rJ   rA   r   )r\   r]   rZ   d_highd_lowd_stepd_rold_highs           r   r[   r[     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                p    || z
  }||z  dk7  r(|}||z  |z  | z   }t        d|  d| d|d|  d| d       |S )Nr   r   r4   r   r   r   r
   )r\   r]   rZ   rr   s        r   r   r     sj    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'   rQ   r   r\   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        |t               |S )NFr|   Tz+ is deprecated and internally converted to z3. See https://github.com/optuna/optuna/issues/2941.)r'   ry   rQ   r\   r]   r   r   r   r   r   rZ   r   r   FutureWarning)r   suppress_warningnew_distributionr   s       r   -_convert_old_distribution_to_new_distributionr     sE    , 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'   rQ   r   r^   r   s    r   _is_distribution_logr      s!    ,!2O DEr   )r   r   r   r   rB   rD   )r   rJ   rB   r   )r   r   rB   rJ   )r   r   r   r   rB   rv   )r\   rA   r]   rA   rZ   rA   rB   rA   )r\   rI   r]   rI   rZ   rI   rB   rI   )r   r   rB   z#int | float | CategoricalChoiceType)F)r   r   r   rD   rB   r   )r   r   rB   rD   )/
__future__r   rN   r   rc   r   ro   numbersr   typingr   r   r   r   optuna._deprecatedr	   optuna._warningsr   collections.abcr   rD   rI   rA   rJ   r   "_float_distribution_deprecated_msg _int_distribution_deprecated_msgABCr   rQ   ry   r   r   r   r   r   r   r   r   r   r   r   r[   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   