+
    iS              	          R t ^ RIt^ RIHt ^ RIHtHtHt ]P                  ! R4      t	]	P                  ]P                  4       ]! R4      t]	P                  ]P                  4       ]'       dl   ^ RIt]P                   t]P$                  tR U u. uF  p ]P!                  V R4      NK  	  up w  tttR Uu. uF  p]P%                  RR=VR	7      NK  	  upw  tttMR
t^ RIt^ RIHt ^ RIH t H!t!H"t"H#t# ^ RI$H%t%H&t&H't' R Uu. uF  p]PQ                  V^^4      NK  	  upw  t)t*t+]PX                  ! R4      ! ]#4      t-R t.R t/R t0R t1R t2R t3R t4R t5]R 4       t6R t7R t8R t9R t:R t;R t<R t=R t>R  t?R! t@R" tAR# tBR$ tCR% tDR& tER' tFR( tGR) tHR* tIR+ tJR, tKR- tLR. tMR/ tNR0 tO]R1 4       tPR2 tQR3 tRR4 tSR5 tTR6 tUR7 tVR8 tWR9 tXR: tYR; tZR< t[R# u up i u upi u upi )>a  
Important note on tests in this module - the Theano printing functions use a
global cache by default, which means that tests using it will modify global
state and thus not be independent from each other. Instead of using the "cache"
keyword argument each time, this module uses the theano_code_ and
theano_function_ functions defined below which default to using a new, empty
cache instead.
N)import_module)raisesSKIPwarns_deprecated_sympyztheano.configdefaultstheanoxyzfloatXXYZ)nameT)S)xyzt)theano_codedim_handlingtheano_functionfc                    VP                  R/ 4       \        4       ;_uu_ 4        \        V 3/ VB uuRRR4       #   + '       g   i     R# ; i)zAWrapper for theano_code that uses a new, empty cache by default. cacheN)
setdefaultr   r   )exprkwargss   &,b/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/printing/tests/test_theanocode.pytheano_code_r   .   s7    
gr"		!	!4*6* 
"	!	!	!	   <A	c                    VP                  R/ 4       \        4       ;_uu_ 4        \        W3/ VB uuRRR4       #   + '       g   i     R# ; i)zEWrapper for theano_function that uses a new, empty cache by default. r   N)r   r   r   )inputsoutputsr   s   &&,r   theano_function_r   4   s7    
gr"		!	!v9&9 
"	!	!	!r   c                    \        \        \        V 4      4      p\        P                  P
                  P                  V4      p\        P                  P
                  P                  W!4      w  r!\        P                  P                  W!4      # )zTransform SymPy expressions into Theano Computation.

Parameters
==========
exprs
    SymPy expressions

