+
    ei'  c                   s    R t R tR t ! R R]4      t] ! R R]4      4       t] ! R R]4      4       t] ! R	 R
]4      4       t] ! R R]4      4       t] ! R R]4      4       t	] ! R R]
4      4       tR# )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.
c                 s8    \        V 4      ^8X  d
   V ^ ,          # V # )   )len)Ztup   &>/usr/lib64/python3.14/site-packages/numpy/_core/_exceptions.py_unpack_tupler   	   s    
3x1}1v
    c                s<    V P                   P                  V n        V # )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.
)Z__base____name__)Zclsr   r   _display_as_baser      s     <<((CLJr   c                   s*   a  ] tR t^t o RtR tRtV tR# )UFuncTypeErrorz$Base class for all ufunc exceptions c                s    Wn         R # Nufunc)selfr   s   &&r   __init__ZUFuncTypeError.__init__!   s    
r   r
   N)r   
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell____classdict__   @r   r   r      s     / r   r   c                   s<   a a ] tR t^%t oRtV 3R ltR tRtVtV ;t	# )_UFuncNoLoopErrorz)Thrown when a ufunc loop cannot be found c                sF   < \         SV `  V4       \        V4      V n        R # r	   )superr   Ztupledtypesr   r   r   	__class__   &&&r   r   Z_UFuncNoLoopError.__init__(   s    Fmr   c           
     s    R V P                   P                  : R\        V P                  RV P                   P                   4      : R\        V P                  V P                   P                  R 4      : 2# )zufunc z6 did not contain a loop with signature matching types Nz -> )r   r   r   r   ninr   r   r   __str__Z_UFuncNoLoopError.__str__,   sf    TZZ((+ ,+DKK,HIL MDJJNNO <=@B	
r   )r   
r   r   r   r   r   r   r   r   r   __classcell__r   r      @@r   r   r   %   s     4$
 
r   r   c                   s<   a a ] tR t^4t oRtV 3R ltR tRtVtV ;t	# )_UFuncBinaryResolutionErrorz&Thrown when a binary resolution fails c                s&   < \         SV `  W4       R # r	   )r   r   r   r   r   r   Z$_UFuncBinaryResolutionError.__init__7   s    'r   c                sf    R P                   ! V P                  P                  .V P                  O5!  # )z7ufunc {!r} cannot use operands with types {!r} and {!r})Zformatr   r   r   r   r   r   r   Z#_UFuncBinaryResolutionError.__str__;   s6    E
& JJ
 #'++
 	
r    r    r"   r#   r   r$   r$   4   s     1%
 
r   r$   c                   s2   a a ] tR t^Ct oV 3R ltRtVtV ;t# )_UFuncCastingErrorc                sJ   < \         SV `  V4       W n        W0n        W@n        R # r	   )r   r   castingfrom_to)r   r   r'   r(   r)   r   s   &&&&&r   r   Z_UFuncCastingError.__init__E   s    
r   )r'   r(   r)   )r   r   r   r   r   r   r   r!   r"   r#   r   r&   r&   C   s      r   r&   c                   s<   a a ] tR t^Lt oRtV 3R ltR tRtVtV ;t	# )_UFuncInputCastingErrorz+Thrown when a ufunc input cannot be casted c                4   < \         SV `  WW44       WPn        R # r	   )r   r   in_ir   r   r'   r(   r)   Zir      &&&&&&r   r   Z _UFuncInputCastingError.__init__O   s    3	r   c           
         V P                   P                  ^8w  d   V P                   R2MRpRV P                   P                  : RV RV P                  : RV P
                  : RV P                  : 2
# )r      Cannot cast ufunc z input from  to  with casting rule )r   r   r,   r   r(   r)   r'   r   Zi_str   & r   r   Z_UFuncInputCastingError.__str__S   sf    #'::>>Q#6499+QB !4!4 7wugUzznD+>t||>NP	
r   )r,   r    r"   r#   r   r*   r*   L   s     6
 
r   r*   c                   s<   a a ] tR t^\t oRtV 3R ltR tRtVtV ;t	# )_UFuncOutputCastingErrorz,Thrown when a ufunc output cannot be casted c                r+   r	   )r   r   out_ir-   r.   r   r   Z!_UFuncOutputCastingError.__init___   s    3
r   c           
     r/   )r    r0   r1   r2   z output r3   r4   r5   )r   Znoutr9   r   r(   r)   r'   r6   r7   r   r   Z _UFuncOutputCastingError.__str__c   sg    $(JJOOq$84::,a b !4!4 7xwezznD+>t||>NP	
r   )r9   r    r"   r#   r   r8   r8   \   s     7
 
r   r8   c                   sP   a  ] tR t^lt o RtR t]R 4       t]R 4       t	R t
RtV tR# )_ArrayMemoryErrorz(Thrown when an array cannot be allocatedc                s    Wn         W n        R # r	   )shapedtype)r   r;   r<   s   &&&r   r   Z_ArrayMemoryError.__init__o   s    

r   c                sh    V P                   P                  pV P                   F  pW,          pK  	  V# r	   )r<   Zitemsizer;   )r   	num_bytesZdims   &  r   _total_sizeZ_ArrayMemoryError._total_sizes   s-    JJ''	::CI r   c                s   ^
pRp. ROp\        V P                  4       ^,
          ^4      V,          p^WA,          ,          pW,          p?\        V4      V8X  d   V^,          pWb,          pV\        V4      8  d2   \        V4      ^,
          pV^WG,
          V,          ,          ,          pTpW4,          pV^ 8X  d	   VR RV 2# \        V4      R8  d	   VR RV 2# VR RV 2# )z4Convert a number of bytes into a binary size string i   z.0fr0   i  z#.3gz#.0f)ZbytesZKiBZMiBZGiBZTiBZPiBZEiB)ZmaxZ
bit_lengthZroundr   )	r=   Z	LOG2_STEPZSTEPZunitsZunit_iZunit_valZn_unitsZ
new_unit_iZ	unit_names	   &        r   _size_to_stringZ!_ArrayMemoryError._size_to_stringz   s    
 	CY))+a/3y@+,& >T!aKFOG SZUaJqf1Y>??GFM	Q;c]!I;//7^d"d^1YK00 d^1YK00r   c                sv    V P                  V P                  4      pR V RV P                   RV P                   2# )zUnable to allocate z for an array with shape z and data type )r?   r>   r;   r<   )r   Zsize_strr7   r   r   Z_ArrayMemoryError.__str__   s?    ''(8(89%hZ/H::,odjj\; 	<r   )r<   r;   N)r   r   r   r   r   r   Zpropertyr>   Zstaticmethodr?   r   r   r   r   r   r   r:   r:   l   s@     3   "1 "1H< <r   r:   N)r   r   r   Z	TypeErrorr   r   r$   r&   r*   r8   ZMemoryErrorr:   r%   r   r   <module>r@      s   Y  
 
 
 
"3 
 
    
0 
 
 
1 
 
 5< 5< 5<r   