a
    LfO                     @   sJ  d Z ddlZddlm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rFe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)
obj2sctype)
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   \/var/www/ai-form-bot/venv/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   sJ  t ddd | D ]}t |dd qt   | D ]}|dkr@t}nt|}t |dd | D ]}|dkrjt}	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y.   d}Y n0 t |dd qXt   q,d S )	N+r   r   r   )r   !@r   )r    r   r   r   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@    


r4   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      r:   r;   r=   r<         	cast_infor5   fromtoZcastingr6   LZrequires_pyapir:   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#   r0   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-errorsr7   N)r!   )	Znumpy._core._multiarray_testsr8   r   setr-   r   	typecodessortedr    )r!   r6   r7   r8   Z
cast_tableZflags_tablerA   Zcastsr&   to_dictrJ   rS   r   )rP   rQ   rR   rI   r	   print_new_cast_tableT   st    	


rX   __main__zcan castrE   zJIn these tables, ValueError is '!', OverflowError is '@', TypeError is '#'zscalar + scalarzscalar + neg scalarr9   zarray + scalarzarray + neg scalarr,   zNew casting type promotion:)F)__doc__numpyr   Znumpy._core.numerictypesr   collectionsr   r   r'   r4   rX   r   r    rU   r   r   r   r	   <module>   s:   
)`