Returns
=======
theano.gof.FunctionGraph
)	listmapr   r   gofgraphr   cloneFunctionGraph)exprsoutsinss   *  r   	fgraph_ofr*   ;   s`     L%()D
**


!
!$
'C

  &&s1IC::##C..    c                    \         P                  P                  4       P                  R4      pV P	                  4       p VP
                  P                  V 4       V # )zSimplify a Theano Computation.

Parameters
==========
fgraph : theano.gof.FunctionGraph

Returns
=======
theano.gof.FunctionGraph
fusion)r   compileget_default_mode	excludingr%   	optimizeroptimize)fgraphmodes   & r   theano_simplifyr5   M   sC     >>**,66x@D\\^FNNF#Mr+   c                   \         \        \        P                  3p\	        W4      p\	        W4      pV'       g	   V'       d   V'       d	   V'       g   R# W8H  # \	        V \
        \        34      p\	        V\
        \        34      pV'       g	   V'       d_   V'       d"   V'       d   \        V 4      \        V4      8w  d   R# \        \        \        V 4      4      \        \        \        V4      4      8H  # \        P                  P                  V RR7      p\        P                  P                  VRR7      pRW3RW33 F.  w  rpVR8X  g   K  \        RV	: RV	: R	\        V
4      : R
24      h	  Wx8H  # )a  Test two Theano objects for equality.

Also accepts numeric types and lists/tuples of supported types.

Note - debugprint() has a bug where it will accept numeric types but does
not respect the "file" argument and in this case and instead prints the number
to stdout and returns an empty string. This can lead to tests passing where
they should fail because any two numbers will always compare as equal. To
prevent this we treat numbers as a separate case.
Fstr)fileab ztheano.printing.debugprint(z) returned empty string (z is instance of ))intfloatnpnumber
isinstancetupler!   typer"   theqr   printing
debugprint	TypeError)r9   r:   numeric_typesa_is_numb_is_numa_is_seqb_is_seqastrbstrargnameargvalargstrs   &&          r   rD   rD   ^   s     %+M!+H!+H 8Xv !eT]+H!eT]+H8X$q'T!W*<CaL!T#dA,%777 ??%%ae%4D??%%ae%4D &)!NS!N#CR< GT&\3  $D <r+   c                    \        \        \        \        4      4      '       g   Q h\        \        \        \
        4      4      '       g   Q h\        \        \        \        4      4      '       g   Q h\        \        \        \        4      4      '       g   Q h\        \        \        \        4      4      '       g   Q h\        \        \        \        4      4      '       g   Q hR# )z}
Check that the example symbols in this module print to their Theano
equivalents, as many of the other tests depend on this.
N)rD   xtr   r   ytr   ztr   XtXYtYZtZ r+   r   test_example_symbolsr]      s    
 LO$$$$LO$$$$LO$$$$LO$$$$LO$$$$LO$$$$r+   c                    \        \        4      p \        V \        P                  \
        P                  34      '       g   Q hV P                  R8X  g   Q hV P                  \        P                  8X  g   Q h\        \        \        R/R7      pVP                  R8X  g   Q hVP                  \        P                  8X  g   Q hR# )z-Test printing a Symbol to a theano variable. broadcastablesNr\   F)	r   r   rA   ttTensorVariabletsScalarVariablebroadcastabler
   )xxxx2s     r   test_Symbolri      s    	aBb2,,b.?.?@AAAAr!!!77aff
q!X
7C(((88qvvr+   c                     \        \        4      p \        V \        P                  4      '       g   Q hV P
                  R8X  g   Q hR# )z3Test printing a MatrixSymbol to a theano variable. NFF)r   rW   rA   rb   rc   rf   )XXs    r   test_MatrixSymbolrm      s8    	aBb"++,,,,~---r+   c                     . ROp V  F:  p\        \        4      ;_uu_ 4        \        \        \        V/R7       RRR4       K<  	  R#   + '       g   i     KQ  ; i)z.Test MatrixSymbol with invalid broadcastable. r_   N)r\   ra   TTFFT)TT)r   
ValueErrorr   rW   )bcsbcs     r   test_MatrixSymbol_wrong_dimsru      s?     OCJAr73   s   AAc                     \        \        4      p \        V \        P                  4      '       g   Q hV P
                  R8X  g   Q hV P                  R8X  g   Q hR# )zFTest printing AppliedUndef instance, which works similarly to Symbol. f_tNr\   )r   rw   rA   rb   rc   rf   r
   )ftts    r   test_AppliedUndefry      sK    
s
Cc2,,----"""88ur+   c                      \         \        ,           p \        V 4      pVP                  P                  \
        P                  P                  8X  g   Q hR # N)r   r   r   owneropr   tensoraddr   comps     r   test_addr      s5    q5DD::==FMM-----r+   c                  6   \        \        \        P                  ! \        4      4      \
        P                  \        4      4      '       g   Q h\        \        \        P                  ! \        4      4      \
        P                  \        4      4      '       g   Q hR # r{   )rD   r   sysinr   rb   rS   tanr\   r+   r   	test_trigr      sR    RVVAY'4444RVVAY'4444r+   c                    \         P                  ! \        ^,          \         P                  ! \        4      ,           4      \         P
                  ! ^\        ,          4      ,          p \        V 4      p\        P                  \        ^,          \        P                  \        4      ,           4      \        P                  ^\        ,          4      ,          p\        W4      '       g   Q hR# )z:Test printing a complex expression with multiple symbols. N)r   expr   cosr   logr   r   rb   rS   rT   rU   rD   )r   r   expecteds      r   	test_manyr      s}    66!Q$"#bffQqSk1DDvvb!ebffRj()BFF1R4L8Hr+   c                    R F5  p \        \        \        V /R7      P                  P                  V 8X  d   K5  Q h	  \        \        \        R/R7      P                  P                  R9   g   Q h\        \        ^,           \        R/R7      P                  P                  R8X  g   Q h\        \        \        ,           \        R\        R/R7      P                  P                  R8X  g   Q hR# )z@Test specifying specific data types through the dtype argument. float32float64dtypesr   N)r   r   int8int16int32int64)r   r   )r   r   rC   dtyper   )r   s    r   
test_dtyper      s    JAq%j166<<EEE K 1h-055;;?UUUU Aq)n5::@@IMMMAq)Q	&BCHHNNR[[[[r+   c                 |    \         \        3 F+  p R F"  p\        W V/R7      P                  V8X  d   K"  Q h	  K-  	  R# )zFTest the "broadcastables" argument when printing symbol-like objects. r_   N)r\   ra   ro   rk   rp   )r   rw   r   rf   )srt   s     r   test_broadcastablesr      s:     XHBb':HHBNNN I r+   c                     \         \        ,           p . RO. RO. RO. RO. RO.pV F2  w  r#p\        V \         V\        V/R7      pVP                  V8X  d   K2  Q h	  R# )zFTest "broadcastable" attribute after applying element-wise binary op. r_   N)r\   r\   r\   )ra   ra   ra   )ro   ra   ra   )rq   rk   rk   )rp   rk   rk   )r   r   r   rf   )r   casesbc1bc2bc3r   s         r   test_broadcastingr      s^     q5D 	&%77E #D!S!S1AB!!S((( r+   c                  <   \         \        ,          \        ,          p \        V 4      p\	        VP
                  P                  \        P                  4      '       g   Q h\        V\        P                  \        4      P                  \        4      4      '       g   Q hR # r{   )rW   rY   r[   r   rA   r|   r}   rb   DotrD   rV   dotrX   rZ   )r   expr_ts     r   test_MatMulr      s\    Q3q5D$Fflloorvv....r
r*++++r+   c                      \        \        \        P                  4      P                  P
                  \        P                  4      '       g   Q hR # r{   )rA   r   rW   Tr|   r}   rb   
DimShuffler\   r+   r   test_Transposer      s.    l133'--00"--@@@@r+   c                      \         \        ,           \        ,           p \        \	        V 4      P
                  P                  \        P                  4      '       g   Q hR # r{   )	rW   rY   r[   rA   r   r|   r}   rb   Elemwiser   s    r   test_MatAddr      s7    Q3q5Dl4(..112;;????r+   c                     \        \        \        P                  ! ^4      ^,          4      \        P                  ^^4      4      '       g   Q h\        \        \        P                  4      \        P                  ^^4      4      '       g   Q hR# )   N)rD   r   r   Integerrb   true_divr   Halfr\   r+   r   test_Rationalsr     sY    RZZ]Q./Q1BCCCCQVV$bkk!Q&78888r+   c                  R    \        \        P                  ! ^4      4      ^8X  g   Q hR# )   N)r   r   r   r\   r+   r   test_Integersr     s    

1&!+++r+   c                      \         P                  ! R 4      p \        \         P                  ! V 4      4      '       g   Q hR# )nN)r   Symbolr   	factorial)r   s    r   test_factorialr     s(    
		#AQ((((r+   c                  "   R  p \        V ! \        \        P                  ! \        P                  ! \
        4      \
        RR7      4      4      V ! \        P                  \        P	                  \        4      \        4      4      4      '       g   Q hR# )c                 *    \        \        V 4      4      # r{   )r5   r*   r   s   &r   <lambda>!test_Derivative.<locals>.<lambda>  s    	$8r+   FevaluateN)
rD   r   r   
Derivativer   r   r   gradrb   rS   )simps    r   test_Derivativer     sZ    8D\"--q	1u"MNOV[[R013 3 3 3r+   c                 r    \        \        \        .\        \        ,           .4      p V ! ^^4      ^8X  g   Q hR# )z+Test theano_function() with single output. Nr   r   r   )r   s    r   test_theano_function_simpler     s*    !Q!A#'AQ7a<<r+   c                     \        \        \        .\        \        ,           \        \        ,
          .4      p V ! ^^4      w  rV^8X  g   Q hVR8X  g   Q hR# )z.Test theano_function() with multiple outputs. Nr   )r   o1o2s      r   test_theano_function_multir     sA    !Q!A#qs,Aq!WFB7N78O8r+   c            	        \        \        \        .\        \        ,           .^\        R\        R/R7      p \        P                  P                  V ! ^^.^^.4      \        P                  ! ^^.4      ,
          4      R8  g   Q h\        \        \        .\        \        ,           .\        R\        R/^R7      p \        P                  ! ^4      P                  R4      p^\        P                  ! ^4      P                  R4      ,          p\        P                  P                  V ! W4      ^\        P                  ! ^4      ,          ,
          4      R8  g   Q hR# )z0Test theano_function() vs Numpy implementation. r   )dimr   &.>)r   r   N)	r   r   r   r?   linalgnormasarrayarangeastype)r   rg   yys      r   test_theano_function_numpyr   !  s    !Q!A#A!"Iq) <	>A99>>!QFQF+bjj!Q.@@ADHHH!Q!A#9a/K	 A	1		Y	'B	
299Q<y)	)B99>>!B)a		!n45<<<r+   c                     \         P                  ! \        \        .\        \        \        ,           \        ,           ..4      p \
        P                  ! R R.RR..4      p\        \        \        \        .V .4      p\
        P                  P                  V! R RR4      V4       \        \        \        \        .V .RR7      p\
        P                  P                  V! R RR4      V4       \        \        \        \        .W .4      p\        V! R RR4      \        . 4      4      '       g   Q h\
        P                  P                  V! R RR4      ^ ,          V4       \
        P                  P                  V! R RR4      ^,          V4       R# )      ?       @g      @T)scalarNg      @)r   Matrixr   r   r   r?   arrayr   testingassert_allcloserA   rC   )mr   r   s      r   test_theano_function_matrixr   .  s   
		Aq6Aq1uqy>*+Axx#sc?%;<=H!QQC(AJJqc3/:!QQC5AJJqc3/:!QQF+AaS#&R1111JJqc3/2H=JJqc3/2H=r+   c                      \        \        .^R7      \        R/8X  g   Q h\        \        \        .\        ^\        ^/R7      \        R\        R/8X  g   Q h\        \        .\        R/R7      \        R/8X  g   Q hR# )r   )r   )dimsr_   Nrk   rq   ra   )r   r   r   r\   r+   r   test_dim_handlingr   :  st    #>'::::AaAq\2q-78.7J J J JQM:q(mKKKr+   c                    ^ RI p \        \        \        \        .\        \        ,           .^R\        R\        R\        R/R7      pV P
                  P                  V! ^^.^^.^ ^ .4      V P                  ! ^^.4      ,
          4      R8  g   Q h\        \        \        \        .\        \        ,           .\        R\        R\        R/^RR7      pV P                  ! ^4      P                  R4      p^V P                  ! ^4      P                  R4      ,          p^V P                  ! ^4      P                  R4      ,          pV P
                  P                  V! W#V4      ^V P                  ! ^4      ,          ,
          4      R8  g   Q hR# )zM
Test passing additional kwargs from theano_function() to theano.function().
Nignorer   )r   on_unused_inputr   r   )r   r   r   )
numpyr   r   r   r   r   r   r   r   r   )r?   r   rg   r   zzs        r   test_theano_function_kwargsr   @  s,    !QQqSEq(y!Y9=	?A99>>!QFQFQF3bjj!Q6HHIDPPP!QQqSE !9aAyIx	9A 
1		Y	'B	
299Q<y)	)B	
299Q<y)	)B99>>!BB-!BIIaL.89D@@@r+   c                    \         \        .\         \        ,           .R^ .3\        \        .\        \        ,           .R^.3\         \        .\         \        ,           .\         ^ \        ^/^.3\         \        .\         \        ,           \         \        ,
          .R^ ^ .3\         \        \        \        .\         \        ,           \        \        ,           .R^ ^.3.p V  EF}  w  rr4R EFo  p\	        WW5R7      p\        VP                  \        P                  P                  P                  4      '       g   Q hVP                  P                   UUu. uFF  p\        P                  ! VP                  P                   Uu. uF  q'       d   ^M^NK  	  up4      NKH  	  p	ppV! V	!  p
\        V
\         4      '       g   V
.p
\#        V4      \#        V
4      8X  g   Q h\%        WJ4       Fm  w  rV'       d,   V^ 8X  d%   \        V\        P&                  4      '       g   Q hK8  \        V\        P(                  4      '       g   Q hVP*                  V8X  d   Km  Q h	  EKr  	  EK  	  R# u upi u uppi )z1Test the "scalar" argument to theano_function(). N)r   r   rq   )r   r   rW   rY   r   rA   r   r   r.   function_moduleFunctioninput_storager?   onesrC   rf   r!   lenzipr@   ndarrayndim)argsr   r   in_dimsout_dimsr   r   irt   	in_values
out_valuesdvalues                r   test_theano_function_scalarr   Q  s    Q!a%$$
Q!a%$$
Q!a%1aA,,
Q!a%Q1v.
Q1Aq1u~taV4D /3*#F wNA a//1O1O1X1XYYYY
 **888A !&&2F2FG2FBba2FGH8   IJj$//(\
 x=C
O3335a1f%eRYY7777 &eRZZ8888 ::?*? 6% $ /3 Hs   -I&
=I!I&
!I&
c                 (    \        \        R 4       R# )zU
Passing an unknown keyword argument to theano_function() should raise an
exception.
c                  @    \        \        .\        ^,           .^R7      # )   )foobar)r   r   r\   r+   r   r   0test_theano_function_bad_kwarg.<locals>.<lambda>  s    /acU1Er+   N)r   	Exceptionr\   r+   r   test_theano_function_bad_kwargr  {  s    
 9EFr+   c            	      l   \        \        ^^^4      4      \        ^^^4      8X  g   Q hR p \        R\        R/pV ! \        \        \        \        4      VR7      \        \        \
        4      4      '       g   Q hV ! \        \        ^\        ^4      VR7      \        ^\        ^4      4      '       g   Q hR# )r   c                     R FD  p\        W4      p\        W4      pVe   Vf   Ve
   Ve    R# K.  K0  \        W44      '       d   KC   R# 	  R# )startFT)r  stopstep)getattrrD   )s1s2attra1a2s   &&   r   
theq_slicetest_slice.<locals>.theq_slice  sM    -D"B"BzRZ
bj  '1
"\\ . r+   r   r   N)r   slicer   r   rS   rT   )r  r   s     r   
test_slicer    s    aA'5Aq>999	 !W%Fl5A;v>b"NNNNl5Aq>&A5BPQ?SSSSr+   c                    aa	a
 ^ RI Ho / p \        P                  ! RRR7      p\        P                  ! RW4      pVR,          p\        W0R7      o	\        P                  R4      o
\        S	P                  P                  P                  4      \        S
S
S
4      \        S
S
S
4      38X  g   Q hS	P                  P                  ^ ,          \        W R7      8X  g   Q h\        ;QJ d+    VV	V
3R l\        ^^4       4       F  '       d   K   R	M 	  RM! VV	V
3R l\        ^^4       4       4      '       g   Q h\        P                  ! R
4      p\        WDR/R7       ^T^rvpW%Wg1,          p\        W1RVR/R7      o	R# )    )Constantr   TintegerrW   r   r   c              3      <"   T F8  pSP                   P                  V,          P                  S! SV4      4      x  K:  	  R # 5ir{   )r|   r   equals).0r   r  rX   r   s   & r   	<genexpr>#test_MatrixSlice.<locals>.<genexpr>  s2     N+Qrxxq!((!Q88+s   A AFkr   r   N):r   r   r   :         )r   r  r   r   MatrixSymbolr   rd   ScalarrB   r|   r}   idx_listr  r   allrange)r   r   rW   rY   r  r  r  r	  r  rX   r   s           @@@r   test_MatrixSlicer(    s   E
		#t$A
Q"A	,A	a	%B
		'A%%&5Aq>5Aq>*JJJJ88??1a!==== 3N%1+N333N%1+NNNNN
		#Aw<(1aE	/A	aGQ 8	9Br+   c            
        a \         P                  ! R RR7      p R Uu. uF  p\         P                  ! WV 4      NK  	  upw  r#rE\        \        W#WE34      w  rgr\         P
                  ! W#.WE..4      p
\	        V
4      o\        P                  ^ \        P                  ^Wg4      \        P                  ^W4      4      \        P                  ^\        P                  ^ Wh4      \        P                  ^ Wy4      4      .p\        ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       g   Q hR# u upi )r   Tr  ABCDc              3   <   <"   T F  p\        SV4      x  K  	  R # 5ir{   )rD   )r  solutionBlockts   & r   r  #test_BlockMatrix.<locals>.<genexpr>  s     @i(tFH%%is   FN)	r   r   r#  r"   r   BlockMatrixrb   joinany)r   r
   ABCDAtBtCtDtBlock	solutionsr-  s               @r   test_BlockMatrixr<    s    
		#t$A:@A&$"//$1-&AJA!a|4NBBNNQFQF+,E% FBGGAr.20BCBGGAr.20BCEI3@i@333@i@@@@@ Bs    E c            	         ^^rRp\         P                  ! RW4      p\         P                  ! RW4      pW43pVP                  V,          pW1^,          V^,          3V ^,          V ^,          3.WA^,          V^,          3V^,          V^,          3./pV Uu. uF!  p\         P                  ! V.Wx,          O5!  NK#  	  p	pVP	                  \        \        WY4      4      4      p
\        \        WR.\        V4      ,          4      4      p\        WV.V/ R7      p\        V\         P                  ! V
4      .V/ R7      pV Uu. uF:  p\        P                  P                  ! VP                  !  P                  V4      NK<  	  pp\        P                  ! W,          4      P!                  VP                  4      P                  V4      \        P"                  ! V4      P                  V4      .pV^;;,          \        P$                  ! VP                  4      R,          ,          uu&   \        P&                  ! V! V!  V! V!  RR7      '       g   Q hR# u upi u upi )r   r   r2  r3  )r   r   gh㈵>)rtolN)r   r#  Iblockcutsubsdictr   r   r   block_collapser?   randomrandshaper   r   reshapeeyer   allclose)r  r   r   r2  r3  r   outputcutsizesr   	cutinputs	cutoutputr   r   fblockedr   ninputss                   r   "test_BlockMatrix_Inverse_executionrP    s   aqE
Q"A
Q"ATFSSUFT1a4L1a4A,/T1a4L1a4A,/1H7=>v!Q--vI>DV!789I#fgc&k123F&CA):):9)E(F'-R9H @FFv!ryy~~qww'..u5vGFyy~%%agg.55e<vvay&(GAJ"''!''"4''J;;q'{Hg$6TBBBB ? Gs   'I>A Ic                     \         P                  ! R 4      p \         P                  \         P                  3 F  pV! \         P                  ! V 4      \         P
                  ! V 4      ) .\         P
                  ! V 4      \         P                  ! V 4      ..4      p\        V4      p\        V\        P                  4      '       g   Q hVP                  P                  \        P                  8X  d   K  Q h	  R# )thetaN)r   r   r   ImmutableMatrixr   r   r   rA   rb   rc   r|   r}   join_)r   
MatrixTyperW   tXs       r   test_DenseMatrixrW    s    
		'Ayy""4"45
RVVAYJ/"&&)RVVAY1GHI!_"b//0000xx{{bhh&&&	 6r+   c                    \         \        P                  ! R4      3\        \        P                  ! R.\        P
                  O5!  3\        \        P                  ! R4      ! \        P                  ! R4      4      3.p V  FJ  w  r/ p\        WR7      p\        WR7      VJ g   Q h\        V/ R7      VJg   Q h\        W#R7      VJ d   KJ  Q h	  R# )zGTest single symbol-like objects are cached when printed by themselves. r   rW   r   r   r  N)	r   r   r   rW   r#  rF  rw   r   r   )pairsr  r  r   sts        r   test_cache_basicr[    s    
 
BIIcN	
BOOC*!''*+	bkk#ryy~./E "* B,222 Bb)333 B,222 r+   c                 `   ^ RI Hp  \        V 4      p V P                  4        \        \
        \        3 F;  p\        4       ;_uu_ 4        \        V4      p\        V4      VJ g   Q h RRR4       K=  	  V P                  V4       R#   + '       g   i     Kc  ; i  T P                  T4       i ; i)zTest use of the global cache. )global_cacheN)
