
    -ji)                        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  S SKJr  S SKJr  Sr\" S5      SSS jj5       rSS jrSS jrg)    )annotations)experimental_func)Study)
TrialState)_get_timeline_info)_TimelineBarInfo)_TimelineInfo)_imports)Axes)DateFormatter)
matplotlib)plt
INFEASIBLEz3.2.0Nc                    Ub  US::  a  [        S5      e[        R                  " 5         [        X5      n[	        U5      $ )aP  Plot the timeline of a study.

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

Args:
    study:
        A :class:`~optuna.study.Study` object whose trials are plotted with
        their lifetime.
    n_recent_trials:
        The number of recent trials to plot. If :obj:`None`, all trials are plotted.
        If specified, only the most recent ``n_recent_trials`` will be displayed.
        Must be a positive integer.

Returns:
    A :class:`plotly.graph_objects.Figure` object.

Raises:
    ValueError: if ``n_recent_trials`` is 0 or negative.
r   z3n_recent_trials must be a positive integer or None.)
ValueErrorr
   checkr   _get_timeline_plot)studyn_recent_trialsinfos      c/home/james-whalen/.local/lib/python3.13/site-packages/optuna/visualization/matplotlib/_timeline.pyplot_timeliner      s<    . "!';NOONNe5Dd##    c                    U R                   [        R                  :X  a  U R                  (       a  [        $ U R                   R
                  $ N)stater   COMPLETE
infeasible_INFEASIBLE_KEYname)bar_infos    r   _get_state_namer"   5   s2    ~~,,,1D1D~~"""r   c                  ^
 [         R                  R                  S[         R                  R                  S[         R                  R                  S[
        S[         R                  R                  S[         R                  R                  S0n[        R                  R                  S5        [        R                  " 5       u  p#UR                  S5        UR                  S	5        UR                  S
5        [        U R                   5      S:X  a  U$ UR#                  U R                    Vs/ s H  oDR$                  PM     snU R                    Vs/ s H  oDR&                  UR(                  -
  PM     snU R                    Vs/ s H  oDR(                  PM     snU R                    Vs/ s H  oA[+        U5         PM     snS9  / nUR-                  5        HY  u  m
n[/        U
4S jU R                    5       5      (       d  M,  UR1                  [2        R4                  R7                  UT
S95        M[     UR9                  USSS9  UR;                  5         [        U R                   5      S:  d   e[=        U R                    Vs/ s H  oDR(                  PM     sn5      n[?        U R                    Vs/ s H  oDR&                  PM     sn5      nX-
  S-  n	URA                  X-   Xy-
  S9  URB                  RE                  [2        RF                  RI                  SS95        URJ                  RM                  [O        S5      5        [        RP                  " 5       RS                  5         U$ s  snf s  snf s  snf s  snf s  snf s  snf )Nztab:blueztab:redz
tab:orangez#CCCCCCz	tab:greenztab:grayggplotzTimeline PlotDatetimeTrialr   )ywidthleftcolorc              3  @   >#    U  H  n[        U5      T:H  v   M     g 7fr   )r"   ).0b
state_names     r   	<genexpr>%_get_timeline_plot.<locals>.<genexpr>^   s     CAq!Z/s   )r*   labelz
upper left)g?g      ?)handleslocbbox_to_anchorg?)rightr)   T)integerz%H:%M:%S)*r   r   r    FAILPRUNEDr   RUNNINGWAITINGr   styleusesubplots	set_title
set_xlabel
set_ylabellenbarsbarhnumbercompletestartr"   itemsanyappendr   patchesPatchlegendtight_layoutminmaxset_xlimyaxisset_major_locatortickerMaxNLocatorxaxisset_major_formatterr   gcfautofmt_xdate)r   _cmfigaxr-   legend_handlesr*   first_start_timelast_complete_timemarginr.   s             @r   r   r   <   s     *iC IIMM(llnGCLL!MM*MM'
499~	 GG!YY
'Y88Y
'-1YY7YzzAGG#Y7#yy)y!ggy)04		:	1?1%&	:	   N YY[
ECCCC!!*"4"4":":j":"YZ ) IIn,{IStyy>ATYY7YGGY78$))<)Qjj)<= 3t;F KK )&   HHz00<<T<JKHH  z!:;GGII; (7): 8<s$   )M$"M)
 M.%M3?M8.M=r   )r   r   r   z
int | Nonereturn'Axes')r!   r   r`   str)r   r	   r`   ra   )
__future__r   optuna._experimentalr   optuna.studyr   optuna.trialr   optuna.visualization._timeliner   r   r	   3optuna.visualization.matplotlib._matplotlib_importsr
   is_successfulr   r   r   r   r   r   r"   r    r   r   <module>rk      sd    " 2  # = ; 8 H HQNG  7$ $<#5r   