a
    Lf                     @   s   d Z ddlZddlmZ ddlmZ ddlmZm	Z	m
Z
 G dd dZG dd dZejd	ejg d
ddeg d
fG dd dZG dd dZG dd dZG dd dZdd Zdd Zdd Zdd Zdd ZdS )zE
Tests related to the ``symbol`` attribute of the ABCPolyBase class.
    N)array)assert_equalassert_raisesassert_c                   @   st   e Zd ZdZg dZdd Zejdde	fde	fde
fd	e
ffd
d Zejdddd Zdd Zdd ZdS )TestInitz5
    Test polynomial creation with symbol kwarg.
             c                 C   s   t | j}t|jd d S )Nxpoly
Polynomialcr   symbolselfp r   [/var/www/ai-form-bot/venv/lib/python3.9/site-packages/numpy/polynomial/tests/test_symbol.pytest_default_symbol   s    zTestInit.test_default_symbol)	bad_input	exception 3Nr   c                 C   s>   t |  tj| j|d}W d    n1 s00    Y  d S )Nr   )pytestraisesr   r   r   )r   r   r   r   r   r   r   test_symbol_bad_input   s    zTestInit.test_symbol_bad_inputr   )r   Zx_1AZxyzu   βc                 C   s    t j| j|d}t|j| dS )zF
        Values for symbol that should pass input validation.
        r   Nr   )r   r   r   r   r   r   test_valid_symbols   s    zTestInit.test_valid_symbolsc                 C   sD   t j| jdd}tt d|_W d   n1 s60    Y  dS )z2
        'symbol' attribute is read only.
        r   r   zN)r   r   r   r   r   AttributeErrorr   r   r   r   r   test_property-   s    zTestInit.test_propertyc                 C   s0   t j| jdd}t j|jdd}t|jd d S )Nyr   t)r   r   r   Zcoefr   r   )r   r   ptr   r   r   test_change_symbol5   s    zTestInit.test_change_symbol)__name__
__module____qualname____doc__r   r   r   markparametrize
ValueError	TypeErrorr   r    r#   r'   r   r   r   r   r      s   

r   c                   @   s>   e Zd Zejg dddZdd Zdd Zdd	 Zd
d Z	dS )TestUnaryOperatorsr   r!   r   c                 C   s   | j  }t|jd d S Nr!   r   r   r   )r   nr   r   r   test_neg?   s    zTestUnaryOperators.test_negc                 C   s   | j d }t|jd d S N
   r!   r2   r   outr   r   r   test_scalarmulC   s    
z!TestUnaryOperators.test_scalarmulc                 C   s   d| j  }t|jd d S r5   r2   r7   r   r   r   test_rscalarmulG   s    
z"TestUnaryOperators.test_rscalarmulc                 C   s   | j d }t|jd d S )Nr
   r!   r2   r7   r   r   r   test_powK   s    
zTestUnaryOperators.test_powN)
r(   r)   r*   r   r   r   r4   r9   r:   r;   r   r   r   r   r0   <   s
   r0   rhs         r!   r   c                   @   sb   e Zd ZdZejg d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d ZdS )TestBinaryOperatorsSameSymbolzc
    Ensure symbol is preserved for numeric operations on polynomials with
    the same symbol
    r   r!   r   c                 C   s   | j | }t|jd d S r1   r2   r   r<   r8   r   r   r   test_add^   s    
