L i)ddlmZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z ddl m Z e jrdd l mZdd l mZdd l mZdd l mZd ZeddddZddZddZy)) annotations)experimental_func)Study) TrialState)_get_timeline_info)_TimelineBarInfo) _TimelineInfo)_imports)Axes) DateFormatter) matplotlib)plt INFEASIBLEz3.2.0Nc|||dkr tdtjt||}t |S)aPlot 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. rz3n_recent_trials must be a positive integer or None.) ValueErrorr checkr_get_timeline_plot)studyn_recent_trialsinfos o/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/optuna/visualization/matplotlib/_timeline.py plot_timeliners>."!';NOO NN e_ 5D d ##c|jtjk(r|jrtS|jj SN)staterCOMPLETE infeasible_INFEASIBLE_KEYname)bar_infos r_get_state_namer"5s2~~,,,1D1D~~"""rc  tjjdtjjdtjjdt dtj jdtjjdi}tjjdtj\}}|jd|jd |jd t|j d k(r|S|j#|j Dcgc]}|j$c}|j Dcgc]}|j&|j(z c}|j Dcgc]}|j(c}|j Dcgc]}|t+|c} g}|j-D]T\ }t/ fd |j Ds%|j1t2j4j7| V|j9|dd|j;t|j d kDsJt=|j Dcgc]}|j(c}}t?|j Dcgc]}|j&c}}||z dz} |jA|| z|| z |jBjEt2jFjId|jJjMtOdtjPjS|Scc}wcc}wcc}wcc}wcc}wcc}w)Nztab:blueztab:redz tab:orangez#CCCCCCz tab:greenztab:grayggplotz Timeline PlotDatetimeTrialr)ywidthleftcolorc3:K|]}t|k(ywr)r").0b state_names r z%_get_timeline_plot..^sCAq!Z/Cs)r*labelz upper left)g?g?)handleslocbbox_to_anchorg?)rightr)T)integerz%H:%M:%S)*rrr FAILPRUNEDrRUNNINGWAITINGrstyleusesubplots set_title set_xlabel set_ylabellenbarsbarhnumbercompletestartr"itemsanyappendr patchesPatchlegend tight_layoutminmaxset_xlimyaxisset_major_locatorticker MaxNLocatorxaxisset_major_formatterr gcf autofmt_xdate) r_cmfigaxr-legend_handlesr*first_start_timelast_complete_timemarginr.s @rrr<s  *i   CIIMM(llnGCLL!MM*MM' 499~ GG!YY '188 '-1YY7qzzAGG#7#yy )!agg )04 :1s?1%&:  N YY[[ E CC C  ! !*"4"4":":j":"Y Z[IIn,{IS tyy>A  TYY7AGG78$))rjsc"2#=;8H8HQNG7$$<#5r