
    bi:                        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eee      Z G d de      Z G d de      Ze G d de             Ze G d de             Ze G d de             Ze G d de             Z e G d de             Z! G d de      Z" G d de"      Z#e G d de#             Z$y )!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                   T     e Zd Z edd      j	                  d      Zd fd	Z xZS )_Float        Float valuehelpTsyncc                 2    |||d<   t        |   di | y )Nvalue )super__init__)selfr   kwargs	__class__s      Z/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/ipywidgets/widgets/widget_float.pyr"   z_Float.__init__   s"    #F7O"6"    N)__name__
__module____qualname__r   tagr   r"   __classcell__r%   s   @r&   r   r      s'    3]+//T/:E# #r'   r   c                       e Zd Z edd      j	                  d      Z edd      j	                  d      Z ed      d	        Z ed
      d        Z	 ed      d        Z
y)_BoundedFloat      Y@	Max valuer   Tr   r   	Min valuer   c                     |d   }| j                   |kD  s| j                  |k  r*t        t        || j                         | j                        }|S zCap and floor valuer   )minmaxr#   proposalr   s      r&   _validate_valuez_BoundedFloat._validate_value!   sE     !88etxx%/E488,dhh7Er'   r6   c                 p    |d   }|| j                   kD  rt        d      || j                  kD  r|| _        |S )Enforce min <= value <= maxr   Setting min > max)r7   r	   r   r#   r9   r6   s      r&   _validate_minz_BoundedFloat._validate_min)   =     w>011DJ
r'   r7   c                 p    |d   }|| j                   k  rt        d      || j                  k  r|| _        |S )r<   r   setting max < min)r6   r	   r   r#   r9   r7   s      r&   _validate_maxz_BoundedFloat._validate_max3   r@   r'   N)r)   r*   r+   r   r,   r7   r6   r
   r:   r?   rD   r    r'   r&   r0   r0      s}    
[
)
-
-4
-
8C
;
'
+
+
+
6Cg  e_  e_ r'   r0   c                   0   e Zd Z edd      j	                  d      Z edd      j	                  d      Z edd	      j	                  d      Z ed
d      j	                  d      Z e	d      d        Z
 e	d      d        Z e	d      d        Zy)_BoundedLogFloatg      @zMax value for the exponentr   Tr   r   zMin value for the exponent      $@zBase of value      ?r   r   c                    |d   }| j                   | j                  z  |kD  s| j                   | j                  z  |k  rDt        t        || j                   | j                  z        | j                   | j                  z        }|S r5   )baser6   r7   r8   s      r&   r:   z _BoundedLogFloat._validate_valueC   si     !99 5(DII,AE,IE499#9:DII$((<RSEr'   r6   c                     |d   }|| j                   kD  rt        d      | j                  |z  | j                  kD  r| j                  |z  | _        |S )+Enforce base ** min <= value <= base ** maxr   r=   )r7   r	   rJ   r   r>   s      r&   r?   z_BoundedLogFloat._validate_minK   O     w>01199djj(c)DJ
r'   r7   c                     |d   }|| j                   k  rt        d      | j                  |z  | j                  k  r| j                  |z  | _        |S )rL   r   rB   )r6   r	   rJ   r   rC   s      r&   rD   z_BoundedLogFloat._validate_maxU   rM   r'   N)r)   r*   r+   r   r,   r7   r6   rJ   r   r
   r:   r?   rD   r    r'   r&   rF   rF   =   s    
7
8
<
<$
<
GC
7
8
<
<$
<
GC$_-11t1<D3]+//T/:Eg  e_  e_ r'   rF   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z edd      j                  d      Z	 edd	      j                  d      Z
 ed
dd      j                  d      Zy
)	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   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&   rP   rP   `   s     )--4-8J*+//T/:KE @AEE4EPHU  *X  Y  ]  ]  cg  ]  h$4.STXX^bXcDr'   rP   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z edd      j                  d      Z	 edd	      j                  d      Z
 ed
dd      j                  d      Zy
)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
    rQ   Tr   BoundedFloatTextModelFrS   r   rT   NrU   rV   rX   r    r'   r&   r`   r`   u   s    " )--4-8J1266D6AKE @AEE4EPHU  *X  Y  ]  ]  cg  ]  h$4.STXX^bXcDr'   r`   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z eddd      j                  d      Z	 e
d	d
gd	d      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z  ee      j
                  dddieZ e
g ddd      j                  d      Zy)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).
    FloatSliderViewTr   FloatSliderModel皙?rU   rV   
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.FrS   r   drag-tapz	drag-snaptapdragsnaprr   Slider dragging behavior.Nr    r)   r*   r+   rY   r   r,   rZ   r[   r   r^   r   orientationr   readoutr   readout_formatr]   r\   r   r   r   stylebehaviorr    r'   r&   rc   rc      s3   2 *+//T/:J,-11t1<K#$-RSWW]aWbD!,
)C")BDDGCTCN 4STXX^bXcG!,..1ctcn T(klppvzp{E @AEE4EPH)L%))LtL7KLE&V 'BDDGCTCN r'   rc   c                   R   e Zd ZdZ ed      j                  d      Z ed      j                  d      Z eddd      j                  d      Z	 e
d	d
gd	d      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z  ee      j
                  dddieZ e
