
    -ji                    8   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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  \R*                  " 5       (       a  S SKJr  S SKJr  \
" \5      r\" S5      SSSS.         SS jj5       r      SS jrg)    )annotations)Callable)SequenceN)experimental_func)
get_logger)Study)FrozenTrial)#_get_optimization_history_info_list)_OptimizationHistoryInfo)_ValueState)_imports)Axes)pltz2.2.0zObjective ValueF)targettarget_name	error_barc               Z    [         R                  " 5         [        XX#5      n[        XB5      $ )ak  Plot optimization history of all trials in a study with Matplotlib.

.. seealso::
    Please refer to :func:`optuna.visualization.plot_optimization_history` for an example.

Args:
    study:
        A :class:`~optuna.study.Study` object whose trials are plotted for their target values.
        You can pass multiple studies if you want to compare those optimization histories.

    target:
        A function to specify the value to display. If it is :obj:`None` and ``study`` is being
        used for single-objective optimization, the objective values are plotted.

        .. note::
            Specify this argument if ``study`` is being used for multi-objective optimization.
    target_name:
        Target's name to display on the axis label and the legend.

    error_bar:
        A flag to show the error bar.

Returns:
    A :class:`matplotlib.axes.Axes` object.
)r   checkr
   _get_optimization_history_plot)studyr   r   r   	info_lists        o/home/james-whalen/.local/lib/python3.13/site-packages/optuna/visualization/matplotlib/_optimization_history.pyplot_optimization_historyr      s&    D NN3E;ZI))AA    c           
        [         R                  R                  S5        [         R                  " SS9u  p#UR	                  S5        UR                  S5        UR                  U5        [         R                  " S5      n[        U 5       GH  u  nu  pgnUR                  b  [        R                  UR                  ;   d  [        R                  UR                  ;   a  [        R                  S5        Un	UR                   n
[         R"                  " U	U
UR                  SS	S
S9  / n/ nO[%        XgR                  5       VVs/ s H  u  pU[        R&                  :X  d  M  UPM     n	nn[%        XgR                  5       VVs/ s H  u  pU[        R                  :X  d  M  UPM     nnn/ n
U	 H!  nU
R)                  UR                   U   5        M#     / nU H!  nUR)                  UR                   U   5        M#     UR+                  U	U
[-        U 5      S:X  a  U" S5      O
U" SU-  5      SUR.                  S9  Ub  UR1                  UUR                   [-        U 5      S:X  a  U" S5      OU" SU-  S-   5      SUR.                  S9  UR                  b  [2        R4                  " UR                   5      [2        R4                  " UR                  5      -
  n[2        R4                  " UR                   5      [2        R4                  " UR                  5      -   nUR7                  UUUSSS9  UR9                  5         UR+                  UUSS9  GM     [         R8                  " SSS9  U$ s  snnf s  snnf )NggplotT)tight_layoutzOptimization History PlotTrialtab10z~Your study contains infeasible trials. In optimization history plot, error bars are calculated for only feasible trial values.   oztab:blue)xyyerrcapsizefmtcolor   r      )r"   r#   r'   alphalabel   g      ?)r'   r*   r+   ztab:redg?)r"   y1y2r'   r*   z#cccccc)r"   r#   r'   )g?g      ?z
upper left)bbox_to_anchorloc)r   styleusesubplots	set_title
set_xlabel
set_ylabelget_cmap	enumeratestdsr   
Infeasiblestates
Incomplete_loggerwarningvalueserrorbarzipFeasibleappendscatterlen
label_nameplotnparrayfill_betweenlegend)r   r   _axcmapitrial_numbersvalues_infobest_values_infofeasible_trial_numbersfeasible_trial_valuesinfeasible_trial_numbersinfeasible_trial_valuesnsnumloweruppers                     r   r   r   A   s   
 IIMM(LLd+EALL,-MM'MM+<< D=Fy=Q99M(8'&&+*<*<<))[-?-??P
 &3"$/$6$6!LL(' %%  35$35# "-1C1CD&Dda[MaMaHaD # & "-1C1CD(Dda[McMcHcD % ( %'!-%,,[-?-?-DE .&(#/'..{/A/A#/FG 0


$# ^q0$q'd1q5k(( 	 	
 'GG ''!$Y1!4d1g$q1uqy/&11    $$0!1!8!89BHHEUEZEZ<[[!1!8!89BHHEUEZEZ<[[##    IIK


&% 	 	
 >RH JJk|<I[&(s    M!M!?M'M')
r   zStudy | Sequence[Study]r   z%Callable[[FrozenTrial], float] | Noner   strr   boolreturn'Axes')r   zlist[_OptimizationHistoryInfo]r   r\   r^   r_   )
__future__r   collections.abcr   r   numpyrH   optuna._experimentalr   optuna.loggingr   optuna.studyr   optuna.trialr	   *optuna.visualization._optimization_historyr
   r   r   3optuna.visualization.matplotlib._matplotlib_importsr   is_successfulr   r   __name__r=   r   r    r   r   <module>rl      s    " $ $  2 %  $ Z O B H HG
X
 7 59($B"$B 2$B 	$B
 $B $B $BNQ-QQ Qr   