o
    tf:                     @   sT  d Z ddlmZmZmZmZmZmZmZm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ ddlmZmZ ddlmZ dd	lmZmZ G d
d deeeZG dd deZG dd deZeG dd deZeG dd deZeG dd deZeG dd deZ eG dd deZ!G dd deZ"G dd de"Z#eG dd de#Z$d S )!z<Float class.

Represents an unbounded float using a widget.
    )	InstanceUnicodeCFloatBoolCaselessStrEnumTuple
TraitErrorvalidatedefault   )DescriptionWidget)InstanceDictNumberFormat)ValueWidget)registerwidget_serialization)
CoreWidget)ProgressStyleSliderStylec                       s2   e Zd ZedddjddZd	 fdd	Z  ZS )
_Float        Float valuehelpTsyncNc                    s&   |d ur||d< t  jdi | d S )Nvalue )super__init__)selfr   kwargs	__class__r   h/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/ipywidgets/widgets/widget_float.pyr      s   z_Float.__init__N)__name__
__module____qualname__r   tagr   r   __classcell__r   r   r"   r$   r      s    r   c                   @   sd   e Zd ZedddjddZedddjddZedd	d
 Zeddd Z	eddd Z
dS )_BoundedFloat      Y@	Max valuer   Tr   r   	Min valuer   c                 C   s4   |d }| j |ks| j|k rt t|| j | j}|S zCap and floor valuer   )minmaxr    proposalr   r   r   r$   _validate_value!   s   z_BoundedFloat._validate_valuer0   c                 C   s.   |d }|| j krtd|| jkr|| _|S )Enforce min <= value <= maxr   Setting min > max)r1   r   r   r    r3   r0   r   r   r$   _validate_min)      

z_BoundedFloat._validate_minr1   c                 C   s.   |d }|| j k rtd|| jk r|| _|S )r5   r   setting max < min)r0   r   r   r    r3   r1   r   r   r$   _validate_max3   r9   z_BoundedFloat._validate_maxN)r&   r'   r(   r   r)   r1   r0   r	   r4   r8   r<   r   r   r   r$   r+      s    

	r+   c                   @   s   e Zd ZedddjddZedddjddZedd	djddZed
ddjddZe	ddd Z
e	ddd Ze	ddd ZdS )_BoundedLogFloatg      @zMax value for the exponentr   Tr   r   zMin value for the exponent      $@zBase of value      ?r   r   c                 C   sL   |d }| j | j |ks| j | j |k r$tt|| j | j | j | j }|S r/   )baser0   r1   r2   r   r   r$   r4   C   s     z _BoundedLogFloat._validate_valuer0   c                 C   s:   |d }|| j krtd| j| | jkr| j| | _|S )+Enforce base ** min <= value <= base ** maxr   r6   )r1   r   r@   r   r7   r   r   r$   r8   K      
z_BoundedLogFloat._validate_minr1   c                 C   s:   |d }|| j k rtd| j| | jk r| j| | _|S )rA   r   r:   )r0   r   r@   r   r;   r   r   r$   r<   U   rB   z_BoundedLogFloat._validate_maxN)r&   r'   r(   r   r)   r1   r0   r@   r   r	   r4   r8   r<   r   r   r   r$   r=   =   s    

	r=   c                   @   n   e Zd ZdZedjddZedjddZedddjddZ	edd	djddZ
ed
dddjddZd
S )	FloatTextaj   Displays a float value within a textbox. For a textbox in
    which the value must be within a specific range, use BoundedFloatText.

    Parameters
    ----------
    value : float
        value displayed
    step : float
        step of the increment (if None, any step is allowed)
    description : str
        description displayed next to the text box
    FloatTextViewTr   ZFloatTextModelFEnable or disable user changesr   lUpdate the value as the user types. If False, update on submission, e.g., pressing Enter or navigating away.N#Minimum step to increment the value
