U
    9%e                     @   s  d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZmZmZmZ ed	\ZZZed
eeZedeeZedeeZedee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d Z&d S )!    )Matrixeye)
ShapeError)MatAdd)Identity	OneMatrix
ZeroMatrix)symbols)raiseswarns_deprecated_sympy)MatrixSymbol)HadamardProducthadamard_productHadamardPowerhadamard_powerzn,m,kZABCc                  C   s   t tttjtjkstttdd  ttdd  t tdt t d dtd  td  td  ksjtt tt tt } | jt	t
fksttt tttjjtjtjtjhkstd S )Nc                   S   s
   t ttS N)r   r   n r   r   m/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/matrices/expressions/tests/test_hadamard.py<lambda>       z&test_HadamardProduct.<locals>.<lambda>c                   S   s
   t tdS )N   )r   r   r   r   r   r   r      r      r   r   )r   r   r   shapeAssertionErrorr
   	TypeErrorr   r   r   ksetTargs)Zmixr   r   r   test_HadamardProduct   s    r&   c                   C   s   t ttt ttkstd S r   )r   r   r   r    r   r   r   r   %test_HadamardProduct_isnt_commutative!   s    r'   c                  C   sn   t ddd} t ddd}t ddd}| t|| d | d |d  |d  | d |d  |d   ksjtd S )NXr   Yr   r   r   r   r   r   r   )r   r   r    )r(   r)   r   r   r   r   test_mixed_indexing%   s    .r-   c               	   C   s   t ddd} t ddd}t  t| dd}W 5 Q R X t|tsDt| }t|t sZttdd}tdd}t||  |kstt|| | | t| dkstt| || t| |kstt| ||| |kstd S )Nr(   r   r)   F)check)	r   r   r   
isinstancer    doitr   r   r   )r(   r)   exprZexpr2r   Ur   r   r   test_canonicalize.   s    

 r3   c            	      C   s  t ddd\} }}td| |}td| |}td| | }t| }ttdd  t||ks\ttt||tsptt||	 t||kstt||t||ksttt||tsttd	t
d
}ttt
d
tt
d
}t||}|	 |kstttdd  d S )Nm, n, pTintegerr   r   r(   c                   S   s   t  S r   )r   r   r   r   r   r   E   r   ztest_hadamard.<locals>.<lambda>ar   c                   S   s   t  S r   r   r   r   r   r   r   Q   r   )r	   r   r   r
   r!   r   r    r/   r   r0   r"   r   r   r   
ValueError)	mr   pr   r   r(   Ir7   r1   r   r   r   test_hadamard>   s     
r=   c                  C   s   t ddd } t ddd }t ddd}t| |}tdd t| |D dd}||ksbtt| ||}|t||kstttd| }|t| d ddgd| d	 dgdd| d
 ggkstttdtd}|tdkstd S )Nr      r   r(   c                 S   s   g | ]\}}|| qS r   r   ).0ijr   r   r   
<listcomp>Y   s     z;test_hadamard_product_with_explicit_mat.<locals>.<listcomp>r*   r   r   )r   r   )	r   as_explicitr   r   zipZreshaper    r   r   )r   r   r(   r1   retr   r   r   'test_hadamard_product_with_explicit_matT   s    
 4rF   c                     s   t ddd\} }}td| | t d ks0ttt dtsDtt |jt j|ks`tt |d  d | ks~tt| || | ksttt fdd	 d S )
Nr4   Tr5   r   r   r   r*   c                      s
   t   S r   )r   r   r   r   r   r   l   r   z%test_hadamard_power.<locals>.<lambda>)	r	   r   r   r    r/   r   r$   r
   r9   )r:   r   r;   r   rG   r   test_hadamard_powerc   s    rH   c                  C   s"  t ddd} t ddd}td\}}t|||| ks:tt|| t||d  ||d  g||d  ||d  ggkstt| | t| d | | d | g| d | | d | ggkstt| | t| d |d  | d |d  g| d |d  | d |d  ggkstd S )	Nr   r   r   za br*   r+   r,   r   )r   r	   r   r    rC   r   )r   r   r7   br   r   r   test_hadamard_power_explicito   s,    rJ   c                      sx   t ddd t dddtt fdd tt fdd t ddd tt fdd tt fd	d d S )
Nr   r   r>   r   c                      s
   t  S r   r8   r   r   r   r   r   r      r   z"test_shape_error.<locals>.<lambda>c                      s
   t  S r   r   r   rK   r   r   r      r   c                      s
   t  S r   r8   r   rK   r   r   r      r   c                      s
   t  S r   rL   r   rK   r   r   r      r   )r   r
   r   r   r   rK   r   test_shape_error   s    rM   N)'Zsympy.matrices.denser   r   Zsympy.matrices.commonr   Z!sympy.matrices.expressions.mataddr   Z"sympy.matrices.expressions.specialr   r   r   Z
sympy.corer	   Zsympy.testing.pytestr
   r   Zsympy.matricesr   Zsympy.matrices.expressionsr   r   r   r   r   r:   r"   r   r   r   r   r&   r'   r-   r3   r=   rF   rH   rJ   rM   r   r   r   r   <module>   s*   	