o
    oh*                     @   s  d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZmZ d d	lmZ d d
l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m Z m!Z!m"Z"m#Z#m$Z$m%Z% d dl&m'Z' d dl(m)Z) d dl*m+Z+m,Z, d dl-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 d dl5m6Z6 d dl7m8Z8m9Z9m:Z:m;Z; d dl<m=Z=m>Z>m?Z?m@Z@mAZAmBZB d dlCmDZD d dlEmFZFmGZG d dlHmIZI eIdZJeIdZKeJreJLeJMg jNZOeOjPZQdd ZRdd ZSdd  ZTd!d" ZUd#d$ ZVd%d& ZWd'd( ZXd)d* ZYd+d, ZZd-d. Z[d/d0 Z\d1d2 Z]d3d4 Z^d5d6 Z_d7d8 Z`d9d: Zad;d< Zbd=d> Zcd?d@ ZddAdB ZedCdD ZfdEdF ZgdGdH ZhdIdJ ZidKdL ZjdMdN ZkdOS )P    )Sum)Mod)Equality
Unequality)Symbol)sqrt)	Piecewise)	polygamma)SiCi)BlockMatrix)MatrixSymbol)Identity)lambdify)symbolsMinMax)xijabcd)Pow)MatrixSolve)	logaddexp
logaddexp2)log1pexpm1hypotlog10exp2log2Sqrt)Array)ArrayTensorProductArrayAddPermuteDimsArrayDiagonal)NumPyPrinterSciPyPrinter_numpy_known_constants_numpy_known_functions_scipy_known_constants_scipy_known_functions)convert_matrix_to_array)skipraises)import_modulenumpyjaxc                  C   sD   t  } tdtdk fd}| |dksJ | jdh diks J dS )z
    NumPyPrinter needs to print Piecewise()'s choicelist as a list to avoid
    breaking compatibility with numpy 1.8. This is not necessary in numpy 1.9+.
    See gh-9747 and gh-9749 for details.
       r   )r   Tz?numpy.select([numpy.less(x, 0),True], [1,0], default=numpy.nan)r4   >   nanlessselectN)r*   r   r   doprintmodule_imports)printerp r>   s/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/printing/tests/test_numpy.pytest_numpy_piecewise_regression%   s   r@   c                  C   s@   t tt} t | dksJ ttt}t |dksJ d S )Nznumpy.logaddexp(a, b)znumpy.logaddexp2(a, b))r   r   r   r*   r:   r   )laelae2r>   r>   r?   test_numpy_logaddexp1   s   

rC   c               	      s   t std ttt tttf} ttttf| d}d\}}t ddd t 	||| t
 fddt||d D s>J ttt tttf} ttttf| d}d\}}t ddd t 	||| t
 fd	dt||d D svJ d S )
NNumPy not installedr4   r   
   r6   rF   c                 3   s    | ]} | V  qd S Nr>   .0i_x_r>   r?   	<genexpr>A       ztest_sum.<locals>.<genexpr>c                 3   s    | ]}|  V  qd S rH   r>   rI   rL   r>   r?   rN   H   rO   )npr1   r   r   r   r   r   r   linspaceallclosesumrangesfa_b_r>   rL   r?   test_sum8   s   48rZ   c               	      s   t std ttt t tttfttt	f} t
tttt	tf| d}d\}}d\ t dddt ||| t fdd	t||d D sNJ d S )
NrD   r4   rE   )      rG   r6   rF   c                 3   s0    | ]}t  d  D ]	}| | V  qqdS )r6   N)rT   )rJ   rK   j_c_d_rM   r>   r?   rN   V   s   . z%test_multiple_sums.<locals>.<genexpr>)rP   r1   r   r   r   r   r   r   r   r   r   rQ   rR   rS   rT   rU   r>   r^   r?   test_multiple_sumsK   s    "ra   c                  C   s   t std tddd} tddd}t| | }t| |f|d}t ddgddgg}t dd	gd
dgg}|||t ||k sEJ d S )NrD   M   Nr4   r6         rG   )rP   r1   r   r0   r   arraymatmulall)rb   rd   cgrW   mambr>   r>   r?   test_codegen_einsumY   s   "rn   c            
   
   C   sx  t std tddd} tddd}tddd}tddd}t ddgdd	gg}t dd