z&TestBinaryOperatorsSameSymbol.test_addc                 C   s   | j | }t|jd d S r1   r2   rB   r   r   r   test_subb   s    
z&TestBinaryOperatorsSameSymbol.test_subc                 C   s   | j | }t|jd d S r1   r2   rB   r   r   r   test_polymulf   s    
z*TestBinaryOperatorsSameSymbol.test_polymulc                 C   s"   t | j|D ]}t|jd qd S r1   divmodr   r   r   rB   r   r   r   test_divmodj   s    z)TestBinaryOperatorsSameSymbol.test_divmodc                 C   s   || j  }t|jd d S r1   r2   rB   r   r   r   	test_raddn   s    
z'TestBinaryOperatorsSameSymbol.test_raddc                 C   s   || j  }t|jd d S r1   r2   rB   r   r   r   	test_rsubr   s    
z'TestBinaryOperatorsSameSymbol.test_rsubc                 C   s   || j  }t|jd d S r1   r2   rB   r   r   r   	test_rmulv   s    
z'TestBinaryOperatorsSameSymbol.test_rmulc                 C   s"   t || jD ]}t|jd qd S r1   rF   rB   r   r   r   test_rdivmodz   s    z*TestBinaryOperatorsSameSymbol.test_rdivmodN)r(   r)   r*   r+   r   r   r   rC   rD   rE   rH   rI   rJ   rK   rL   r   r   r   r   rA   P   s   rA   c                   @   s^   e Zd Zejg dddZejg dddZejejej	ej
ejfZejdedd Zd	S )
"TestBinaryOperatorsDifferentSymbolr   r   r   r=   r$   fc                 C   s   t t|| j d S )N)r   r.   other)r   rN   r   r   r   test_binops_fails   s    z4TestBinaryOperatorsDifferentSymbol.test_binops_failsN)r(   r)   r*   r   r   r   rO   __add____sub____mul____floordiv____mod__opsr   r,   r-   rP   r   r   r   r   rM      s
   rM   c                   @   s.   e Zd Zejg dddZdd Zdd ZdS )	TestEqualityr   r   r   c                 C   s$   t jg ddd}t| j|k d S )Nr   r   r   r   r   r   r   r   rO   r   r   r   test_eq   s    zTestEquality.test_eqc                 C   s&   t jg ddd}t| j|k  d S )Nr   r$   r   rX   rY   r   r   r   test_neq   s    zTestEquality.test_neqN)r(   r)   r*   r   r   r   rZ   r[   r   r   r   r   rW      s   rW   c                   @   s|   e Zd ZdZejg dddZdd Zdd Zd	d
 Z	e
jddddgidddgidejifdd Zdd Zdd ZdS )TestExtraMethodszJ
    Test other methods for manipulating/creating polynomial objects.
    )r   r	   r
   r   r!   r   c                 C   s   | j  }t|jd d S r1   )r   copyr   r   rY   r   r   r   	test_copy   s    
zTestExtraMethods.test_copyc                 C   s   | j  }t|jd d S r1   )r   Ztrimr   r   rY   r   r   r   	test_trim   s    
zTestExtraMethods.test_trimc                 C   s   | j d}t|jd d S )Nr	   r!   )r   truncater   r   rY   r   r   r   test_truncate   s    zTestExtraMethods.test_truncatekwargdomainir6   windowkindc                 C   s"   | j jf i |}t|jd d S r1   )r   convertr   r   )r   rb   rO   r   r   r   test_convert   s    zTestExtraMethods.test_convertc                 C   s   | j  }t|jd d S r1   )r   Zintegr   r   rY   r   r   r   
test_integ   s    
zTestExtraMethods.test_integc                 C   s   | j  }t|jd d S r1   )r   Zderivr   r   rY   r   r   r   
test_deriv   s    
zTestExtraMethods.test_derivN)r(   r)   r*   r+   r   r   r   r^   r_   ra   r   r,   r-   Z	Chebyshevrg   rh   ri   r   r   r   r   r\      s   


r\   c                  C   s>   t jg ddd} t jg ddd}| |}|jdks:J d S )N)r
   r	   r   r%   r   )r?   r   r   u   λ_1)r   r   r   )r   qrr   r   r   test_composition   s    rm   c                  C   s6   t dfd \} }tjj| |ddd}t|jd d S )Nr6   r	   r   r!   )degr   )ranger   r   fitr   r   )r   r$   r   r   r   r   test_fit   s    rq   c                  C   s(   ddg} t jj| dd}t|jd d S )Nr	   r!   r   )r   r   Z	fromrootsr   r   )rootsr   r   r   r   test_froomroots   s    rt   c                  C   s*   t jjddgddgdd} t| jd d S )Nrj   r   r?      r!   )rc   rd   r   )r   r   identityr   r   r   r   r   r   test_identity   s    rx   c                  C   s    t jjddd} t| jd d S )Nr
   r!   r   )r   r   Zbasisr   r   rw   r   r   r   
test_basis   s    ry   )r+   r   Znumpy.polynomialZ
polynomialr   Znumpy._corer   Znumpy.testingr   r   r   r   r0   r,   r-   r   rA   rM   rW   r\   rm   rq   rt   rx   ry   r   r   r   r   <module>   s*   1
(
$