U
    iâËdW  ã                   @   sT   d dl Zd dlmZ d dlmZ d dlmZ d dlm	Z	 dd„ Z
G dd	„ d	e	ƒZdS )
é    N)Únjit)Útypes)ÚTypingError)ÚTestCasec                    s   ‡ ‡fdd„}|S )Nc                    s   ˆ | ƒ  ˆ¡S ©N©Úview)Úx©ÚaÚb© úQ/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numba/tests/test_numbers.pyÚimpl   s    zgen_view.<locals>.implr   )r   r   r   r   r
   r   Úgen_view   s    r   c                   @   sP   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚTestViewIntFloatz0 This tests the 'view' method on NumPy scalars. c           	   	   C   s–   |D ]Œ\}}}t ||ƒD ]v\}}tt||ƒƒ}t |¡sd|  ||ƒ||ƒ¡ |  ||ƒ| |¡¡ q|  t ||ƒ¡¡ |  t | |¡¡¡ qqd S r   )Úzipr   r   ÚnpÚisnanÚassertEqualZpy_funcÚ
assertTrue)	ÚselfÚinputsÚdtypesÚvalueZinitial_typeÚexpectedZtarget_typeÚresultr   r   r   r   Ú
do_testing   s    

ÿzTestViewIntFloat.do_testingc                 C   s4   t jt jf}dt jdfdt jdff}|  ||¡ d S )Né   )r   r   éÿÿÿÿ)éÿ   r   )r   Zuint8Úint8r   ©r   r   r   r   r   r   Útest_8_bits$   s
    

ÿzTestViewIntFloat.test_8_bitsc                 C   sJ   t jt jt jf}dt jdfdt jddt jffdt jdff}|  ||¡ d S )Nr   )r   r   g       6r   l   ÿÿ ç      ð?)é  €?r%   r$   )r   Zuint32Úint32Zfloat32Únanr   r"   r   r   r   Útest_32_bits+   s    

þzTestViewIntFloat.test_32_bitsc                 C   sJ   t jt jt jf}dt jdfdt jddt jffdt jdff}|  ||¡ d S )Nr   )r   r   g       r   l   ÿÿÿÿ r$   )ì         € r)   r$   )r   Zuint64Úint64Zfloat64r'   r   r"   r   r   r   Útest_64_bits3   s    

þzTestViewIntFloat.test_64_bitsc              	      sV   t td tjj¡ƒ‰ t‡ fdd„ƒ}|  t¡�}|ƒ  W 5 Q R X |  	dt
|jƒ¡ d S )Nzint{}c                     s   d} |   ˆ ¡ d S )Nr   r   )r   ©Zinttyr   r   ÚmyviewA   s    z=TestViewIntFloat.test_python_scalar_exception.<locals>.myviewz\'view' can only be called on NumPy dtypes, try wrapping the variable 'a' with 'np.<dtype>()')Úgetattrr   Úformatr   ZintpZbitwidthr   ÚassertRaisesr   ÚassertInÚstrÚ	exception)r   r-   Úer   r,   r   Útest_python_scalar_exception>   s    þz-TestViewIntFloat.test_python_scalar_exceptionc              	   C   sJ   |   t¡�$}tt|d |d ƒƒ}|dƒ W 5 Q R X |  dt|jƒ¡ d S )Nr   r   zOChanging the dtype of a 0d array is only supported if the itemsize is unchanged)r0   r   r   r   r1   r2   r3   )r   Úpairr4   r   r   r   r   Údo_testing_exceptionsL   s    þz&TestViewIntFloat.do_testing_exceptionsc                 C   s,   t jt jft jt jffD ]}|  |¡ qd S r   )r   r&   r!   r7   ©r   r6   r   r   r   Útest_exceptions32T   s    z"TestViewIntFloat.test_exceptions32c                 C   s,   t jt jft jt jffD ]}|  |¡ qd S r   )r   r&   r*   r7   r8   r   r   r   Útest_exceptions64X   s    z"TestViewIntFloat.test_exceptions64N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r#   r(   r+   r5   r7   r9   r:   r   r   r   r   r      s   r   )Únumpyr   Znumbar   Z
numba.corer   Znumba.core.errorsr   Znumba.tests.supportr   r   r   r   r   r   r   Ú<module>   s   