sympy.printing.theanocoder]  rB  clearr   rW   rw   r   r   update)r]  backupr   rZ  s       r   test_global_cacherb    s    6,F$QA')) ^"1~+++ *)  	F# *)) 	F#s#   6B 	B'B B	B B-c            	        \         P                  ! R4      \         P                  ! R^^4      \        .p / p/ pV  F)  p\	        W1R7      pWBP                  4       9  g   Q hWBV&   K+  	  \        \        \        \        VP                  4       4      4      4      \        V 4      8X  g   Q hVP                  4        F3  w  r4\        4       ;_uu_ 4        \        W1R7      VJ g   Q h RRR4       K5  	  R#   + '       g   i     KJ  ; i)z
Test that symbol-like objects of different types (Symbol, MatrixSymbol,
AppliedUndef) are distinguished by the cache even if they have the same
name.
rw   r  N)r   r   r#  rw   r   valuesr   setr"   iditemsr   r   )symbolsr   printedr   rZ  s        r   test_cache_types_distinctrj    s     yy1!=sCGEG!)))))
  s3r7>>+,-.#g,>>> #%%q."444 &% !%%%s   C00Dc                     \         P                  ! \        \        RR7      p \        V 4      p\	        V\
        \
        ,           4      '       g   Q h\	        V\
        \        \        4      ,           4      '       d   Q hR# )zZ
