o
    .h$                     @   s@  d Z ddlZddlmZ G dd dZdd Zdd	d
ZddddddZe	dkre
d eejd  e
  e
d e
  e
d eejd ddd e
  e
d eejd ddd e
  e
d eejd ddd e
  e
d eejd ddd e
  e
d eejd dddd e
d edddd dS dS )z:Prints type-coercion tables for the built-in NumPy types

    N)
namedtuplec                   @   s.   e Zd Zdd Zdd Zdd ZedZdS )	GenericObjectc                 C   s
   || _ d S N)v)selfr    r   b/var/www/supernova/superenvnew/lib/python3.10/site-packages/numpy/testing/print_coercion_tables.py__init__
   s   
zGenericObject.__init__c                 C      | S r   r   r   otherr   r   r   __add__      zGenericObject.__add__c                 C   r
   r   r   r   r   r   r   __radd__   r   zGenericObject.__radd__ON)__name__
__module____qualname__r	   r   r   npdtyper   r   r   r   r   	   s
    r   c                 C   s   t ddd | D ]}t |dd qt   | D ]@}t |dd | D ]2}t||dr,d}n t||dr6d}nt||dr@d	}nt||d
rJd}nd}t |dd q t   qd S )NX endequiv#safe=	same_kind~unsafe.)printr   can_cast)ntypescharrowcolcastr   r   r   print_cancast_table   s&   r)   Fc              
   C   sF  t ddd | D ]}t |dd qt   | D ]}|dkrt}nt|}t |dd | D ]p}|dkr5t}	nt|}	z<|rHtj||g|d}
n||}
|	|}|r\t|
j|jj}nt|
|}t	|tj
rm|jj}ntt|j}W n ty   d}Y n ty   d}Y n ty   d}Y nw t |dd q,t   qd S )	N+r   r   r   )r   !@r   )r"   r   r   
obj2sctypearraypromote_typesr   r%   add
isinstancendarraytype
ValueErrorOverflowError	TypeError)r$   inputfirstvalueinputsecondvalue
firstarrayuse_promote_typesr%   r&   rowtyper'   coltyperowvaluecolvaluevaluer   r   r   print_coercion_table*   sF   


r@   Tr#   legacyflagsc              	      s  ddl m} ddddddd}d	d
ddddddd}tdg d}|ddd| }i t  |D ]Y} |d   |d  |d vrMi |d < |d  }	||d  } |d r_dnd}d}|d rk|dO }|d rs|dO }|d r{|dO }|| }|| ||d|	|d < q1tjd fd d!}
t |
d" d. fd$d%	}| rt  td& t  |d# |rt  td' t  |d |rt  t|d  d(|d  d)|d  d*|d  d+ t  |d, d-S d-S )/z[Prints new casts, the values given are default "can-cast" values, not
    actual ones.
    r   )get_all_cast_informationr   r   r   r   r!   )r               u   ▗u   █u   ▚u   ▐u   ▄u   ▜u   ▙u   ▟)r      rF   rG   rI   rH         	cast_inforA   fromtocastingrB   Lrequires_pyapirF   supports_unalignedrG   no_floatingpoint_errorsrI   Allc                    s@   t | j}z |j}W n ty   t j}Y nw ||jfS r   )r   r   r3   indexr%   r4   inf)xr   indx)typesr   r   sorter   s   

z$print_new_cast_table.<locals>.sorter)keyr#   c                    s   t ddd  D ]}t t|jjdd qt    D ](}t t|jjdd |i } D ]}t t||| dd q0t   qd S )Nr   r   r   )r"   r   r   r3   r%   getgetattr)fielddtfrom_dtr&   to_dt)dtypesno_cast_infotabler   r   print_table   s   z)print_new_cast_table.<locals>.print_tablezDCasting: # is equivalent, = is safe, ~ is same-kind, and . is unsafez+L denotes a legacy cast . a non-legacy one.z: no flags, z	: PyAPI, z: supports unaligned, z: no-float-errorsrC   N)r#   )	numpy.core._multiarray_testsrD   r   setr0   r   	typecodessortedr"   )r#   rB   rC   rD   
cast_tableflags_tablerM   castsr(   to_dictr[   rf   r   )rc   rd   re   rZ   r   print_new_cast_tableS   sv   	


ro   __main__zcan castrU   zJIn these tables, ValueError is '!', OverflowError is '@', TypeError is '#'zscalar + scalarzscalar + neg scalarrE   zarray + scalarzarray + neg scalarr/   zNew casting type promotion:)F)__doc__numpyr   collectionsr   r   r)   r@   ro   r   r"   ri   r   r   r   r   <module>   s<   
)`