o
    Ô­j$  ã                   @   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 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   ú`/var/www/html/CropPilot/venv/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%„	}| rµtƒ  td&ƒ tƒ  |d#ƒ |rÅtƒ  td'ƒ tƒ  |dƒ |rëtƒ  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<   
)`ë