
    h                         d 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y)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                 ,    t        |       dk(  r| d   S | S )N       )len)tups    <D:\jyotish\venv\Lib\site-packages\numpy/_core/_exceptions.py_unpack_tupler   	   s    
3x1}1v
    c                 `    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y)UFuncTypeErrorz% Base class for all ufunc exceptions c                     || _         y 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                 D    t         |   |       t        |      | _        y r   )superr   tupledtypesr   r   r!   	__class__s      r   r   z_UFuncNoLoopError.__init__(   s    Fmr	   c           
          d| j                   j                  dt        | j                  d | j                   j                         dt        | j                  | j                   j                  d        S )Nzufunc z6 did not contain a loop with signature matching types z -> )r   r   r   r!   ninr   s    r   __str__z_UFuncNoLoopError.__str__,   sf    TZZ((+ ,+DKK,HIL MDJJNNO <=@B	
r	   r   r   r   r   r   r'   __classcell__r#   s   @r   r   r   %   s    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                 Z    t         |   ||       t        | j                        dk(  sJ y )N   )r   r   r   r!   r"   s      r   r   z$_UFuncBinaryResolutionError.__init__7   s)    '4;;1$$$r	   c                 d     dj                   | j                  j                  g| j                   S )Nz7ufunc {!r} cannot use operands with types {!r} and {!r})formatr   r   r!   r&   s    r   r'   z#_UFuncBinaryResolutionError.__str__;   s4    E
&JJ
 #'++
 	
r	   r(   r*   s   @r   r,   r,   4   s    1%
r	   r,   c                        e Zd Z fdZ xZS )_UFuncCastingErrorc                 N    t         |   |       || _        || _        || _        y r   )r   r   castingfrom_to)r   r   r4   r5   r6   r#   s        r   r   z_UFuncCastingError.__init__E   s%    
r	   )r   r   r   r   r)   r*   s   @r   r2   r2   C   s     r	   r2   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                 8    t         |   ||||       || _        y r   )r   r   in_ir   r   r4   r5   r6   ir#   s         r   r   z _UFuncInputCastingError.__init__O   s    3	r	   c           
          | j                   j                  dk7  r| j                   dnd}d| j                   j                  d| d| j                  d| j
                  d| j                  
S )	Nr     Cannot cast ufunc z input from  to  with casting rule )r   r%   r:   r   r5   r6   r4   r   i_strs     r   r'   z_UFuncInputCastingError.__str__S   sf    #'::>>Q#6499+QB !4!4 7wugUzznD+>t||>NP	
r	   r(   r*   s   @r   r8   r8   L   s    6
r	   r8   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                 8    t         |   ||||       || _        y r   )r   r   out_ir;   s         r   r   z!_UFuncOutputCastingError.__init___   s    3
r	   c           
          | j                   j                  dk7  r| j                   dnd}d| j                   j                  d| d| j                  d| j
                  d| j                  
S )	Nr   r>   r?   r@   z output rA   rB   rC   )r   noutrI   r   r5   r6   r4   rD   s     r   r'   z _UFuncOutputCastingError.__str__c   sg    $(JJOOq$84::,a b !4!4 7xwezznD+>t||>NP	
r	   r(   r*   s   @r   rG   rG   \   s    7
r	   rG   c                   <    e Zd ZdZd Zed        Zed        Zd Z	y)_ArrayMemoryErrorz) Thrown when an array cannot be allocatedc                      || _         || _        y r   )shapedtype)r   rO   rP   s      r   r   z_ArrayMemoryError.__init__o   s    

r	   c                 ^    | j                   j                  }| j                  D ]  }||z  }	 |S r   )rP   itemsizerO   )r   	num_bytesdims      r   _total_sizez_ArrayMemoryError._total_sizes   s/    JJ''	::CI r	   c                 V   d}d}g d}t        | j                         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d| S t        |      dk  r|d	d| S |d
d| S )z5 Convert a number of bytes into a binary size string 
   i   )bytesKiBMiBGiBTiBPiBEiBr   r   z.0fr>   i  z#.3gz#.0f)max
bit_lengthroundr   )	rS   	LOG2_STEPSTEPunitsunit_iunit_valn_units
new_unit_i	unit_names	            r   _size_to_stringz!_ArrayMemoryError._size_to_stringz   s    
 	CY))+a/3y@)+,h& >T!aKFtOG SZUaJqfz1Y>??GF&M	Q;c]!I;//7^d"d^1YK00 d^1YK00r	   c                 v    | j                  | j                        }d| d| j                   d| j                   S )NzUnable to allocate z for an array with shape z and data type )rj   rU   rO   rP   )r   size_strs     r   r'   z_ArrayMemoryError.__str__   s?    ''(8(89%hZ/H::,odjj\; 	<r	   N)
r   r   r   r   r   propertyrU   staticmethodrj   r'   r   r	   r   rM   rM   l   s8    3   "1 "1H<r	   rM   N)r   r   r   	TypeErrorr   r   r,   r2   r8   rG   MemoryErrorrM   r   r	   r   <module>rq      s   Y  
 
 
 
"3 
 
    
0 
 
 
1 
 
 5< 5< 5<r	   