o
    /wi                     @  s   d dl m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Zd dl	m
Z
 erDd dlmZ d dlmZ ed	Zed
ZedZdZd!ddZd"ddZd#ddZ	d$d%ddZ	d$d&dd ZdS )'    )annotationsN)Any)TYPE_CHECKING)TypeVar)ExperimentalWarning)Callable)	ParamSpecFTFPCTz

.. note::
    Added in v{ver} as an experimental feature. The interface may change in newer versions
    without prior notice. See https://github.com/optuna/optuna/releases/tag/v{ver}.
option_namestrreturnNonec                 C  s   t d|  dt d S )NzArgument ``zF`` is an experimental feature. The interface can change in the future.)warningswarnr   )r    r   Q/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/optuna/_experimental.pywarn_experimental_argument   s   
r   versionc                 C  s.   t | trt| ddkrtd| d S )N.   zKInvalid version specification. Must follow `x.y.z` format but `{}` is given)
isinstancer   lensplit
ValueErrorformat)r   r   r   r   _validate_version'   s   r   	docstringc                 C  s   d| v r|  dd S dS )N
 )r   )r   r   r   r   _get_docstring_indent0   s   r"   name
str | None.Callable[[Callable[FP, FT]], Callable[FP, FT]]c                      t  d fdd}|S )zDecorate function as experimental.

    Args:
        version: The first version that supports the target feature.
        name: The name of the feature. Defaults to the function name. Optional.
    funcCallable[FP, FT]r   c                   sb    j d u rd _ tjd}t j } j  t|| |  _ t d
 fdd	}|S )Nr!   verargsr   kwargsr   r	   c                    s4   t jdd ur
n jtdd  | i |S NzP{} is experimental (supported from v{}). The interface can change in the future.   )
stacklevel)r   r   r   __name__r   )r+   r,   )r'   r#   r   r   r   wrapperI   s   	z5experimental_func.<locals>.decorator.<locals>.wrapper)r+   r   r,   r   r   r	   )	__doc___EXPERIMENTAL_NOTE_TEMPLATEr   r"   striptextwrapindent	functoolswraps)r'   noter6   r1   r#   r   )r'   r   	decoratorA   s   

z$experimental_func.<locals>.decoratorN)r'   r(   r   r(   r   r   r#   r;   r   r:   r   experimental_func4   s   r>   Callable[[CT], CT]c                   r&   )zDecorate class as experimental.

    Args:
        version: The first version that supports the target feature.
        name: The name of the feature. Defaults to the class name. Optional.
    clsr   r   c                   s   d fdd}|| S )Nr@   r   r   c                   s   t | d t | dt d fd	d
}t| d| | jdu r'd| _tjd}t| j}| j t	
|| | | _| S )zDecorates a class as experimental.

            This decorator is supposed to be applied to the experimental class.
            __init__r0   selfr   r+   r,   r   r   c                   s>   t jdd ur
ntdd  | g|R i | d S r-   )r   r   r   r   )rB   r+   r,   )_original_init_original_namer#   r   r   r   wrapped_initq   s   	zLexperimental_class.<locals>.decorator.<locals>.wrapper.<locals>.wrapped_initNr!   r)   )rB   r   r+   r   r,   r   r   r   )getattrr7   r8   setattrr2   r3   r   r"   r4   r5   r6   )r@   rE   r9   r6   r:   )rC   rD   r   r1   i   s   



z6experimental_class.<locals>.decorator.<locals>.wrapperr@   r   r   r   r   )r@   r1   r:   r   r   r;   h   s    z%experimental_class.<locals>.decoratorNrH   r<   r=   r   r:   r   experimental_class[   s   #rI   )r   r   r   r   )r   r   r   r   )r   r   r   r   )N)r   r   r#   r$   r   r%   )r   r   r#   r$   r   r?   )
__future__r   r7   r5   typingr   r   r   r   optuna.exceptionsr   collections.abcr   typing_extensionsr   r	   r
   r   r3   r   r   r"   r>   rI   r   r   r   r   <module>   s,    


	)