o
    GZh                     @   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J ttdd  ttdd  t tdt t d dtd  td  td  ks5J t tt tt } | jtt	fksGJ t
t tttjjtjtjtjhks[J d S )Nc                   S   s
   t ttS N)r   r   n r   r   ]/var/www/auris/lib/python3.10/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   shaper
   	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J d S 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s5J d S )NXr   Yr   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 d    n1 s w   Y  t|ts,J | }t|t s7J tdd}tdd}t||  |ksLJ t|| | | t| dks\J t| || t| |kskJ t| ||| |ksxJ d S )Nr'   r   r(   F)check)r   r   r   
isinstancedoitr   r   r   )r'   r(   exprZexpr2r   Ur   r   r   test_canonicalize.   s   

 r2   c            	      C   s  t ddd\} }}td| |}td| |}td| | }t| }ttdd  t||ks.J tt||ts8J t|| t||ksFJ t||t||ksRJ tt||ts\J td	t	d
}t
tt	d
tt	d
}t||}| |kszJ ttdd  d S )Nm, n, pTintegerr   r   r'   c                   S      t  S r   )r   r   r   r   r   r   E       ztest_hadamard.<locals>.<lambda>ar   c                   S   r6   r   r   r   r   r   r   r   Q   r7   )r	   r   r   r
   r    r   r.   r   r/   r!   r   r   r   
ValueError)	mr   pr   r   r'   Ir8   r0   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s1J t| ||}|t||ks@J ttd| }|t| d ddgd| d	 dgdd| d
 ggksaJ ttdtd}|tdksrJ 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'   r0   retr   r   r   'test_hadamard_product_with_explicit_matT   s   
 4rG   c                     s   t ddd\} }}td| | t d ksJ tt dts"J t |jt j|ks0J t |d  d | ks?J t| || | ksJJ tt fdd	 d S )
Nr3   Tr4   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:   )r;   r   r<   r   rH   r   test_hadamard_powerc   s   rI   c                  C   s   t ddd} t ddd}td\}}t|||| ksJ t|| t||d  ||d  g||d  ||d  ggks@J t| | t| d | | d | g| d | | d | ggkscJ t| | t| d |d  | d |d  g| d |d  | d |d  ggksJ d S )	Nr   r   r   za br)   r*   r+   r   )r   r	   r   rD   r   )r   r   r8   br   r   r   test_hadamard_power_explicito   s,   rK   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                      
   t  S r   r9   r   r   r   r   r   r      r   z"test_shape_error.<locals>.<lambda>c                      rL   r   r   r   rM   r   r   r      r   c                      rL   r   r9   r   rM   r   r   r      r   c                      rL   r   rN   r   rM   r   r   r      r   )r   r
   r   r   r   rM   r   test_shape_error   s   rO   N)'Zsympy.matrices.denser   r   Zsympy.matrices.exceptionsr   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,   r2   r>   rG   rI   rK   rO   r   r   r   r   <module>   s,    	