a
    p=ic$                     @   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r:e
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 )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   t/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/numpy/testing/print_coercion_tables.py__init__
   s    zGenericObject.__init__c                 C   s   | S r   r   r   otherr   r   r   __add__   s    zGenericObject.__add__c                 C   s   | S r   r   r
   r   r   r   __radd__   s    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 ]d}t||drXd}n@t||drld}n,t||drd	}nt||d
rd}nd}t |dd q@t   q,d S )NX endequiv#safe=Z	same_kind~unsafe.)printr   can_cast)ntypescharrowcolcastr   r   r   print_cancast_table   s$    r&   Fc              
   C   sN  t ddd | D ]}t |dd qt   | D ]}|dkr@t}n
t|}t |dd | D ]}|dkrlt}	n
t|}	zx|rtj||g|d}
n||}
|	|}|rt|
j|jj}n2t|
|}t	|tj
r|jj}ntt|j}W nD ty   d}Y n. ty   d}Y n ty2   d}Y n0 t |dd qZt   q,d S )	N+r   r   r   )r   !@r   )r   r   r   Z
obj2sctypearraypromote_typesr   r"   add
isinstanceZndarraytype
ValueErrorOverflowError	TypeError)r!   ZinputfirstvalueZinputsecondvalueZ
firstarrayZuse_promote_typesr"   r#   Zrowtyper$   ZcoltypeZrowvalueZcolvaluevaluer   r   r   print_coercion_table*   s@    




r3   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 ]} |d   |d  |d vri |d < |d  }	||d  } |d rdnd}d}|d r|dO }|d r|dO }|d r|dO }|| }|| ||d|	|d < qbtjd fd d!}
t |
d" d. fd$d%	}| rlt  td& t  |d# |rt  td' t  |d |rt  t|d  d(|d  d)|d  d*|d  d+ t  |d, 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      r9   r:   r<   r;         	cast_infor4   fromtoZcastingr5   LZrequires_pyapir9   Zsupports_unalignedr:   Zno_floatingpoint_errorsr<   Allc                    s@   t | j}z |j}W n ty4   t j}Y n0 ||jfS r   )r   r   r.   indexr"   r/   inf)xr   Z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 ]P}t t|jjdd |i } D ]}t t||| dd q`t   q6d S )Nr   r   r   )r   r   r   r.   r"   getgetattr)fielddtZfrom_dtr#   Z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-errorsr6   N)r    )	Znumpy.core._multiarray_testsr7   r   setr,   r   	typecodessortedr   )r    r5   r6   r7   Z
cast_tableZflags_tabler@   Zcastsr%   to_dictrI   rR   r   )rO   rP   rQ   rH   r   print_new_cast_tableS   st    	


rW   __main__zcan castrD   zJIn these tables, ValueError is '!', OverflowError is '@', TypeError is '#'zscalar + scalarzscalar + neg scalarr8   zarray + scalarzarray + neg scalarr+   zNew casting type promotion:)F)__doc__numpyr   collectionsr   r   r&   r3   rW   r   r   rT   r   r   r   r   <module>   s8   
)`
