U
    #c9                     @   s   d dl Zd dlZd dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZ d dlmZ d dlmZ d dlmZ dd ejjj D Zd	d eD Zeeed
 eddpeddoeddZejdoeoed Z ej!j"e  ddZ#dddZ$e%e$Z&G dd dZ'dS )    N)path)
c_longlongc_doublec_floatc_intcastpointerPOINTER)assert_array_max_ulp)_glibc_older_than)__cpu_features__c                 C   s   g | ]}t |tjr|qS  )
isinstancenpufunc).0objr   r   H/tmp/pip-unpacked-wheel-b2rbor69/numpy/core/tests/test_umath_accuracy.py
<listcomp>   s    r   c                 C   s   g | ]}d |j kr|qS )zO->O)types)r   Zufr   r   r   r      s     
 invertZAVX512FFZFMA3ZAVX2linuxz2.17z;avoid testing inconsistent platform library implementations)reason
np.float32c                 C   sP   t | d}|dkr.tt|}t|tt}ntt|}t|tt}|jj	S )N   z
np.float64)
intr   r   r   r	   r   r   r   contentsvalue)sdatatypeicpfpr   r   r   convert   s    
r#   c                   @   s.   e Zd Zedd Zejdedd Z	dS )TestAccuracyc                 C   s~  t jddf tttd}t|}tt	dd |}|D ]*}t||}t
|
}dd |D }t j|dddtfd	d
dd}t|d dd }tt |}	t |d D ]}
||d |
k }t jt|d t|d tt|
d}t jt|d t|d tt|
d}t jt|}|| }|| }|d  }t|	||| qW 5 Q R X qBW 5 Q R X d S )Nignorealldatac                 S   s
   |  dS )Nz.csv)endswith)fr   r   r   <lambda>.       z<TestAccuracy.test_validate_transcendentals.<locals>.<lambda>c                 s   s   | ]}|d  dkr|V  qdS )r   )$#Nr   )r   rr   r   r   	<genexpr>2   s      z=TestAccuracy.test_validate_transcendentals.<locals>.<genexpr>z|S39)typeinputoutputulperr,   )dtypenames	delimiterZskip_headerr   -   r1   r2   r7   r3   r4   )r   errstater   joindirname__file__oslistdirlistfilteropenZ
genfromtxtr   splitextsplitgetattruniquearraystr_to_floatastypestrevalrandomZpermutationlenmaxr
   )selfdata_dirfilesfilenamefilepathZfidZfile_without_commentsr(   ZnpnameZnpfuncr   Zdata_subsetZinvalZoutvalpermZ	maxulperrr   r   r   test_validate_transcendentals)   s2    



,,z*TestAccuracy.test_validate_transcendentalsr   c              	   C   sf   t jddP t jdt jd}t j| t jd}|t j}t	||||dt jd W 5 Q R X d S )Nr%   r&   i   r<   r6   )Zmaxulpr7   )
r   r=   ZarangeZint16Z
frombuffertobytesZfloat16rL   Zfloat32r
   )rR   r   ZarrZdatafp16Zdatafp32r   r   r   "test_validate_fp16_transcendentalsD   s     z/TestAccuracy.test_validate_fp16_transcendentalsN)
__name__
__module____qualname__platform_skiprX   pytestmarkZparametrizeUNARY_OBJECT_UFUNCSrZ   r   r   r   r   r$   (   s   
r$   )r   )(Znumpyr   rA   r   sysr_   ctypesr   r   r   r   r   r   r	   Znumpy.testingr
   Znumpy.testing._private.utilsr   Znumpy.core._multiarray_umathr   coreZumath__dict__valuesZUNARY_UFUNCSra   removerH   getZIS_AVXplatform
startswithZruntestr`   Zskipifr^   r#   Z	vectorizerK   r$   r   r   r   r   <module>   s2   $