Test that a symbol is cached and reused when it appears in an expression
more than once.
Fr   N)r   Addr   r   rD   rS   r   s     r   test_symbols_are_created_oncerm    sV    
 66!Q'DDb2gD"|A./////r+   c                    \         ^,          \        \        P                  ! \         4      ,
          \        P                  ! \
        \         \        ,          ,
          4      ,          ,           p V P                   Uu0 uF  qP                  kK  	  pp\        V 4      p\        4       p\        P                  P                  P                  V.4       F  pVP                  e   K  \        V\        P                  P                  P                   4      '       d   KI  VP                  V9   g   Q hVP                  V9  g   Q hVP#                  VP                  4       K  	  WB8X  g   Q hR# u upi )zZ
Test caching on a complicated expression with multiple symbols appearing
multiple times.
N)r   r   r   r   r   r   free_symbolsr
   r   re  r   r#   r$   	ancestorsr|   rA   r  r   )r   r   symbol_namesr   seenvs         r   test_cache_complexrt  '  s    
 6Q]bffQQY&777D$($5$56$5qFF$5L6$F 5DZZ''177?:a1A1A1J1J#K#K66\)))66%%%HHQVV 2  7s   ;E(c                  \   \         P                  ! ^ \        ^ 8  3\        \        ^8  3R4      p \        V 4      pVP                  P
                  \        P                  8X  g   Q h\        P                  \        ^ 8  ^ \        P                  \        ^8  \        ^4      4      p\        W4      '       g   Q h\         P                  ! \        \        ^ 8  34      p \        V 4      p\        P                  \        ^ 8  \        \        P                  4      p\        W4      '       g   Q h\         P                  ! ^ \         P                  ! \        ^ 8  \        ^8  4      3\        \         P                  ! \        ^8  \        ^ 8  4      34      p \        V 4      p\        P                  \        P                  \        ^ 8  \        ^8  4      ^ \        P                  \        P                  \        ^8  \        ^ 8  4      \        \        P                  4      4      p\        W4      '       g   Q hR# )r  N)r   T)r   	Piecewiser   r   r|   r}   rb   switchrS   rD   r?   nanAndOrand_or_)r   resultr   s      r   test_Piecewiser~  ?  st   <<AaC1ac(I6D$F<<??bii'''yyAq"))BqD"a"89H!!!!<<AE
#D$FyyaRVV,H!!!!<<BFF1Q3!,-	
BEE!A#qsOD$FyyAbd+Q
		"&&Ar!t$b"&&13H!!!!r+   c                  J   \        \        \        P                  ! \        \
        4      4      \        P                  \        \        4      4      '       g   Q h\        \        \        \
        8  4      \        \        8  4      '       g   Q h\        \        \        \
        8  4      \        \        8  4      '       g   Q h\        \        \        \
        8  4      \        \        8  4      '       g   Q h\        \        \        \
        8*  4      \        \        8*  4      '       g   Q hR # r{   )
rD   r   r   Eqr   r   rb   eqrS   rT   r\   r+   r   test_Relationalsr  U  s    RUU1a[)255R=9999QU#R"W----QU#R"W----Q!V$bBh////Q!V$bBh////r+   c                  l   \        4       ;_uu_ 4        \        \        \        R /R7      \        \        \        R /R7      rRRR4       ^ RIHp ^ RIHp ^ RIHp \        4       ;_uu_ 4        \        \        \        V! \        4      ,          4      XX P                  4       ,          4      '       g   Q h\        \        R\        ,          4      W! R4      V! R4      V! ^ ^4      ,          ,           ,          4      '       g   Q h RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	
complex128r   N)	conjugate)as_tensor_variable)complexr   r   y      ?       @)r   r   r   r   $sympy.functions.elementary.complexesr  theano.tensorr  r  rD   conj)rS   rT   r  atvcplxs        r   test_complexfunctionsr  ^  s    		!	!a<(89<STVbRc;dB 
">7-		!	!L9Q<0"bggi.AAAAL$*BCS$q)9K0K,LMMMM 
"	! 
"	!
 