gddgg}t ddgddgg}t ddgd	dgg}t| |}t| |f|d}	|	||t |ddg|ddgk slJ t| |}t| |f|d}	|	|||| k sJ t| ||}t| ||f|d}	|	||||| | k sJ t| |||}t| |||f|d}	|	|||||| | | k sJ t	| ddg}t| f|d}	|	||j
k sJ t	t| |g d}t| |f|d}	|	||t t |ddg|ddgdk sJ tt| |d}t| |f|d}	|	||t jt |ddg|ddgdddk s:J d S )NrD   rb   rc   rd   PQr6   re   rf   rg   rG   r      r4   )r6   rc   re   r   r6   rc   )axis1axis2)rP   r1   r   rh   r&   r   einsumrj   r'   r(   T	transposer)   diagonal)
rb   rd   ro   rp   rl   rm   mcmdrk   rW   r>   r>   r?   test_codegen_extrah   s>   
*
 &4<r{   c                  C   sp  t std ttd} ttf| }t g d}t ||g ds$J ttd} ttf| }t g d}t ||g dsBJ tdk } ttf| }t g d}t ||g ds_J tdk} ttf| }t g d}t ||g ds|J tdk} ttf| }t g d}t ||g dsJ tdk} ttf| }t g d}t ||g d	sJ d S )
NrD   r6   )r   r6   rc   )FTF)TFT)TFF)TTF)FFT)FTT)rP   r1   r   r   r   rh   array_equalr   )erW   rM   r>   r>   r?   test_relational   s4   

r~   c                  C   s   t std ttt} tttf| }t g d}d}t |||g ds(J t g d}t g d}t |||g dsCJ t g d}t g d}t |||g ds^J d S )NrD   )r   r6   rc   re   rc   )r   r6   r   r6   )rc   rc   rc   rc   )rc   re   rf      )r   r   r   r   )rP   r1   r   r   r   r   rh   r|   )r}   rW   rX   rY   r>   r>   r?   test_mod   s   
r   c                  C   s8   t std tdddd} tg | d}| dksJ d S )NrD   rc   rG   F)evaluater4   g      ?)rP   r1   r   r   )exprrW   r>   r>   r?   test_pow   s
   r   c                  C   sB   t std ttfttd} t| dd d dt ksJ d S )NrD   r4   g|=g#B;)rP   r1   r   r   r   absNUMPY_DEFAULT_EPSILONrW   r>   r>   r?   
test_expm1   s   $r   c                  C   s>   t std ttfttd} t| dd dt ksJ d S )NrD   r4   g>N}a+)rP   r1   r   r   r   r   r   r   r>   r>   r?   
test_log1p   s    r   c                   C   s<   t std ttttftttdddd tksJ d S )NrD   r4   re   rf   r   )rP   r1   r   r   r   r   r    r   r>   r>   r>   r?   
test_hypot   s   0r   c                   C   6   t std tttfttddd tksJ d S )NrD   r4   d   rc   )rP   r1   r   r   r   r!   r   r>   r>   r>   r?   
test_log10      *r   c                   C   r   )NrD   r4   r       )rP   r1   r   r   r   r"   r   r>   r>   r>   r?   	test_exp2   r   r   c                   C   r   )NrD   r4         )rP   r1   r   r   r   r#   r   r>   r>   r>   r?   	test_log2   r   r   c                   C   r   NrD   r4   rf   rc   )rP   r1   r   r   r   r$   r   r>   r>   r>   r?   	test_Sqrt   r   r   c                   C   r   r   )rP   r1   r   r   r   r   r   r>   r>   r>   r?   	test_sqrt  r   r   c                  C   s   t std tddd} tddd}| d | | }t| || }t| |f|}t| |f|}t g dg dg d	g}t j|dksGJ t g d
}t ||||||s\J d S )NrD   rb   re   r   r6   rG   r6   rc   re   )re   rc   r   )r      rq   )re   rf   r   )	rP   r1   r   r   r   rh   linalgmatrix_rankrR   )rb   r   r   matsolve_exprrW   
f_matsolvem0x0r>   r>   r?   test_matsolve
  s    r   c                  C   sz   t std tddd} tddd}tddd}tddd}t| |g||gg}|jdks/J t }||d	ks;J d S )
