a
    —§»aÀ  ã                   @   sp   d dl Z d dlmZ d dlZd dlmZ d dlmZm	Z	m
Z
 d dlZdd„ ZG dd„ deƒZG d	d
„ d
eƒZdS )é    N)Úproduct)Újit)ÚTestCaseÚtagÚneeds_lapackc                 C   s
   t  | ¡S ©N)ÚnpÚroots)Úp© r   úU/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/numba/tests/test_polynomial.pyÚroots_fn   s    r   c                   @   s@   e Zd ZdZejejejejfZ	dd„ Z
efdd„Zdd„ ZdS )	ÚTestPolynomialBasezV
    Provides setUp and common data/error modes for testing polynomial functions.
    c                 C   s   t  ¡  d S r   )ÚgcZcollect)Úselfr   r   r   ÚsetUp   s    zTestPolynomialBase.setUpc                 C   sH   |   |¡�}||Ž  W d   ƒ n1 s(0    Y  |  |t|jƒ¡ d S r   )ÚassertRaisesZassertInÚstrÚ	exception)r   ÚcfuncÚargsÚmsgÚerrZraisesr   r   r   Úassert_error   s    &zTestPolynomialBase.assert_errorc                 C   s   d}|   |||¡ d S )NzInput must be a 1d array.©r   )r   r   r   r   r   r   r   Úassert_1d_input    s    z"TestPolynomialBase.assert_1d_inputN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úfloat64Úfloat32Ú
complex128Z	complex64Údtypesr   Ú
ValueErrorr   r   r   r   r   r   r      s
   r   c                   @   s    e Zd Zdd„ Zedd„ ƒZdS )Ú
TestPoly1Dc                 C   s   |d }|   |||¡ d S )Nz+() argument must not cause a domain change.r   )r   Únamer   r   r   r   r   r   Úassert_no_domain_change'   s    z"TestPoly1D.assert_no_domain_changec              
      s�  t dd�tƒ‰ t tj¡j‰‡ ‡‡fdd„}t dg¡t g d¢¡t g d¢¡t g d¢¡t g d	¢¡t g d
¢¡t g d¢¡f}t|tjtj	gt
ˆjƒ ƒD ]\}}| |¡}||ƒ qžt dg¡t g d¢¡t g d¢¡t g d¢¡t g d¢¡t g d¢¡t g d¢¡f}t|ˆjdd … ƒD ]\}}| |¡}||ƒ �q$ˆ ˆ t d¡ dd¡f¡ t g d¢¡}ˆ dˆ |f¡ ˆ | tj¡ƒ d S )NT)Znopythonc                    s˜   t | fi |¤Ž}ˆ | fi |¤Ž}| jˆjv r<t | j¡j}nˆ}tjj||d| d| d� ˆ ¡ �  ˆ | fi |¤Ž W d   ƒ n1 sŠ0    Y  d S )Né
   éd   )ZrtolZatol)	r   Údtyper#   r   ÚfinfoÚ
resolutionZtestingZassert_allcloseZassertNoNRTLeak)ÚaÚkwargsÚexpectedÚgotr,   ©r   Zdefault_resolutionr   r   r   Úcheck2   s    ü
z$TestPoly1D.test_roots.<locals>.checké   )r3   é   é   )r   r   r   )r3   é   é   r6   )r   r   r   r3   r4   r5   )r3   r3   r   r   r   )r   r   r3   r   r   r   ù      ð?      ð?)r3   y      @      ð?r5   )r   y                r   )r3   y      @      ð?r7   r6   )r   r   r   r8   r4   r5   )r8   r3   r   r   r   )r   r   r8   r   r   r   r5   g      @)g      @g       @g        g      ð?Zeigvals)r   r   r   r+   r    r,   Úarrayr   Úint32Úint64Úlistr#   Zastyper   ZarangeZreshaper'   r"   )r   r2   Z	r_vectorsÚvr*   r-   Z	c_vectorsÚxr   r1   r   Ú
test_roots+   s<    
ùÿ



ù
zTestPoly1D.test_rootsN)r   r   r   r'   r   r?   r   r   r   r   r%   %   s   r%   )r   Ú	itertoolsr   Únumpyr   Znumbar   Znumba.tests.supportr   r   r   Zunittestr   r   r%   r   r   r   r   Ú<module>   s   