allow_noner   r&   r'   r(   __doc__r   r)   
_view_name_model_namer   disabledcontinuous_updater   stepr   r   r   r$   rD   `   s    rD   c                   @   rC   )BoundedFloatTexta8   Displays a float value within a textbox. Value must be within the range specified.

    For a textbox in which the value doesn't need to be within a specific range, use FloatText.

    Parameters
    ----------
    value : float
        value displayed
    min : float
        minimal value of the range of possible values displayed
    max : float
        maximal value of the range of possible values displayed
    step : float
        step of the increment (if None, any step is allowed)
    description : str
        description displayed next to the textbox
    rE   Tr   ZBoundedFloatTextModelFrF   r   rG   NrH   rI   rK   r   r   r   r$   rR   u   s    rR   c                   @      e Zd ZdZedjddZedjddZeddddjddZ	e
d	d
gd	ddjddZedddjddZedddjddZedddjddZedddjddZeejdddieZe
g ddddjddZdS )FloatSlideras   Slider/trackbar of floating values with the specified range.

    Parameters
    ----------
    value : float
        position of the slider
    min : float
        minimal position of the slider
    max : float
        maximal position of the slider
    step : float
        step of the trackbar
    description : str
        name of the slider
    orientation : {'horizontal', 'vertical'}
        default is 'horizontal', orientation of the slider
    readout : {True, False}
        default is True, display the current value of the slider next to it
    behavior : str
        slider handle and connector dragging behavior. Default is 'drag-tap'.
    readout_format : str
        default is '.2f', specifier for the format function used to represent
        slider value for human consumption, modeled after Python 3's format
        specification mini-language (PEP 3101).
    ZFloatSliderViewTr   ZFloatSliderModel皙?rH   rI   
horizontalverticalVertical or horizontal.valuesdefault_valuer   3Display the current value of the slider next to it.r   .2fFormat for the readoutAUpdate the value of the widget as the user is holding the slider.FrF   r   drag-tapz	drag-snaptapZdragZsnapra   Slider dragging behavior.Nr   r&   r'   r(   rL   r   r)   rM   rN   r   rQ   r   orientationr   readoutr   readout_formatrP   rO   r   r   r   stylebehaviorr   r   r   r$   rT      0    
rT   c                   @   s   e Zd ZdZedjddZedjddZeddddjddZ	e
d	d
gd	ddjddZedddjddZedddjddZedddjddZedddjddZedddjddZeejdddieZe
g ddddjddZdS )FloatLogSlidera_   Slider/trackbar of logarithmic floating values with the specified range.

    Parameters
    ----------
    value : float
        position of the slider
    base : float
        base of the logarithmic scale. Default is 10
    min : float
        minimal position of the slider in log scale, i.e., actual minimum is base ** min
    max : float
        maximal position of the slider in log scale, i.e., actual maximum is base ** max
    step : float
        step of the trackbar, denotes steps for the exponent, not the actual value
    description : str
        name of the slider
    orientation : {'horizontal', 'vertical'}
        default is 'horizontal', orientation of the slider
    readout : {True, False}
        default is True, display the current value of the slider next to it
    behavior : str
        slider handle and connector dragging behavior. Default is 'drag-tap'.
    readout_format : str
        default is '.3g', specifier for the format function used to represent
        slider value for human consumption, modeled after Python 3's format
        specification mini-language (PEP 3101).
    ZFloatLogSliderViewTr   ZFloatLogSliderModelrU   z3Minimum step in the exponent to increment the valuerI   rV   rW   rX   rY   r\   r   z.3gr^   r_   FrF   r>   zBase for the logarithmr   r`   ra   rc   Nr   )r&   r'   r(   rL   r   r)   rM   rN   r   rQ   r   re   r   rf   r   rg   rP   rO   r@   r   r   r   rh   ri   r   r   r   r$   rk      s2    
rk   c                   @   s~   e Zd ZdZedjddZedjddZeddgddd	jddZ	eg d
ddddjddZ
eejdddieZdS )FloatProgressad   Displays a progress bar.

    Parameters
    -----------
    value : float
        position within the range of the progress bar
    min : float
        minimal position of the slider
    max : float
        maximal position of the slider
    description : str
        name of the progress bar
    orientation : {'horizontal', 'vertical'}
        default is 'horizontal', orientation of the progress bar
    bar_style: {'success', 'info', 'warning', 'danger', ''}
        color of the progress bar, default is '' (blue)
        colors are: 'success'-green, 'info'-light blue, 'warning'-orange, 'danger'-red
    ZProgressViewTr   ZFloatProgressModelrV   rW   rX   rY   )successinfowarningZdanger rp   z.Use a predefined styling for the progress bar.)rZ   r[   rJ   r   r   Nr   )r&   r'   r(   rL   r   r)   rM   rN   r   re   Z	bar_styler   r   r   rh   r   r   r   r$   rl      s"    rl   c                   @   sl   e Zd Zee e dddjddZedd Zej	dd Zed	d
 Z