"	!	!s   .D-BD"D	"D3	c                      \        4       ;_uu_ 4        \        . R.4      p RRR4       X ! 4       R8X  g   Q hR#   + '       g   i     L ; i)r   Ny      ?      ?)r   r   )tfs    r   test_constantfunctionsr  i  s5    		!	!b$( 
"4:: 
"	!s	   9A		c                 6   \         P                  ! ^4      p \         P                  p\        P                  P                  \        V 4      \        P                  4       \        P                  P                  \        V4      \        P                  4       \        V 4      p\        P                  P                  \        V 4      VP                  4       4       \        V4      p\        P                  P                  \        V4      VP                  4       4       R# )zH
Test that exp(1) prints without error and evaluates close to SymPy's E
N)
r   r   Er?   r   r   r>   er   eval)e_ae_br  s      r   	test_Exp1r  o  s     &&)C
$$CJJuSz2440JJuSz2440SAJJuSz16684SAJJuSz16684r+   rk   )\__doc__loggingsympy.externalr   sympy.testing.pytestr   r   r   	getLoggertheanologgersetLevelCRITICALr   WARNINGr   r?   r   rd   r~   rb   rS   rT   rU   rV   rX   rZ   disabledsympyr   sympy.core.singletonr   	sympy.abcr   r   r   r   r^  r   r   r   r#  rW   rY   r[   r   rw   r   r   r*   r5   rD   r]   ri   rm   ru   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r(  r<  rP  rW  r[  rb  rj  rm  rt  r~  r  r  r  r  )r
   r   s   00r   <module>r     s<    ( E E  !89   g&& '	x	    goo & 
	B	B8=>"))D(+>JBBGLMu!"))Hn1)=uMJBB H  "      .3
3U2??1a#U
31a 	kk#q+:/$"-`
%	. 4 4.
5 
\O)$,A@
9,)3

=
>LA"(+TGT$:2A C C2'3.$$50	0 0",0N5m ?M 4s   G5G G