
    Dg                     F   d Z ddlmZ d Zd 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e G d de                      ZdS )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                 <    t          |           dk    r| d         S | S )N       )len)tups    K/var/www/sysmax/venv/lib/python3.11/site-packages/numpy/core/_exceptions.py_unpack_tupler
   
   s    
3xx1}}1v
    c                 V    t          | t                    sJ | j        j        | _        | S )aG  
    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                       e Zd ZdZd ZdS )UFuncTypeErrorz% Base class for all ufunc exceptions c                     || _         d S N)ufunc)selfr   s     r	   __init__zUFuncTypeError.__init__"   s    


r   N)r   
__module____qualname____doc__r    r   r	   r   r       s)        //    r   r   c                   (     e Zd ZdZ fdZd Z xZS )_UFuncNoLoopErrorz* Thrown when a ufunc loop cannot be found c                 r    t                                          |           t          |          | _        d S r   )superr   tupledtypesr   r   r#   	__class__s      r	   r   z_UFuncNoLoopError.__init__)   s,    Fmmr   c           	          d                     | j        j        t          | j        d | j        j                           t          | j        | j        j        d                              S )NzLufunc {!r} did not contain a loop with signature matching types {!r} -> {!r})formatr   r   r
   r#   ninr   s    r	   __str__z_UFuncNoLoopError.__str__-   sW    
&J$+otz~o677$+djnoo677
 
	
r   r   r   r   r   r   r*   __classcell__r%   s   @r	   r   r   &   sM        44$ $ $ $ $
 
 
 
 
 
 
r   r   c                   (     e Zd ZdZ fdZd Z xZS )_UFuncBinaryResolutionErrorz' Thrown when a binary resolution fails c                     t                                          ||           t          | j                  dk    sJ d S )Nr   )r!   r   r   r#   r$   s      r	   r   z$_UFuncBinaryResolutionError.__init__;   s>    '''4;1$$$$$$r   c                 <     dj         | j        j        g| j        R  S )Nz7ufunc {!r} cannot use operands with types {!r} and {!r})r'   r   r   r#   r)   s    r	   r*   z#_UFuncBinaryResolutionError.__str__?   s5    E
J
 #'+
 
 
 	
r   r+   r-   s   @r	   r/   r/   8   sM        11% % % % %
 
 
 
 
 
 
r   r/   c                        e Zd Z fdZ xZS )_UFuncCastingErrorc                 t    t                                          |           || _        || _        || _        d S r   )r!   r   castingfrom_to)r   r   r5   r6   r7   r%   s        r	   r   z_UFuncCastingError.__init__I   s4    
r   )r   r   r   r   r,   r-   s   @r	   r3   r3   G   s8                r   r3   c                   (     e Zd ZdZ fdZd Z xZS )_UFuncInputCastingErrorz, Thrown when a ufunc input cannot be casted c                 ^    t                                          ||||           || _        d S r   )r!   r   in_ir   r   r5   r6   r7   ir%   s         r	   r   z _UFuncInputCastingError.__init__S   s,    333			r   c                     | j         j        dk    rd                    | j                  nd}d                    | j         j        || j        | j        | j                  S )Nr   {}  zGCannot cast ufunc {!r} input {}from {!r} to {!r} with casting rule {!r})r   r(   r'   r;   r   r6   r7   r5   r   i_strs     r	   r*   z_UFuncInputCastingError.__str__W   sW    +/:>Q+>+>TY'''B
&J
DGT\
 
	
r   r+   r-   s   @r	   r9   r9   P   sM        66    
 
 
 
 
 
 
r   r9   c                   (     e Zd ZdZ fdZd Z xZS )_UFuncOutputCastingErrorz- Thrown when a ufunc output cannot be casted c                 ^    t                                          ||||           || _        d S r   )r!   r   out_ir<   s         r	   r   z!_UFuncOutputCastingError.__init__e   s,    333


r   c                     | j         j        dk    rd                    | j                  nd}d                    | j         j        || j        | j        | j                  S )Nr   r?   r@   zHCannot cast ufunc {!r} output {}from {!r} to {!r} with casting rule {!r})r   noutr'   rF   r   r6   r7   r5   rA   s     r	   r*   z _UFuncOutputCastingError.__str__i   sW    ,0JOq,@,@TZ(((b
&J
DGT\
 
	
r   r+   r-   s   @r	   rD   rD   b   sM        77    
 
 
 
 
 
 
r   rD   c                   J    e Zd ZdZd Zed             Zed             Zd Z	dS )_ArrayMemoryErrorz) Thrown when an array cannot be allocatedc                 "    || _         || _        d S r   )shapedtype)r   rL   rM   s      r	   r   z_ArrayMemoryError.__init__w   s    



r   c                 <    | j         j        }| j        D ]}||z  }|S r   )rM   itemsizerL   )r   	num_bytesdims      r	   _total_sizez_ArrayMemoryError._total_size{   s/    J'	: 	 	CIIr   c                    d}d}g d}t          |                                 dz
  d          |z  }d||z  z  }| |z  }~t          |          |k    r
|dz  }||z  }|t          |          k    r"t          |          dz
  }|d||z
  |z  z  z  }|}||         }|dk    rd                    ||          S t          |          dk     rd                    ||          S d	                    ||          S )
z5 Convert 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'   )	rP   	LOG2_STEPSTEPunitsunit_iunit_valn_units
new_unit_i	unit_names	            r	   _size_to_stringz!_ArrayMemoryError._size_to_string   s&   
 	CCCY))++a/33y@)+,h& >>T!!aKFtOG SZZUaJqfz1Y>??GF&M	Q;;%%gy9997^^d""&&w	:::  &&w	:::r   c                 x    |                      | j                  }d                    || j        | j                  S )NzAUnable to allocate {} for an array with shape {} and data type {})rg   rR   r'   rL   rM   )r   size_strs     r	   r*   z_ArrayMemoryError.__str__   s5    ''(899OVHdj$*55	
r   N)
r   r   r   r   r   propertyrR   staticmethodrg   r*   r   r   r	   rJ   rJ   t   so        33     X "; "; \";H
 
 
 
 
r   rJ   N)r   _utilsr   r
   r   	TypeErrorr   r   r/   r3   r9   rD   MemoryErrorrJ   r   r   r	   <module>ro      s                  Y    
 
 
 
 
 
 
 
" 
 
 
 
 
"3 
 
 
         
 
 
 
 
0 
 
 
" 
 
 
 
 
1 
 
 
" 7
 7
 7
 7
 7
 7
 7
 7
 7
 7
r   