
    h                         S r SSKJr  S rS r " S S\5      r\ " S S\5      5       r\ " S	 S
\5      5       r\ " S S\5      5       r	\ " S S\	5      5       r
\ " S S\	5      5       r\ " S S\5      5       rg)z
Various richly-typed exceptions, that also help us deal with string formatting
in python where it's easier.

By putting the formatting in `__str__`, we also avoid paying the cost for
users who silence the exceptions.
   )
set_modulec                 .    [        U 5      S:X  a  U S   $ U $ )N       )len)tups    P/var/www/fran/franai/venv/lib/python3.13/site-packages/numpy/core/_exceptions.py_unpack_tupler
   
   s    
3x1}1v
    c                 j    [        U [        5      (       d   eU R                  R                  U l        U $ )a/  
A decorator that makes an exception class look like its base.

We use this to hide subclasses that are implementation details - the user
should catch the base type, which is what the traceback will show them.

Classes decorated with this decorator are subject to removal without a
deprecation warning.
)
issubclass	Exception__base____name__)clss    r	   _display_as_baser      s-     c9%%%%<<((CLJr   c                       \ rS rSrSrS rSrg)UFuncTypeError    z$Base class for all ufunc exceptions c                     Xl         g Nufunc)selfr   s     r	   __init__UFuncTypeError.__init__"   s    
r   r   N)r   
__module____qualname____firstlineno____doc__r   __static_attributes__ r   r	   r   r       s
    /r   r   c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )_UFuncNoLoopError&   z)Thrown when a ufunc loop cannot be found c                 D   > [         TU ]  U5        [        U5      U l        g r   )superr   tupledtypesr   r   r)   	__class__s      r	   r   _UFuncNoLoopError.__init__)   s    Fmr   c           	          SR                  U R                  R                  [        U R                  S U R                  R
                   5      [        U R                  U R                  R
                  S  5      5      $ )NzLufunc {!r} did not contain a loop with signature matching types {!r} -> {!r})formatr   r   r
   r)   ninr   s    r	   __str___UFuncNoLoopError.__str__-   sY    
&JJ$++otzz~~67$++djjnno67
	
r   )r)   	r   r   r   r   r    r   r1   r!   __classcell__r+   s   @r	   r$   r$   &   s    4$
 
r   r$   c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )_UFuncBinaryResolutionError8   z&Thrown when a binary resolution fails c                 Z   > [         TU ]  X5        [        U R                  5      S:X  d   eg )Nr   )r'   r   r   r)   r*   s      r	   r   $_UFuncBinaryResolutionError.__init__;   s'    '4;;1$$$r   c                 d    SR                   " U R                  R                  /U R                  Q76 $ )Nz7ufunc {!r} cannot use operands with types {!r} and {!r})r.   r   r   r)   r0   s    r	   r1   #_UFuncBinaryResolutionError.__str__?   s6    E
& JJ
 #'++
 	
r   r"   r3   r5   s   @r	   r7   r7   8   s    1%
 
r   r7   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )_UFuncCastingErrorG   c                 H   > [         TU ]  U5        X l        X0l        X@l        g r   )r'   r   castingfrom_to)r   r   rA   rB   rC   r+   s        r	   r   _UFuncCastingError.__init__I   s    
r   )rA   rB   rC   )r   r   r   r   r   r!   r4   r5   s   @r	   r>   r>   G   s     r   r>   c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )_UFuncInputCastingErrorP   z+Thrown when a ufunc input cannot be casted c                 2   > [         TU ]  XX45        XPl        g r   )r'   r   in_ir   r   rA   rB   rC   ir+   s         r	   r    _UFuncInputCastingError.__init__S   s    3	r   c                     U R                   R                  S:w  a  SR                  U R                  5      OSnSR                  U R                   R                  XR
                  U R                  U R                  5      $ )Nr   {}  zGCannot cast ufunc {!r} input {}from {!r} to {!r} with casting rule {!r})r   r/   r.   rI   r   rB   rC   rA   r   i_strs     r	   r1   _UFuncInputCastingError.__str__W   sX    +/::>>Q+>TYY'B
&JJ

DGGT\\
	
r   )rI   r3   r5   s   @r	   rF   rF   P   s    6
 
r   rF   c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )_UFuncOutputCastingErrorb   z,Thrown when a ufunc output cannot be casted c                 2   > [         TU ]  XX45        XPl        g r   )r'   r   out_irJ   s         r	   r   !_UFuncOutputCastingError.__init__e   s    3
r   c                     U R                   R                  S:w  a  SR                  U R                  5      OSnSR                  U R                   R                  XR
                  U R                  U R                  5      $ )Nr   rN   rO   zHCannot cast ufunc {!r} output {}from {!r} to {!r} with casting rule {!r})r   noutr.   rW   r   rB   rC   rA   rP   s     r	   r1    _UFuncOutputCastingError.__str__i   sX    ,0JJOOq,@TZZ(b
&JJ

DGGT\\
	
r   )rW   r3   r5   s   @r	   rT   rT   b   s    7
 
r   rT   c                   D    \ rS rSrSrS r\S 5       r\S 5       r	S r
Srg)	_ArrayMemoryErrort   z(Thrown when an array cannot be allocatedc                     Xl         X l        g r   )shapedtype)r   r`   ra   s      r	   r   _ArrayMemoryError.__init__w   s    

r   c                 `    U R                   R                  nU R                   H  nX-  nM	     U$ r   )ra   itemsizer`   )r   	num_bytesdims      r	   _total_size_ArrayMemoryError._total_size{   s-    JJ''	::CI r   c                    SnSn/ SQn[        U R                  5       S-
  S5      U-  nSXA-  -  nX-  nA[        U5      U:X  a	  US-  nXb-  nU[        U5      :  a  [        U5      S-
  nUSXG-
  U-  -  -  nUnX4   nUS:X  a  SR	                  Xh5      $ [        U5      S:  a  SR	                  Xh5      $ S	R	                  Xh5      $ )
z4Convert a number of bytes into a binary size string 
   i   )bytesKiBMiBGiBTiBPiBEiBr   r   z	{:.0f} {}i  z
{:#.3g} {}z
{:#.0f} {})max
bit_lengthroundr   r.   )	re   	LOG2_STEPSTEPunitsunit_iunit_valn_units
new_unit_i	unit_names	            r	   _size_to_string!_ArrayMemoryError._size_to_string   s    
 	CY))+a/3y@+,& >T!aKFOG SZUaJqf1Y>??GFM	Q;%%g997^d"&&w::  &&w::r   c                     U R                  U R                  5      nSR                  XR                  U R                  5      $ )NzAUnable to allocate {} for an array with shape {} and data type {})r}   rg   r.   r`   ra   )r   size_strs     r	   r1   _ArrayMemoryError.__str__   s4    ''(8(89OVHjj$**5	
r   )ra   r`   N)r   r   r   r   r    r   propertyrg   staticmethodr}   r1   r!   r"   r   r	   r]   r]   t   s8    3   "; ";H
r   r]   N)r    _utilsr   r
   r   	TypeErrorr   r$   r7   r>   rF   rT   MemoryErrorr]   r"   r   r	   <module>r      s     Y  
 
 
" 
"3 
 
    
0 
 
" 
1 
 
" 7
 7
 7
r   