
    Q-j,k                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 d dl	mZ d dl	mZ d dl	mZ d dlmZ d d	lmZ erd d
lmZ edeeeef   ZdZdZ G d de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*d/d'Z+d0d(Z,	 d1	 	 	 	 	 d2d)Z-y)3    )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     b/Users/jameslopez/projects/TradingBot25/.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!     Q2P$!QaS!:2Ps   ())joinr/   r$   r0   r-   __name__)r   kwargss     r   __repr__zBaseDistribution.__repr__h   sH    Q&9M9M9O2PQQ..))*!F8155r   N)r   floatreturnr   )r   r   rA   r@   rA   boolr   r@   rA   rC   rA   dictr)   r   rA   rC   )rA   int)rA   str)r=   
__module____qualname____doc__r   abcabstractmethodr   r   r    r$   r*   r1   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   r[   r\   r]   rY   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)rY   r[   r\   decimalDecimalrI   )r   r\   r[   rY   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>)rY   r[   r\   absround)r   r   valuer7   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.rU   z)` is invalid value for the case log=True.r@   rX   	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[   r@   r\   r@   r]   rC   rY   zNone | floatrA   NonerB   rD   )r   r@   rA   r@   )r=   rJ   rK   rL   r_   r   r    r   r   r   r   rP   rP   m   sK    < PT %,0@L	0	'Qr   rP   z3.0.0z6.0.0)textc                  ,     e Zd ZdZd fdZddZ xZS )UniformDistributiona  A uniform distribution in the linear domain.

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

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

    c                ,    t         |   ||dd        y NFr[   r\   r]   rY   superr_   r   r[   r\   r-   s      r   r_   zUniformDistribution.__init__       StTBr   c                    t        j                  | j                        }|j                  d       |j                  d       |S Nr]   rY   copydeepcopyr#   popr   ds     r   r$   zUniformDistribution._asdict   /    MM$--(	e	fr   r[   r@   r\   r@   rA   ru   rE   r=   rJ   rK   rL   r_   r$   __classcell__r-   s   @r   rx   rx      s    Cr   rx   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   rE   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\   rY   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]   rY   r   r   )r   r   rY   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   rY   r   s    r   r   zDiscreteUniformDistribution.q'  s     GTYY''r   c                    || _         y r"   )rY   )r   r8   s     r   r   zDiscreteUniformDistribution.q1  s	    	r   )r[   r@   r\   r@   r   r@   rA   ru   rE   )rA   r@   )r8   r@   rA   ru   )
r=   rJ   rK   rL   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.rR   rS   rT   z2`low >= 1` must hold for `log=True`, but got (low=r   rV   rW   )rX   r]   rH   rY   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"   )rH   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ri   rl   rp   s       r   r   z IntDistribution.to_internal_reprm  rs   rt   c                    | j                   r| j                  | j                  k(  S | j                  | j                  k(  ry| j                  | j                  z
  | j                  k  S ra   )r]   r[   r\   rY   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   rg   s      r   r    zIntDistribution._contains  s<    ,xx5-DII-U54883Ctyy2PTU2UUr   N)Fr   )
r[   rH   r\   rH   r]   rC   rY   rH   rA   ru   )r   r@   rA   rH   )r   rH   rA   r@   rB   rD   )	r=   rJ   rK   rL   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 rz   r|   r   r[   r\   rY   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[   rH   r\   rH   rY   rH   rA   ru   rE   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   rE   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   rn   ro   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 ]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 rW   )lenrX   r&   rC   rH   r@   rI   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   rH   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      )Nrj   z	' not in rW   )r   indexrX   	enumerater   )r   r   r   r   s       r   r   z(CategoricalDistribution.to_internal_repr  sx    
	!
 <<%%&BCC 	!!*4<<!8v,-I6R L "9	! 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   )rH   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#   keysr0   r   getattrzipr   )r   r)   keyrg   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$ -L GE3//  0 r   N)r   zSequence[CategoricalChoiceType]rA   ru   )r   r@   rA   CategoricalChoiceType)r   r   rA   r@   rB   rD   rG   )r=   rJ   rK   rL   r_   r   r   r   r    r*   r   r1   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@   rH   r[   r\   rY   r]   Fr@   )r]   rY   r   r{   zUnknown distribution type: r   )
jsonloadsr   r=   r.   DISTRIBUTION_CLASSESrX   getrP   r   )json_str	json_dictclsr[   r\   rY   r]   s          r   json_to_distributionr   5  sH    

8$IV 7 @ @@16y7Ny7Y1ZIl#I.'C CLL05Y|455 ( 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-   rX   r&   rP   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 [r3   ] and step=F, but the range is not divisible by `step`. It will be replaced with [].)rb   rc   rI   r@   r   )r[   r\   rY   d_highd_lowd_stepd_rold_highs           r   rZ   rZ     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   r3   r   r   r   r
   )r[   r\   rY   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&   rP   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&   rx   rP   r[   r\   r   r   r   r   r   rY   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   )r   r   r   r   rA   rC   )r   rI   rA   r   )r   r   rA   rI   )r   r   r   r   rA   ru   )r[   r@   r\   r@   rY   r@   rA   r@   )r[   rH   r\   rH   rY   rH   rA   rH   )r   r   rA   z#int | float | CategoricalChoiceType)F)r   r   r   rC   rA   r   ).
__future__r   rM   r   rb   r   rn   numbersr   typingr   r   r   r   optuna._deprecatedr	   optuna._warningsr   collections.abcr   rC   rH   r@   rI   r   "_float_distribution_deprecated_msg _int_distribution_deprecated_msgABCr   rP   rx   r   r   r   r   r   r   r   r   r   r   r   rZ   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r   