
    XhG                        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mZmZ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 d dlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 d dl7m8Z8 d dl9m:Z:m;Z; d dl<m=Z=m>Z>m?Z? d dl@mAZA d dlBmCZCmDZDmEZEmFZFmGZG d dlHmIZI d dlJmKZKmLZL d dlMmNZNmOZO d dlPmQZQmRZR d dlSmTZTmUZUmVZVmWZWmXZX d dlYmZZZ d dl[m\Z\  ed          \  Z]Z^Z_ eQd          Z`d Zad Zbd Zcd Zdd Zed Zfd  Zgd! Zhd" Zid# Zjd$ Zk G d% d&e          Zld' Zmd( Znd) Zod* Zpd+ Zqd, Zrd- Zsd. Ztd/ Zud0 Zvd1 Zwd2 Zxd3 Zyd4S )5    )Not)
Assignment)none)expm1log1p)cosm1)MatrixSolve)
ExprModsymbolsEqLeGtzooooRationalPow)
Derivative)pi)S)acosKroneckerDelta	PiecewisesignsqrtMinMaxcotacschaseccothseclogsincostanasinatansinhcoshtanhasinhacoshatanh)atan2)AndOr)SparseMatrixMatrixSymbolIdentity)PrintMethodNotImplementedError)MpmathPrinterCmathPrinterPythonCodePrinterpycodeSymPyPrinter)TensorflowPrinter)NumPyPrinterSciPyPrinter)raisesskip)IndexedBaseIdx)ArraySymbolArrayDiagonalArrayContraction	ZeroArrayOneArray)import_module)loggammazx y zpc            
      
   t                      } | j        rJ |                     t          t          z            dk    sJ |                     t          t          d                    dk    sJ |                     t          t          t                               dk    sJ |                     t          t           t                              dk    sJ |                     t          t          t                              dk    sJ |                     t          t          t                              dk    sJ |                     dt          t          z   z            d	k    sJ |                     t          t                              d
k    sJ | j        rJ |                     t                    dk    sJ | j        ddhik    sJ |                     t          t          dd          z            dk    sJ |                     t          t                              dk    sJ | j        dddhik    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t!          t                              dk    sJ |                     t#          t          d                    dk    sJ |                     t%          dt'          t          d          fdt          dk    f                    dk    sJ |                     t%          dt)          t          d          fdt+          t          d          fd                    dk    sJ |                     t-          t                              dk    sJ |                     t.          d                   dk    sJ |                     t1          t          t                              d k    sJ |                     d!          d"k    sJ |                     ddg          d#k    sJ |                     t3          t          t                              d$k    sJ |                     t5          t          t                              d%k    sJ d S )&Nzx**y   zx % 2z-(x % y)z(-x) % yzx and yzx or y   z	1/(x + y)znot xzmath.pimathr   math.sqrt(x)r   zmath.acos(x)z(1/math.tan(x))z;((math.exp(x) + math.exp(-x))/(math.exp(x) - math.exp(-x)))z(math.acos(1/x))z((math.log(math.sqrt(1 + x**(-2)) + 1/x))zx = 2r      z/((1) if (x == 0) else (2) if (x > 6) else None)   Fevaluatez/((2) if (x <= 0) else (3) if (x > 0) else None)z((0.0 if x == 0 else math.copysign(1, x))r   rL   zp[0, 1]z(1 if x == y else 0)rK   rP   z(2, 3)z[2, 3]z	min(x, y)z	max(x, y))r8   module_importsdoprintxyr   r0   r1   r   r   r   r   r   r   r!   r    r   r   r   r   r   r   r   rI   r   r   r   prntrs    r/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/sympy/printing/tests/test_pycode.pytest_PythonCodePrinterr\   !   sz   E####==A&((((==Q##w....==#a))$$
2222==aR$$
2222==Q##y0000==Aq""h....==AaC!![0000==Q  G++++####==	))))FTF#33333==HQNN*++~======a!!^3333FT6N#;;;;;==a!!^3333==Q  $55555==a!!%bbbbb==a!!%77777==q""&PPPPP==Aq))**g5555==Ar!Qxx=AaC" " # #&WX X X X==Ar!Qxx=Bq!HH7 7 7 8 8<UU U U U ==a!!%OOOOO==4!!Y....==!,,--1GGGGG==8++++==!A8++++==Q##{2222==Q##{222222    c                  h    t                      } | j        dk    sJ t          t          d            d S )Npython3c                  $    t          ddi          S )Nstandardpython4)r8    r]   r[   <lambda>z1test_PythonCodePrinter_standard.<locals>.<lambda>S   s    0*Y1GHH r]   )r8   ra   r>   
ValueErrorrY   s    r[   test_PythonCodePrinter_standardrf   N   s:    E>Y&&&&
:HHIIIIIr]   c                     t                      } |                     t          t                              dk    sJ |                     t	          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              d	k    sJ |                     t          t                              d
k    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t          t                              dk    sJ |                     t!          t                              dk    sJ d S )Nzcmath.sqrt(x)zcmath.log(x)zcmath.sin(x)zcmath.cos(x)zcmath.tan(x)zcmath.asin(x)zcmath.acos(x)zcmath.atan(x)zcmath.sinh(x)zcmath.cosh(x)zcmath.tanh(x)zcmath.asinh(x)zcmath.acosh(x)zcmath.atanh(x))r7   rV   r   rW   r#   r$   r%   r&   r'   r   r(   r)   r*   r+   r,   r-   r.   rI   s    r[   test_CmathPrinterri   V   s   A99T!WW000099SVV....99SVV....99SVV....99SVV....99T!WW000099T!WW000099T!WW000099T!WW000099T!WW000099T!WW000099U1XX"2222299U1XX"2222299U1XX"2222222r]   c                  .   t                      } |                     t          t                              dk    sJ |                     t	          dd                    dk    sJ |                     t
          j                  dk    sJ |                     t
          j                  dk    sJ |                     t
          j                  dk    sJ |                     t
          j	                  dk    sJ |                     t
          j
                  d	k    sJ |                     t
          j                  d
k    sJ |                     t
          j                  dk    sJ |                     t          t                              dk    sJ d S )Nzmpmath.sign(x)rL   rK   zmpmath.mpf(1)/mpmath.mpf(2)zmpmath.ez	mpmath.piz
mpmath.phizmpmath.eulerz
mpmath.nanz
mpmath.infzmpmath.ninfzmpmath.loggamma(x))r6   rV   r   rW   r   r   Exp1PiGoldenRatio
EulerGammaNaNInfinityNegativeInfinityrH   rh   s    r[   test_MpmathPrinterrr   m   sW   A99T!WW!1111199Xa^^$$(EEEEE99QV
****99QT??k))))99Q]##|333399Q\""n444499QU|++++99QZ  L000099Q'((M999999Xa[[!!%9999999r]   c                     ddl m}  ddlm} ddlm}m}m} ddlm	} ddl
m} ddlm} ddlm}m}	 dd	lm}
m} t)                      }|                    t-          t.                              d
k    sJ t1          ddd          }t1          ddd          }t1          ddd          }t1          ddd          }|                    |dz            dk    sJ |                    |dz            dk    sJ |                    t3          d                    dk    sJ t1          ddd          }t1          ddd          }|                    t5          ||                    dk    sJ |                    t5          ||          |z             dk    sJ |                     |	dd                    dk    sJ |                     |dd                    dk    sJ |                     |dd | |
|f|
|z                                 dk    sJ |                     |||                    dk    sJ |                     |||                    d k    sJ |                     ||                    d!k    sJ |                     ||                    d"k    sJ |                     ||                    d#k    sJ |                     ||                    d$k    sJ |                    t.          dz            d%k    sJ |                    t.          d&z            d'k    sJ t7          ddd()          }|                    |          d*k    sJ |                    t8          j                  d+k    sJ |                    t8          j                  d,k    sJ |                    t8          j                  d-k    sJ |                    t8          j                   d.k    sJ |                    t8          j!                  d/k    sJ |                    t8          j"                  d0k    sJ |                    tG          t.                    dz            d1k    sJ d S )2Nr   )Lambda)Adjoint)
DiagMatrixDiagonalMatrix
DiagonalOf)FunctionMatrix)HadamardProduct)KroneckerProduct)	OneMatrix
ZeroMatrix)abznumpy.sign(x)ArK   BCrL      DrP      znumpy.linalg.inv(A)znumpy.linalg.matrix_power(A, 5)znumpy.eye(3)rW   rX   znumpy.linalg.solve(A, x)znumpy.linalg.solve(A, x) + yznumpy.zeros((2, 3))znumpy.ones((2, 3))z.numpy.fromfunction(lambda a, b: a + b, (4, 5))znumpy.multiply(A, B)znumpy.kron(A, B)z#numpy.conjugate(numpy.transpose(A))z%numpy.reshape(numpy.diag(A), (-1, 1))znumpy.diagflat(C)z"numpy.multiply(D, numpy.eye(3, 4))z	x**(-1.0)z	x**(-2.0)FrQ   z	2**(-1.0)numpy.eznumpy.piznumpy.euler_gammaz	numpy.nanz	numpy.infz
-numpy.infz(numpy.cos(x)**(-1.0))**2)$sympy.core.functionrt   "sympy.matrices.expressions.adjointru   #sympy.matrices.expressions.diagonalrv   rw   rx   %sympy.matrices.expressions.funcmatrixry   #sympy.matrices.expressions.hadamardrz   $sympy.matrices.expressions.kroneckerr{   "sympy.matrices.expressions.specialr|   r}   	sympy.abcr~   r   r<   rV   r   rW   r3   r4   r	   r   r   rk   rl   rn   ro   rp   rq   r"   )rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   rI   r   r   r   r   uvexprs                       r[   test_NumPyPrinterr   |   s   ******::::::\\\\\\\\\\DDDDDDCCCCCCEEEEEEJJJJJJJJA99T!WW0000S!QAS!QAS!QAS!QA99QW!6666699QT???????99Xa[[!!^3333S!QAS!QA99[A&&''+EEEEE99[A&&*++/MMMMM99ZZ1%%&&*?????99YYq!__%%)=====99^^Aq&&!QQ*?*?@@AA89 9 9 999__Q**++/EEEEE99%%a++,,0BBBBB99WWQZZ  $IIIII99ZZ]]##'NNNNN99ZZ]]##':::::99^^A&&''+OOOOO 99QU{****99QU{****q"u%%%D99T??k))))99QV	))))99QT??j((((99Q\""&9999999QU{****99QZ  K////99Q'((L8888 99SVVQY#>>>>>>>r]   c                  d   t          d          } | st          d           ddlm}m} ddlm}  |dt          z  dz   t          dz   d	t          z  dz             } |t          |d          } ||                     ddd                    g d
k    	                                sJ  |d          dk    sJ  |t          dz  t          dz            } |t          |d          } ||                     ddd                    g dk    	                                sJ  |d          dk    sJ d S )Nnumpyznumpy not installed.r   )r   r   )lambdifyg?rP   rL   g      ?)g      ?g      ?g      @r   rK   r   )rL   r   rL      @   )
rG   r?   (sympy.functions.elementary.miscellaneousr   r   sympy.utilities.lambdifyr   rW   linspaceall)r   r   r   r   expr1funcs         r[   test_issue_18770r      s[   '""E %#$$$CCCCCCCC111111CA	1q5#a%!),,E8Aug&&DD1a(())->->->>CCEEEEEDGGqLLLLC1adOOE8AeW%%DDAq))**lll:@@BBBBB477b======r]   c                  <   t                      } t          t                    }d| j        vsJ |                     |          dk    sJ d| j        v sJ t          d | j        D                       rJ t          ddddi          }|                     |          dk    sJ d	| j        v sJ |                     t          j                  d
k    sJ |                     t          j	                  dk    sJ |                     t          j
                  dk    sJ d S )Nr   znumpy.arccos(x)c              3   @   K   | ]}|                     d           V  dS )scipyN)
startswith).0ms     r[   	<genexpr>z$test_SciPyPrinter.<locals>.<genexpr>   s.      CCQ1<<((CCCCCCr]   rK   r   rS   rP   z8scipy.sparse.coo_matrix(([3], ([0], [1])), shape=(2, 5))zscipy.sparsezscipy.constants.golden_ratiozscipy.constants.pir   )r=   r   rW   rU   rV   anyr2   r   rm   rl   rk   )rI   r   smats      r[   test_SciPyPrinterr      s4   A77D!*****99T??/////a&&&&&CC!2BCCCCCCCC1vqk**D99T??BC C C CQ-----99Q]##'EEEEE99QT??2222299QV	))))))r]   c                      t          d          \  t          t          fd           t          z             } | dv sJ d S )Nzif elsec                  ,    t           z   d          S )NT)error_on_reserved)r9   )s1s2s   r[   rd   z,test_pycode_reserved_words.<locals>.<lambda>   s    vb2gFFF r]   )zelse_ + if_zif_ + else_)r   r>   re   r9   )py_strr   r   s    @@r[   test_pycode_reserved_wordsr      sY    YFB
:FFFFFGGGBG__F3333333r]   c                      t          d          \  } }}| |z  }t          |          dk    sJ ||z  }t          |          dk    sJ d S )Nza_{b} b a_{11}za_b*bza_11*b)r   r9   )a_br   a_11r   s       r[   test_issue_20762r      s\    +,,LCDq5D$<<7""""6D$<<8######r]   c                  (   t                      } |                     t          t                    d          dk    sJ |                     dt          t                    z  d          dk    sJ t          ddi          } |                     t          t                    d          d	k    sJ |                     dt          t                    z  d          d
k    sJ t	                      } |                     t          t                    d          dk    sJ |                     t          t                    d          dk    sJ t                      } |                     t          t                    d          dk    sJ |                     t          t                    d          d	k    sJ t                      } |                     t          t                    d          dk    sJ |                     t          t                    d          d	k    sJ t                      } |                     t          t                    d          dk    sJ |                     t          t                    d          d	k    sJ d S )NF)rationalrN   rL   z1/math.sqrt(x)ra   r_   Tzx**(1/2)z	x**(-1/2)zmpmath.sqrt(x)z x**(mpmath.mpf(1)/mpmath.mpf(2))znumpy.sqrt(x)zsympy.sqrt(x))r8   
_print_Powr   rW   r6   r<   r=   r:   rY   s    r[   	test_sqrtr      sV   EDGGe44FFFFAd1ggI66:JJJJJzI677EDGGd33zAAAAAd1ggI55DDDDOOEDGGe448HHHHHDGGd33*+ + + + NNEDGGe44GGGGDGGd33zAAAANNEDGGe44GGGGDGGd33zAAAANNEDGGe44GGGGDGGd33zAAAAAAr]   c                     ddl m}   | t                    }t                      }|                    |          dk    sJ t                      }|                    |          dk    sJ t                      }|                    |          dk    sJ t                      }|                    |          dk    sJ t                      }|                    |          dk    sJ d S )Nr   )fracznumpy.mod(x, 1)zx % 1zmpmath.frac(x)z+sympy.functions.elementary.integers.frac(x))	#sympy.functions.elementary.integersr   rW   r<   rV   r=   r8   r6   r:   )r   r   rZ   s      r[   	test_fracr      s    888888477DNNE=="33333NNE=="33333E=='))))OOE=="22222NNE=="OOOOOOOr]   c                       e Zd Zd Zd ZdS )CustomPrintedObjectc                     dS )Nr   rc   selfprinters     r[   
_numpycodezCustomPrintedObject._numpycode  s    wr]   c                     dS )Nmpmathrc   r   s     r[   _mpmathcodezCustomPrintedObject._mpmathcode  s    xr]   N)__name__
__module____qualname__r   r   rc   r]   r[   r   r     s2              r]   r   c                      t                      } t                                          |           dk    sJ t                                          |           dk    sJ d S )Nr   r   )r   r<   rV   r6   )objs    r[   test_printmethodr     sY    


C>>!!#&&'1111??""3''8333333r]   c                  :    t          t                    dk    sJ d S )NNone)r9   r   rc   r]   r[   test_codegen_ast_nodesr   "  s    $<<6!!!!!!r]   c                      t                      } |                     t                    dk    sJ |                     t                     dk    sJ d S )Nzmath.nanzfloat('-inf'))r8   rV   r   r   rY   s    r[   test_issue_14283r   &  sO    E==++++=="000000r]   c                  r    t                      } |                     t          d                    dk    sJ d S )NrK   z(0, 1,))r<   
_print_seqrange)ns    r[   test_NumPyPrinter_print_seqr   -  s4    A<<a!!Y......r]   c                      ddl m} m} t          d          } | |t                    } ||t                    }t                      }|                    |          dk    sJ |                    |          dk    sJ t                      }t          ddi          }||fD ]\}t          t                    5  |                    |           d d d            n# 1 swxY w Y   d|                    |          v sJ ]d S )	Nr   )
lowergamma
uppergammar~   z3scipy.special.gamma(a)*scipy.special.gammainc(a, x)z4scipy.special.gamma(a)*scipy.special.gammaincc(a, x)strictFNot supported)'sympy.functions.special.gamma_functionsr   r   r   rW   r=   rV   r<   r8   r>   NotImplementedError)	r   r   r~   r   expr2rZ   p_numpyp_pycoder   s	            r[   test_issue_16535_16536r   3  s\   PPPPPPPPAJq!EJq!ENNE==#XXXXX==#YYYYYnnG (E!233H 9 9'(( 	# 	#OOE"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#("2"24"8"8888889 9s   7CC	 C	c                  P   ddl m}  ddlm}  | | t                     t          dt
          f          } |t          dz   | t          t          z            z  t          t           t          ft          dt          f          } |t          dz  t                     |t          dz  t          df          t                      	                    |          dk    sJ 	                    |          dk    sJ t          t          fd           t          t          fd	           t                      	                    |          d
k    sJ 	                    |          dk    sJ t          t          fd           t          t          fd           d S )Nr   )exp)IntegralrK   rL   z>scipy.integrate.quad(lambda x: numpy.exp(-x), 0, numpy.inf)[0]zMscipy.integrate.nquad(lambda x, y: x**2*numpy.exp(x*y), ((-z, z), (0, z)))[0]c                  .                                    S NrV   
indefiniterZ   s   r[   rd   ztest_Integral.<locals>.<lambda>S      j(A(A r]   c                  .                                    S r   r   
evaluateatrZ   s   r[   rd   ztest_Integral.<locals>.<lambda>T  r   r]   z6mpmath.quad(lambda x: mpmath.exp(-x), (0, mpmath.inf))z?mpmath.quad(lambda x, y: x**2*mpmath.exp(x*y), (-z, z), (0, z))c                  .                                    S r   r   r   s   r[   rd   ztest_Integral.<locals>.<lambda>Y  r   r]   c                  .                                    S r   r   r   s   r[   rd   ztest_Integral.<locals>.<lambda>Z  r   r]   )&sympy.functions.elementary.exponentialr   sympy.integrals.integralsr   rW   r   rX   zr=   rV   r>   r   r6   )r   r   singledoubler   r   rZ   s       @@@r[   test_Integralr   G  s   ::::::222222Xcc1"gg1bz**FXad33qs88ma!QZ!Q;;F!Q$""J!Q$A''JNNE==  $ddddd==  $sssss
 A A A A ABBB
 A A A A ABBBOOE==  $\\\\\==  $eeeee
 A A A A ABBB
 A A A A ABBBBBr]   c                     ddl m} m}  | t                    } |t                    }t	                      }|                    |          dk    sJ |                    |          dk    sJ t                      }t                      }t                      }||fD ]}t          t                    5  |                    |           d d d            n# 1 swxY w Y   t          t                    5  |                    |           d d d            n# 1 swxY w Y   |                    |          dk    sJ |                    |          dk    sJ d S )Nr   )fresnelcfresnelszscipy.special.fresnel(x)[1]zscipy.special.fresnel(x)[0]zmpmath.fresnelc(x)zmpmath.fresnels(x))'sympy.functions.special.error_functionsr   r   rW   r=   rV   r<   r8   r6   r>   r   )	r   r   r   r   rZ   r   r   p_mpmathr   s	            r[   test_fresnel_integralsr   ]  s   LLLLLLLLHQKKEHQKKENNE==#@@@@@==#@@@@@nnG ""HH # #'(( 	" 	"OOD!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"'(( 	# 	#T"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# E""&:::::E""&:::::::s$   1CC	C	2DD	D	c                     ddl m}   | t          t                    }t	                      }|                    |          dk    sJ t                      }|                    |          dk    sJ t                      }|                    |          dk    sJ t          ddi          }|                    |          dk    sJ t                      }|                    |          dk    sJ d S )Nr   )betazscipy.special.beta(x, y)z/(math.gamma(x)*math.gamma(y)/math.gamma(x + y))allow_unknown_functionsTzmpmath.beta(x, y))	&sympy.functions.special.beta_functionsr   rW   rX   r=   rV   r<   r8   r6   )r   r   rZ   s      r[   	test_betar  t  s    ;;;;;;41::DNNE=="<<<<<NNE=="SSSSSE=="SSSSS8$?@@E=="SSSSSOOE==#6666666r]   c                     ddl m} m}  | t                    } |t                    }t	                      }|                    |          dk    sJ |                    |          dk    sJ t          ddi          }d|                    |          v sJ d|                    |          v sJ t          ddi          }d|                    |          v sJ d|                    |          v sJ d S )Nr   )airyaiairybizscipy.special.airy(x)[0]zscipy.special.airy(x)[2]r   Fr   )sympy.functions.special.besselr  r  rW   r=   rV   r<   r8   )r  r  r   r   rZ   s        r[   	test_airyr    s   ????????F1IIEF1IIENNE==#=======#=====(E*++EemmE222222emmE222222x/00EemmE222222emmE22222222r]   c                     ddl m} m}  | t                    } |t                    }t	                      }|                    |          dk    sJ |                    |          dk    sJ t          ddi          }d|                    |          v sJ d|                    |          v sJ t          ddi          }d|                    |          v sJ d|                    |          v sJ d S )Nr   )airyaiprimeairybiprimezscipy.special.airy(x)[1]zscipy.special.airy(x)[3]r   Fr   )r  r  r	  rW   r=   rV   r<   r8   )r  r	  r   r   rZ   s        r[   test_airy_primer
    s   IIIIIIIIKNNEKNNENNE==#=======#=====(E*++EemmE222222emmE222222x/00EemmE222222emmE22222222r]   c                  0   t                      } |                     t          t                              dk    sJ |                     t	          t                              dk    sJ |                     t          t                              dk    sJ d S )Nznumpy.expm1(x)znumpy.log1p(x)zscipy.special.cosm1(x))r=   rV   r   rW   r   r   rY   s    r[   !test_numerical_accuracy_functionsr    s}    NNE==q""&66666==q""&66666==q""&>>>>>>>r]   c            	      4   t          dd          } t          d          }t          dd          t          dd          t          dd	          }}}t                      }|                    t          d
                    dk    sJ |                    t          d
                    dk    sJ |                    t          | ddg                    dk    sJ |                    |          dk    sJ |                    t          | g d                    dk    sJ |                    t          | ddgddg                    dk    sJ |                    t          | dgdg                    dk    sJ |                    t          ||||f         ||||f                             dk    sJ t                      }|                    t          d
                    dk    sJ |                    t          d
                    dk    sJ |                    t          | ddg                    dk    sJ |                    |          dk    sJ |                    t          | g d                    dk    sJ |                    t          | ddgddg                    dk    sJ |                    t          | dgdg                    dk    sJ |                    t          ||||f         ||||f                             dk    sJ d S )Nr   )r   r   rO   rO   rO   IirS   jrT   k)r   r   r   znumpy.zeros((5,))znumpy.ones((5,))rK   rP   znumpy.einsum("abccd->abd", A))rK   rP   r   znumpy.einsum("abccc->abc", A)r   rL   znumpy.einsum("aabbc->cab", A)znumpy.einsum("abcde->abe", A)zI = Iztensorflow.zeros((5,))ztensorflow.ones((5,))z)tensorflow.linalg.einsum("abccd->abd", A)z)tensorflow.linalg.einsum("abccc->abc", A)z)tensorflow.linalg.einsum("aabbc->cab", A)z)tensorflow.linalg.einsum("abcde->abe", A))rB   r@   rA   r<   rV   rE   rF   rD   rC   r   r;   )r   r  r  r  r  rZ   s         r[   test_array_printerr    s   C%%ACAUOOSe__c#uooaANNE==1&&*=======!%%);;;;;==)!aU33448WWWWW==s""""==q'''22337VVVVV==q1Q%!A7788<[[[[[==)!aS1#6677;ZZZZZ==Aa!eHa!Ah7788GCCCCE==1&&*BBBBB==!%%)@@@@@==)!aU33448ccccc==s""""==q'''22337bbbbb==q1Q%!A7788<ggggg==)!aS1#6677;fffff==Aa!eHa!Ah7788GCCCCCCr]   c                  .    G d dt                     }  |             }t          t                                        t          d          }|                    |          dk    sJ t          t          t                                        t          dt          dd          }|                    |          dk    sJ 	 |                    t          t                                        t          d                     J # t          $ r}d	t          |          v sJ Y d }~nd }~ww xY w	 |                    t          t          t          dz            t                               J # t          $ r}d
t          |          v sJ Y d }~d S d }~ww xY w)Nc                       e Zd Zd Zd ZdS )1test_custom_Derivative_methods.<locals>.MyPrinterc                 F    |\  }|\  }d|                      |          |fz  S )Nz#my_custom_cosm1(%s, deriv_order=%d)_print)r   args
seq_ordersargorders        r[   _print_Derivative_cosm1zItest_custom_Derivative_methods.<locals>.MyPrinter._print_Derivative_cosm1  s,    DCFE8DKK<L<Le;TTTr]   c                 t    |\  }}|\  }}d|                      |          |                      |          ||fz  S )Nz-my_custom_atan2(%s, %s, deriv1=%d, deriv2=%d)r  )r   r  r  arg1arg2ord1ord2s          r[   _print_Derivative_atan2zItest_custom_Derivative_methods.<locals>.MyPrinter._print_Derivative_atan2  sH    JD$#JD$BD!!4;;t#4#4dDF  r]   N)r   r   r   r  r#  rc   r]   r[   	MyPrinterr    s5        	U 	U 	U
	 	 	 	 	r]   r$  FrQ   z!my_custom_cosm1(x, deriv_order=1)rK   rP   z)my_custom_atan2(x, y, deriv1=2, deriv2=3)_print_Derivative_expm1z_print_Derivative()r=   r   rW   diffrV   r/   rX   r   r5   reprr   re   )r$  rI   cosm1_1	atan2_2_3es        r[   test_custom_Derivative_methodsr+    s       L    		AAhhmmAm..G99W!DDDDDa  Aq!e <<I99Y#NNNNN			%((--E-22333 	 * 4 4 4(DGG3333333334
			*U1a4[[++,,, 	  / / /#tAww........../s1   ?AD 
D)D$$D)-=E, ,
F6FFN)zsympyr   sympy.codegenr   sympy.codegen.astr   sympy.codegen.cfunctionsr   r   sympy.codegen.scipy_nodesr   sympy.codegen.matrix_nodesr	   
sympy.corer
   r   r   r   r   r   r   r   r   r   r   r   sympy.core.numbersr   sympy.core.singletonr   sympy.functionsr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   (sympy.functions.elementary.trigonometricr/   sympy.logicr0   r1   sympy.matricesr2   r3   r4   sympy.printing.codeprinterr5   sympy.printing.pycoder6   r7   r8   r9   r:   sympy.printing.tensorflowr;   sympy.printing.numpyr<   r=   sympy.testing.pytestr>   r?   sympy.tensorr@   rA   0sympy.tensor.array.expressions.array_expressionsrB   rC   rD   rE   rF   sympy.externalrG   r   rH   rW   rX   r   rI   r\   rf   ri   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r+  rc   r]   r[   <module>rA     sJ         $ $ $ $ $ $ " " " " " " 1 1 1 1 1 1 1 1 + + + + + + 2 2 2 2 2 2 M M M M M M M M M M M M M M M M M M M M M M M M * * * * * * ! ! ! ! ! ! " " " " " " v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v : : : : : :         ? ? ? ? ? ? ? ? ? ? E E E E E E              8 7 7 7 7 7 ; ; ; ; ; ; ; ; - - - - - - - - ) ) ) ) ) ) ) ) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ( ( ( ( ( ( < < < < < < ''

1aK*3 *3 *3ZJ J J3 3 3.: : :2? 2? 2?j  &* * *"4 4 4$ $ $B B B6P P P(    $   4 4 4" " "1 1 1/ / /9 9 9(C C C,; ; ;.7 7 7(3 3 3$3 3 3&? ? ?D D D4         r]   