g ddd      j                  d      Zy)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).
    FloatLogSliderViewTr   FloatLogSliderModelrf   z3Minimum step in the exponent to increment the valuerV   rg   rh   ri   rj   rm   r   z.3gro   rp   FrS   rG   zBase for the logarithmr   rq   rr   rv   Nr    )r)   r*   r+   rY   r   r,   rZ   r[   r   r^   r   rx   r   ry   r   rz   r]   r\   rJ   r   r   r   r{   r|   r    r'   r&   r~   r~      sN   6 -.222=J/044$4?K#$-bcggmqgrD!,
)C")BDDGCTCN 4STXX^bXcG!,..1ctcn T(klppvzp{E @AEE4EPH#4599t9DD)L%))LtL7KLE&V 'BDDGCTCN r'   r~   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z eddgdd	      j                  d      Z	 eg d
ddd      j                  d      Z
  ee      j
                  dddieZy)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
    ProgressViewTr   FloatProgressModelrg   rh   ri   rj   )successinfowarningdanger r   z.Use a predefined styling for the progress bar.)rk   rl   rW   r   r   Nr    )r)   r*   r+   rY   r   r,   rZ   r[   r   rx   	bar_styler   r   r   r{   r    r'   r&   r   r      s    $ (,,$,7J./333>K!,
)C")BDDGCTCN   ;T=? @Css~ 
 ,L'++NN9MNEr'   r   c                       e Zd Z e e        e       dd      j                  d      Zed        Zej                  d        Zed        Z
e
j                  d	        Z
 ed
      d        Zy)_FloatRange)r   rH   zTuple of (lower, upper) bounds)rl   r   Tr   c                      | j                   d   S Nr   r   r#   s    r&   lowerz_FloatRange.lower
      zz!}r'   c                 0    || j                   d   f| _         y Nr   r   )r#   r   s     r&   r   z_FloatRange.lower  s    TZZ]+
r'   c                      | j                   d   S r   r   r   s    r&   upperz_FloatRange.upper  r   r'   c                 0    | j                   d   |f| _         y r   r   )r#   r   s     r&   r   z_FloatRange.upper  s    jjmU+
r'   r   c                 :    |d   \  }}||k  rt        d      ||fS )Nr   zsetting lower > upper)r	   )r#   r9   r   r   s       r&   r:   z_FloatRange._validate_value  s-    (u5=455e|r'   N)r)   r*   r+   r   r   r,   r   propertyr   setterr   r
   r:   r    r'   r&   r   r     s    &(FHJ799<$ 
   \\, ,   \\, , g r'   r   c                        e Zd Z edd      j	                  d      Z edd      j	                  d      Z edd	      j	                  d      Z fd
Z e	dd      d        Z
 e	d       fd       Z xZS )_BoundedFloatRangerH   z<Minimum step that the value can take (ignored by some views)r   Tr   r1   r2   r   r3   c           	      d   |j                  dd      |j                  dd      }}|j                  dd       d|z  d|z  z   d|z  d|z  z   f|d<   n%t        |d   t              s	 t        |d         |d<   t        |   |i | y #  t        dj	                  t        |d                     xY w)	Nr6   r   r7   r1   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$   r6   r7   r%   s        r&   r"   z_BoundedFloatRange.__init__'  s    ::eS)6::eU+CS::gt$,#czD3J6#czD3J68F7OF7OU3"'w"8w 	$)&)77=vd6'?>S7T s   &B (B/r6   r7   c                    |d   }|d   }|j                   dk(  r|| j                  kD  rt        d      |j                   dk(  r|| j                  k  rt        d      |j                   dk(  r7t        || j                  d         t        || j                  d         f| _        |j                   dk(  r7t        || j                  d         t        || j                  d         f| _        |S )	Ntraitr   r6   zsetting min > maxr7   rB   r   r   )namer7   r	   r6   r   )r#   r9   r   news       r&   _validate_boundsz#_BoundedFloatRange._validate_bounds6  s    !w::3>011::3>011::c4::a=13sDJJqM3JKDJ::c4::a=13sDJJqM3JKDJ
r'   r   c                     t         |   |      \  }}t        || j                        t        || j                        }}t        || j                        t        || j                        }}||fS r(   )r!   r:   r6   r7   )r#   r9   r   r   r%   s       r&   r:   z"_BoundedFloatRange._validate_valueD  s^    w.x8u5$((+S-Au5$((+S-Aue|r'   )r)   r*   r+   r   r,   r^   r7   r6   r"   r
   r   r:   r-   r.   s   @r&   r   r   "  s    #Z[__ei_jD
[
)
-
-4
-
8C
;
'
+
+
+
6C* eU  g r'   r   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z eddd      j                  d      Z	 e
d	d
gd	d      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z  ee      j
                  dddieZ e
g ddd      j                  d      Zy)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).
    FloatRangeSliderViewTr   FloatRangeSliderModelrf   rU   rV   rg   rh   ri   rj   rm   r   rn   ro   zAUpdate the value of the widget as the user is sliding the slider.FrS   r   rq   rr   rv   Nr    rw   r    r'   r&   r   r   L  s3   2 /044$4?J1266D6AK#$-RSWW]aWbD!,
)C")BDDGCTCN 4STXX^bXcG!,..1ctcn T(klppvzp{E @AEE4EPH)L%))LtL7KLE&V 'BDDGCTCN r'   r   N)%rY   	traitletsr   r   r   r   r   r   r	   r
   r   widget_descriptionr   trait_typesr   r   valuewidgetr   widgetr   r   widget_corer   
widget_intr   r   r   r0   rF   rP   r`   rc   r~   r   r   r   r   r    r'   r&   <module>r      s*     2 3 $ 2 # 2#Z #F @ v  F 
d d 
d( 
d} d 
d0 
&S- &S 
&SR 
)S% )S 
)SX 
OM O 
O@& 8' 'T 
&S) &S 
&Sr'   