e
j	dd
 Z
eddd ZdS )_FloatRange)r   r?   zTuple of (lower, upper) bounds)r[   r   Tr   c                 C   
   | j d S Nr   r   r    r   r   r$   lower
     
z_FloatRange.lowerc                 C   s   || j d f| _ d S Nr   rt   )r    rv   r   r   r$   rv        c                 C   rr   rx   rt   ru   r   r   r$   upper  rw   z_FloatRange.upperc                 C   s   | j d |f| _ d S rs   rt   )r    rz   r   r   r$   rz     ry   r   c                 C   s$   |d \}}||k rt d||fS )Nr   zsetting lower > upper)r   r    r3   rv   rz   r   r   r$   r4     s   z_FloatRange._validate_valueN)r&   r'   r(   r   r   r)   r   propertyrv   setterrz   r	   r4   r   r   r   r$   rq     s     



rq   c                       s~   e Zd ZedddjddZedddjddZedd	djddZ fd
dZe	dddd Z
e	d fddZ  ZS )_BoundedFloatRanger?   z<Minimum step that the value can take (ignored by some views)r   Tr   r,   r-   r   r.   c              	      s   | dd| dd}}| dd d u r(d| d|  d| d|  f|d< n t|d tsHz
t|d |d< W n   tdt|d t j|i | d S )	Nr0   r   r1   r,   r   g      ?g      ?z_A 'range' must be able to be cast to a tuple. The input of type {} could not be cast to a tuple)get
isinstancetuple	TypeErrorformattyper   r   )r    argsr!   r0   r1   r"   r   r$   r   '  s   
z_BoundedFloatRange.__init__r0   r1   c                 C   s   |d }|d }|j dkr|| jkrtd|j dkr$|| jk r$td|j dkr:t|| jd t|| jd f| _|j dkrPt|| jd t|| jd f| _|S )	Ntraitr   r0   zsetting min > maxr1   r:   r   r   )namer1   r   r0   r   )r    r3   r   newr   r   r$   _validate_bounds6  s   
"
"z#_BoundedFloatRange._validate_boundsr   c                    sL   t  |\}}t|| jt|| j}}t|| jt|| j}}||fS r%   )r   r4   r0   r1   r{   r"   r   r$   r4   D  s   z"_BoundedFloatRange._validate_value)r&   r'   r(   r   r)   rQ   r1   r0   r   r	   r   r4   r*   r   r   r"   r$   r~   "  s    
r~   c                   @   rS   )FloatRangeSlidera   Slider/trackbar that represents a pair of floats bounded by minimum and maximum value.

    Parameters
    ----------
    value : float tuple
        range of the slider displayed
    min : float
        minimal position of the slider
    max : float
        maximal position of the slider
    step : float
        step of the trackbar
    description : str
        name of the slider
    orientation : {'horizontal', 'vertical'}
        default is 'horizontal'
    readout : {True, False}
        default is True, display the current value of the slider next to it
    behavior : str
        slider handle and connector dragging behavior. Default is 'drag-tap'.
    readout_format : str
        default is '.2f', specifier for the format function used to represent
        slider value for human consumption, modeled after Python 3's format
        specification mini-language (PEP 3101).
    ZFloatRangeSliderViewTr   ZFloatRangeSliderModelrU   rH   rI   rV   rW   rX   rY   r\   r   r]   r^   zAUpdate the value of the widget as the user is sliding the slider.FrF   r   r`   ra   rc   Nr   rd   r   r   r   r$   r   L  rj   r   N)%rL   Z	traitletsr   r   r   r   r   r   r   r	   r
   Zwidget_descriptionr   Ztrait_typesr   r   Zvaluewidgetr   Zwidgetr   r   Zwidget_corer   Z
widget_intr   r   r   r+   r=   rD   rR   rT   rk   rl   rq   r~   r   r   r   r   r$   <module>   s2    ,	 #), *