
    -ji                       S SK Jr  S SKJr  S SKJr  S SKrS SKJr  S SKJr  S SK	r
S SKrS SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S/r\R6                  R9                  \5      rSS jr\" 5       (       a$  S SK r!\!RD                  RF                  RH                  r%        SS jr&SS jr'SS jr(SS jr)      SS jr*  S       S S jjr+S!S jr,S"S jr-S#S jr.g)$    )annotations)Callable)SequenceN)Any)cast)optuna_warn)CategoricalDistribution)FloatDistribution)IntDistribution)Study)StudyDirection)FrozenTrial)_plotly_importsis_availablec                 >    [         R                  R                  5       $ )a  Returns whether visualization with plotly is available or not.

.. note::

    :mod:`~optuna.visualization` module depends on plotly version 4.0.0 or higher. If a
    supported version of plotly isn't installed in your environment, this function will return
    :obj:`False`. In such case, please execute ``$ pip install -U plotly>=4.0.0`` to install
    plotly.

Returns:
    :obj:`True` if visualization with plotly is available, :obj:`False` otherwise.
)r   _importsis_successful     U/home/james-whalen/.local/lib/python3.13/site-packages/optuna/visualization/_utils.pyr   r      s     ##1133r   c                    [        U [        5      (       a  U /nOU nUc"  [        S U 5       5      (       a  [        S5      eUb  US:X  a  [	        S5        g g g )Nc              3  @   #    U  H  oR                  5       v   M     g 7fN)_is_multi_objective).0studys     r   	<genexpr>#_check_plot_args.<locals>.<genexpr><   s     Owe7799ws   z[If the `study` is being used for multi-objective optimization, please specify the `target`.zObjective ValuezQ`target` is specified, but `target_name` is the default value, 'Objective Value'.)
isinstancer   any
ValueErrorr   )r   targettarget_namestudiess       r   _check_plot_argsr%   1   sg     %'~#OwOOO+
 	

 k->>_	
 ?r   c                    U  HL  nXR                   ;  a  M  UR                  U   n[        U[        [        45      =(       a    UR
                  s  $    g)NF)paramsdistributionsr   r
   r   logtrialsparamtrialdists       r   _is_log_scaler/   H   sJ    $""5)$!2O DER$((R	 
 r   c                    U  Hx  nXR                   ;  a  M  UR                  U   n[        U[        [        45      (       a    g[        U[
        5      (       a  [        S UR                   5       5      s  $  S5       e   g)NTc              3     #    U  H7  n[        U[        [        45      =(       a    [        U[        5      (       + v   M9     g 7fr   )r   intfloatbool)r   vs     r   r    _is_numerical.<locals>.<genexpr>Z   s1      Q]A
1sEl+GJq$4G0GGQ]s   ?AzShould not reach.)r'   r(   r   r   r
   r	   allchoicesr*   s       r   _is_numericalr9   Q   s    $""5)d_.?@AA566 QUQ]Q]   .--5  r   c                    U  Vs/ s H#  o!UR                   ;   d  M  UR                   U   PM%     nn[        X5      (       a  U$ [        [        [        U5      5      $ s  snf r   )r'   r9   listmapstr)r+   p_nametvaluess       r   _get_param_valuesrA   b   sS    (.E1AHH2DahhvFEV$$C !! Fs
   AAc                    [        5       nU  HG  nU H>  nXCR                  R                  5       ;  d  M"  UR                  UR                  5          ME     MI     U$ )av  Utility function for ``plot_parallel_coordinate``.

If trial's parameters do not contain a parameter in ``used_param_names``,
``plot_parallel_coordinate`` methods do not use such trials.

Args:
    trials:
        List of ``FrozenTrial``s.
    used_param_names:
        The parameter names used in ``plot_parallel_coordinate``.

Returns:
    A set of invalid trial numbers.
)setr'   keysaddnumber)r+   used_param_namesskipped_trial_numbersr-   
used_params        r   _get_skipped_trial_numbersrJ   i   sP    $  E*J!2!2!44%))%,,7 + 
 ! r   c           
        Uc  SS jnUn/ nU  Hq  nU" U5      n [        U5      n[        R                  " U5      (       d.  U(       a%  [        R                  SUR                   S35        M^  M`  UR                  U5        Ms     U$ ! [        [        4 a'    [        SUR                   S[        U5       S35        e f = f)Nc                6    [        [        U R                  5      $ r   )r   r3   value)r?   s    r   _target"_filter_nonfinite.<locals>._target   s    qww''r   Trialz's target value z could not be cast to float.zTrial zG is omitted in visualization because its objective value is inf or nan.)r?   r   returnr3   )r3   r!   	TypeErrorr   rF   reprnpisfinite_loggerwarningappend)r+   r"   with_messagerN   filtered_trialsr-   rM   s          r   _filter_nonfiniter[      s     ~	( )+Ou		%LE {{5!!U\\N +A A  ""5)- 0 % 
 	 ~%5d5k]B^_ 	s   B7B=c                R    US L=(       d    U R                   [        R                  :H  $ r   )	directionr   MINIMIZE)r   r"   s     r   _is_reverse_scaler_      s!    KN4K4K!KKr   c                j     [         R                  " U 5        U $ ! [         a    [        U 5      s $ f = fr   )jsondumpsrR   r=   )rM   s    r   _make_json_compatiblerc      s1    

5 5zs    22c                .   U R                   R                  5        VVs0 s H  u  pU[        U5      _M     nnnU(       a  SU0O0 n[        R                  " U R
                  U R                  U R                  S.UESS9nUR                  SS5      $ s  snnf )N
user_attrs)rF   r@   r'      )indent
z<br>)	re   itemsrc   ra   rb   rF   r@   r'   replace)r-   keyrM   re   user_attrs_dicttexts         r   _make_hovertextrn      s    FKFVFVF\F\F^_F^
#,U33F^J_4>|Z0BO::llllll	
 		
 D <<f%% `s   B)rQ   r4   )r   zStudy | Sequence[Study]r"   %Callable[[FrozenTrial], float] | Noner#   r=   rQ   None)r+   list[FrozenTrial]r,   r=   rQ   r4   )r+   rq   r>   r=   rQ   z	list[Any])r+   rq   rG   zSequence[str]rQ   zset[int])NT)r+   rq   r"   ro   rY   r4   rQ   rq   )r   r   r"   ro   rQ   r4   )rM   r   rQ   r   )r-   r   rQ   r=   )/
__future__r   collections.abcr   r   ra   typingr   r   numpyrT   optunaoptuna._warningsr   optuna.distributionsr	   r
   r   optuna.studyr   optuna.study._study_directionr   optuna.trialr   optuna.visualizationr   __all__logging
get_logger__name__rV   r   plotly.colorsplotlycolors
sequentialBluesCOLOR_SCALEr%   r/   r9   rA   rJ   r[   r_   rc   rn   r   r   r   <module>r      s   " $ $      ( 8 2 0  8 $ 0 

..
#
#H
-4" >>--**00K
"
1
 
 
	
.""!!1>!!: 59))1) ) 	)XL&r   