+
    &h                     x    R t ^ RIHtHt ^ RIt^ RIt]! R4      ]! R4      3R lt	R
R ltR
R lt ! R R	4      t
R# )z[This module provides useful math functions on top of Python's
built-in :mod:`math` module.
)ceilfloorNz-infinfc                `    W!8  d   \        RV: RV: R24      h\        \        W4      V4      # )a  Limit a value to a given range.

Args:
    x (int or float): Number to be clamped.
    lower (int or float): Minimum value for x.
    upper (int or float): Maximum value for x.

The returned value is guaranteed to be between *lower* and
*upper*. Integers, floats, and other comparable types can be
mixed.

>>> clamp(1.0, 0, 5)
1.0
>>> clamp(-1.0, 0, 5)
0
>>> clamp(101.0, 0, 5)
5
>>> clamp(123, upper=5)
5

Similar to `numpy's clip`_ function.

.. _numpy's clip: http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html

zexpected upper bound (z) >= lower bound ())
ValueErrorminmax)xloweruppers   &&&1lib/python3.14/site-packages/boltons/mathutils.pyclampr   (   s1    4 }!5* + 	+s1}e$$    c                    Vf   \        V 4      # \        V4      p\        P                  ! W4      pV\	        V4      8X  d   \        RV ,          4      hW,          # )a  Return the ceiling of *x*. If *options* is set, return the smallest
integer or float from *options* that is greater than or equal to
*x*.

Args:
    x (int or float): Number to be tested.
    options (iterable): Optional iterable of arbitrary numbers
      (ints or floats).

>>> VALID_CABLE_CSA = [1.5, 2.5, 4, 6, 10, 25, 35, 50]
>>> ceil(3.5, options=VALID_CABLE_CSA)
4
>>> ceil(4, options=VALID_CABLE_CSA)
4
z,no ceil options greater than or equal to: %r)_ceilsortedbisectbisect_leftlenr   r
   optionsis   && r   r   r   H   sP      QxWoG7&ACLG!KLL:r   c                    Vf   \        V 4      # \        V4      p\        P                  ! W4      pV'       g   \	        RV ,          4      hW^,
          ,          # )a  Return the floor of *x*. If *options* is set, return the largest
integer or float from *options* that is less than or equal to
*x*.

Args:
    x (int or float): Number to be tested.
    options (iterable): Optional iterable of arbitrary numbers
      (ints or floats).

>>> VALID_CABLE_CSA = [1.5, 2.5, 4, 6, 10, 25, 35, 50]
>>> floor(3.5, options=VALID_CABLE_CSA)
2.5
>>> floor(2.5, options=VALID_CABLE_CSA)
2.5

z*no floor options less than or equal to: %r)_floorr   r   bisect_rightr   r   s   && r   r   r   a   sL    " ayWoGG'AEIJJq5>r   c                      a  ] tR t^|t o RtRtRR ltR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR t]R 4       t]R 4       t]R 4       t]RR l4       t]R 4       tR tRtV tR# )Bitsa  
An immutable bit-string or bit-array object.
Provides list-like access to bits as bools,
as well as bitwise masking and shifting operators.
Bits also make it easy to convert between many
different useful representations:

* bytes -- good for serializing raw binary data
* int -- good for incrementing (e.g. to try all possible values)
* list of bools -- good for iterating over or treating as flags
* hex/bin string -- good for human readability

Nc                   \        V4      \        JEd   \        V4      \        J d+   R P                  V Uu. uF  q3'       d   RMRNK  	  up4      p\        V4      \        J d   VP                  R4      p\        V4      \        J dr   Vf3   \        V4      pVP                  R4      '       d   V^,
          ^,          pVP                  R4      '       d   \        V^4      pMV'       d   \        V^4      pM^ p\        V4      \        Jd"   \        R\        V4      P                   24      hV^ 8  d   \        R4      hVf   \        VR 4      pV^V,          8  d   \        R	V R
V R24      hWn        W n        R# u upi ) 10asciiN0xzinitialized with bad type: z%Bits cannot represent negative valuesbzvalue z cannot be represented with z bits)typeintlistjoinbytesdecodestrr   
startswith	TypeError__name__r   val)selfr/   len_es   &&& r   __init__Bits.__init__   s?   9CCyD gg#>#QasS0#>?CyE!jj)CyC<s8D~~d++ $qA~>>$''c2,C!#qkCy#"=d3i>P>P=Q RSS7DEE<#a?Dd?vcU*FtfERSS1 ?s   E?c                b   \        V4      \        J d!   \        V P                  4       V,          4      # \        V4      \        J dW   WP
                  8  d   \        V4      h\        ^V P
                  V,
          ^,
          ,          V P                  ,          4      # \        \        V4      4      h)   )
