o
    iW                     @   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 g/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/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 ]F\}}}t ||D ];\}}tt||}t|s2| |||| | |||| 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   J   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   r$   )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                    sj   t tdtjj t fdd}| t}|  W d    n1 s%w   Y  | 	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   s^   |  t}tt|d |d }|d W d    n1 sw   Y  | dt|j d S )Nr   r   zOChanging the dtype of a 0d array is only supported if the itemsize is unchanged)r1   r   r   r   r2   r3   r4   )r   pairr5   r   r   r   r   do_testing_exceptionsL   s   
z&TestViewIntFloat.do_testing_exceptionsc                 C   ,   t jt jft jt jffD ]}| | qd S r   )r   r'   r!   r8   r   r7   r   r   r   test_exceptions32T      z"TestViewIntFloat.test_exceptions32c                 C   r9   r   )r   r'   r+   r8   r:   r   r   r   test_exceptions64X   r<   z"TestViewIntFloat.test_exceptions64N)__name__
__module____qualname____doc__r   r#   r)   r,   r6   r8   r;   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   