NrD   a_1rF   re   a_2a_3a_4)   r   z%numpy.block([[a_1, a_2], [a_3, a_4]]))rP   r1   r   r   shaper*   r:   )r   r   r   r   Ar<   r>   r>   r?   
test_16857  s   r   c                     s   t std tddd} t| | td }t ddgddgg}t ddgddgg}|||k s5J dd	lm} |d
ddtd t	t
 fdd d S )NrD   rb   rc   r6   re   rf   r   r   )r   nT)integerc                      s   t   t S rH   )r   r   r>   rd   r   r>   r?   <lambda>=  s    z"test_issue_17006.<locals>.<lambda>)rP   r1   r   r   r   rh   rj   sympy.core.symbolr   r2   NotImplementedError)rb   rW   rl   mrr   r>   r   r?   test_issue_17006.  s   r   c            	      C   s   t std td\} }}t| ||t| || }t| ||f|d}d\}}t j|t j|}}t	|| || s?J t	|| || sKJ d S )NzJax not installedzx y zr5   )r   )rf   r   r   )
r5   r1   r   r   r   r   r4   asarrayrP   rR   )	r   yzr   funcinput_tuple1input_tuple2input_array1input_array2r>   r>   r?   test_jax_tuple_compatibility?  s   r   c                   C   s4   t  tddksJ t  tddksJ d S )N)rr   )re   r   znumpy.array([[1, 2], [3, 5]])rr   znumpy.array((1, 2)))r*   r:   r%   r>   r>   r>   r?   test_numpy_arrayK  s   r   c                   C   D   t d dksJ t d dksJ td dksJ td dks J d S )	NNaNz	numpy.nan
EulerGammaznumpy.euler_gammaacosznumpy.arccoslogz	numpy.log)r,   r-   r>   r>   r>   r?   test_numpy_known_funcs_constsO     r   c                   C   r   )	NGoldenRatiozscipy.constants.golden_ratioPizscipy.constants.pierfzscipy.special.erf	factorialzscipy.special.factorial)r.   r/   r>   r>   r>   r?   test_scipy_known_funcs_constsV  r   r   c                  C   s&   t  } t| ds
J t| dsJ d S )N_print_acos
_print_log)r*   hasattr)prntrr>   r>   r?   test_numpy_print_methods]  s   r   c                  C   s   t  } t| ds
J t| dsJ t| dsJ t| dsJ t| ds&J tdddd}td	dd
}| t||dks?J | t|dksJJ | t|dksUJ d S )Nr   r   
_print_erf_print_factorial_print_chebyshevtkT)r   nonnegativer   )realzscipy.special.polygamma(k, x)zscipy.special.sici(x)[0]zscipy.special.sici(x)[1])r+   r   r   r:   r	   r
   r   )r   r   r   r>   r>   r?   test_scipy_print_methodsb  s   r   N)lsympy.concrete.summationsr   sympy.core.modr   sympy.core.relationalr   r   r   r   (sympy.functions.elementary.miscellaneousr   $sympy.functions.elementary.piecewiser   'sympy.functions.special.gamma_functionsr	   'sympy.functions.special.error_functionsr
   r   &sympy.matrices.expressions.blockmatrixr   "sympy.matrices.expressions.matexprr   "sympy.matrices.expressions.specialr   sympy.utilities.lambdifyr   sympyr   r   r   	sympy.abcr   r   r   r   r   r   r   
sympy.corer   sympy.codegen.matrix_nodesr   sympy.codegen.numpy_nodesr   r   sympy.codegen.cfunctionsr   r   r    r!   r"   r#   r$   sympy.tensor.arrayr%   0sympy.tensor.array.expressions.array_expressionsr&   r'   r(   r)   sympy.printing.numpyr*   r+   r,   r-   r.   r/   3sympy.tensor.array.expressions.from_matrix_to_arrayr0   sympy.testing.pytestr1   r2   sympy.externalr3   rP   r5   finforh   dtypedeafult_float_infoepsr   r@   rC   rZ   ra   rn   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r>   r>   r>   r?   <module>   sn    $$ *)	