o
    8ήc                     @   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   B/tmp/pip-target-vg8gfxp4/lib/python/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   )gccollect)selfr   r   r   setUp   s   zTestPolynomialBase.setUpc                 C   sH   |  |}||  W d    n1 sw   Y  | |t|j d S r   )assertRaisesassertInstr	exception)r   cfuncargsmsgerr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
complex128	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 ]\}}||}|| qOt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)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    d S 1 sFw   Y  d S )N
   d   )rtolatol)	r   dtyper'   r   finfo
resolutiontestingassert_allcloseassertNoNRTLeak)akwargsexpectedgotr3   r   default_resolutionr   r   r   check2   s   
"z$TestPoly1D.test_roots.<locals>.check   )r>         )r   r   r   )r>         rA   )r   r   r   r>   r?   r@   )r>   r>   r   r   r   )r   r   r>   r   r   r         ?      ?)r>   y      @      ?r@   )r   y                r   )r>   y      @      ?rB   rA   )r   r   r   rC   r?   r@   )rC   r>   r   r   r   )r   r   rC   r   r   r   r@   g      @)g      @g       @g        g      ?eigvals)r   r   r   r2   r#   r3   arrayr   int32int64listr'   astyper   arangereshaper+   r%   )r   r=   	r_vectorsvr1   r7   	c_vectorsxr   r;   r   
test_roots+   s<   






zTestPoly1D.test_rootsN)r   r    r!   r+   r   rP   r   r   r   r   r)   %   s    r)   )r   	itertoolsr   numpyr   numbar   numba.tests.supportr   r   r   unittestr   r   r)   r   r   r   r   <module>   s    