r%   slicer   as_binr&   r   
IndexErrorboolr/   r-   )r0   ks   &&r   __getitem__Bits.__getitem__   sw    7ea())7c>HH} m#txx!|a/0DHH<==Q  r   c                    V P                   # N)r   r0   s   &r   __len__Bits.__len__       xxr   c                    \        V 4      \        V4      Jd   \        # V P                  VP                  8H  ;'       d    V P                  VP                  8H  # r?   )r%   NotImplementedr/   r   r0   others   &&r   __eq__Bits.__eq__   s@    :T%[(!!xx599$>>UYY)>>r   c                    \        V 4      \        V4      Jd   \        # \        V P                  VP                  ,          \	        V P
                  VP
                  4      4      # r?   r%   rE   r   r/   r	   r   rF   s   &&r   __or__Bits.__or__   A    :T%[(!!DHHuyy(#dhh		*BCCr   c                    \        V 4      \        V4      Jd   \        # \        V P                  VP                  ,          \	        V P
                  VP
                  4      4      # r?   rK   rF   s   &&r   __and__Bits.__and__   rN   r   c                ^    \        V P                  V,          V P                  V,           4      # r?   r   r/   r   rF   s   &&r   
__lshift__Bits.__lshift__   !    DHH%txx%'788r   c                ^    \        V P                  V,	          V P                  V,
          4      # r?   rS   rF   s   &&r   
__rshift__Bits.__rshift__   rV   r   c                ,    \        V P                  4      # r?   )hashr/   r@   s   &r   __hash__Bits.__hash__   s    DHH~r   c                P    V P                  4        Uu. uF  qR 8H  NK	  	  up# u upi )r    )r8   )r0   cs   & r   as_listBits.as_list   s"    "&++-0-QS-000s   #c                T    R V P                    R2P                  V P                  4      # )z{0:0zb})r   formatr/   r@   s   &r   r8   Bits.as_bin   s$    txxj$++DHH55r   c                    R ^V P                   ^,          V P                   ^,          ^ 8g  ,           ,           R2pWP                  ,          pV# )z%0Xr   r/   )r0   tmplrets   &  r   as_hexBits.as_hex   s@    AQ488a<A*=>?@BXXo
r   c                    V P                   # r?   )r/   r@   s   &r   as_intBits.as_int   rC   r   c                J    \         P                  ! V P                  4       4      # r?   )binascii	unhexlifyrj   r@   s   &r   as_bytesBits.as_bytes   s    !!$++-00r   c                    V ! V4      # r?    )clslist_s   &&r   	from_listBits.from_list   s    5zr   c                    V ! V4      # r?   ru   )rv   bins   &&r   from_binBits.from_bin   s    3xr   c                    \        V\        4      '       d   VP                  R 4      pVP                  R4      '       g
   RV,           pV ! V4      # )r"   r#   )
isinstancer)   r*   r,   )rv   hexs   &&r   from_hexBits.from_hex   s>    c5!!**W%C~~d##*C3xr   c                    V ! W4      # r?   ru   )rv   int_r1   s   &&&r   from_intBits.from_int   s    4r   c                L    V P                  \        P                  ! V4      4      # r?   )r   rp   hexlify)rv   bytes_s   &&r   
from_bytesBits.from_bytes   s    ||H,,V455r   c                Z    V P                   P                  pV R V P                  4        R2# )z('z'))	__class__r.   r8   )r0   cns   & r   __repr__Bits.__repr__   s*    ^^$$Rb))r   rg   )r/   r   )    Nr?   )r.   
__module____qualname____firstlineno____doc__	__slots__r3   r<   rA   rH   rL   rP   rT   rX   r\   r`   r8   rj   rm   rr   classmethodrx   r|   r   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r   r   r   |   s      I:!?
D
D
99161         6 6* *r   r   r?   )r   mathr   r   r   r   r   rp   floatr   r   ru   r   r   <module>r      s@   > 0   =e %@26}* }*r   