
    sgS                        d Z ddlZddlmZ ddlmZmZmZ  ej                  d      Z	e	j                  ej                          ed      Ze	j                  ej                         ergddlZej                   Zej$                  ZdD  cg c]  } ej!                  | d       c} \  ZZZd	D cg c]  }ej%                  dd
|       c}\  ZZZndZddlZddlmZ ddlm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z' d	D cg c]  } ejP                  |dd       c}\  Z)Z*Z+  ejX                  d      e#      Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4d Z5ed        Z6d Z7d Z8d Z9d Z:d Z;d  Z<d! Z=d" Z>d# Z?d$ Z@d% ZAd& ZBd' ZCd( ZDd) ZEd* ZFd+ ZGd, ZHd- ZId. ZJd/ ZKd0 ZLd1 ZMd2 ZNd3 ZOed4        ZPd5 ZQd6 ZRd7 ZSd8 ZTd9 ZUd: ZVd; ZWd< ZXd= ZYd> ZZd? Z[yc c} w c c}w c c}w )@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FF)nameT)S)xyzt)theano_codedim_handlingtheano_function   fc                 ~    |j                  di        t               5  t        | fi |cddd       S # 1 sw Y   yxY w)zB Wrapper for theano_code that uses a new, empty cache by default. cacheN)
setdefaultr   r   )exprkwargss     W/var/www/html/venv/lib/python3.12/site-packages/sympy/printing/tests/test_theanocode.pytheano_code_r   .   s:    
gr"		! +4*6*+ + +s   3<c                     |j                  di        t               5  t        | |fi |cddd       S # 1 sw Y   yxY w)zF Wrapper for theano_function that uses a new, empty cache by default. r   N)r   r   r   )inputsoutputsr   s      r   theano_function_r!   4   s<    
gr"		! :vw9&9: : :s   4=c                      t        t        t        |             }t        j                  j
                  j                  |      }t        j                  j
                  j                  ||      \  }}t        j                  j                  ||      S )z Transform 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,   ;   sf     L%()D
**


!
!$
'C

  &&sD1IC::##C..    c                     t         j                  j                         j                  d      }| j	                         } |j
                  j                  |        | S )z Simplify 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_simplifyr7   M   sC     >>**,66x@D\\^FNNF#Mr-   c                 |   t         t        t        j                  f}t	        | |      }t	        ||      }|s|r
|r|sy| |k(  S t	        | t
        t        f      }t	        |t
        t        f      }|s|rO|r|rt        |       t        |      k7  ryt        t        t        |             t        t        t        |            k(  S t        j                  j                  | d      }t        j                  j                  |d      }d| |fd||ffD ])  \  }	}
}|dk(  st        d|	d|	d	t        |
      d
       ||k(  S )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)r;   r<   numeric_typesa_is_numb_is_numa_is_seqb_is_seqastrbstrargnameargvalargstrs               r   rF   rF   ^   s2    %+M!]+H!]+H 8XAv !eT]+H!eT]+H8X$q'T!W*<CaL!T#dA,%777 ??%%ae%4D??%%ae%4D &)!TNS!TN#C R< GT&\3  4<r-   c                  x   t        t        t        t                    sJ t        t        t        t
                    sJ t        t        t        t                    sJ t        t        t        t                    sJ t        t        t        t                    sJ t        t        t        t                    sJ y)z
    Check that the example symbols in this module print to their Theano
    equivalents, as many of the other tests depend on this.
    N)rF   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                  h   t        t              } t        | t        j                  t
        j                  f      sJ | j                  dk(  sJ | j                  t        j                  k(  sJ t        t        t        di      }|j                  dk(  sJ |j                  t        j                  k(  sJ y)z. Test printing a Symbol to a theano variable. r^   FbroadcastablesN)	r   r   rC   ttTensorVariabletsScalarVariablebroadcastabler   )xxxx2s     r   test_Symbolrk      s    	aBb2,,b.?.?@AAAr!!!77aff
q!X
7C(((88qvvr-   c                  |    t        t              } t        | t        j                        sJ | j
                  dk(  sJ y)z4 Test printing a MatrixSymbol to a theano variable. r   N)r   rY   rC   rd   re   rh   )XXs    r   test_MatrixSymbolrn      s5    	aBb"++,,,~---r-   c                      g d} | D ]1  }t        t              5  t        t        t        |i       ddd       3 y# 1 sw Y   >xY w)z/ Test MatrixSymbol with invalid broadcastable. )r^   ra   TTFFT)TTrb   N)r   
ValueErrorr   rY   )bcsbcs     r   test_MatrixSymbol_wrong_dimsrv      sI     OC 4J 	4Ar73	4 	44	4 	4s	   <A	c                      t        t              } t        | t        j                        sJ | j
                  dk(  sJ | j                  dk(  sJ y)zG Test printing AppliedUndef instance, which works similarly to Symbol. r^   f_tN)r   rx   rC   rd   re   rh   r   )ftts    r   test_AppliedUndefrz      sH    
s
Cc2,,---"""88ur-   c                      t         t        z   } t        |       }|j                  j                  t
        j                  j                  k(  sJ y N)r   r   r   owneropr   tensoraddr   comps     r   test_addr      s5    q5DD::==FMM-----r-   c                     t        t        t        j                  t                    t
        j                  t                    sJ t        t        t        j                  t                    t
        j                  t                    sJ y r|   )rF   r   sysinr   rd   rU   tanr^   r-   r   	test_trigr      sL    RVVAY'444RVVAY'444r-   c                     t        j                  t        dz  t        j                  t              z         t        j
                  dt        z        z  } t        |       }t        j                  t        dz  t        j                  t              z         t        j                  dt        z        z  }t        ||      sJ y)z; Test printing a complex expression with multiple symbols.    N)r   expr   cosr   logr   r   rd   rU   rV   rW   rF   )r   r   expecteds      r   	test_manyr      s|    66!Q$"#bffQqSk1DDvvb!ebffRj()BFF1R4L8Hhr-   c                     dD ]2  } t        t        t        | i      j                  j                  | k(  r2J  t        t        t        di      j                  j                  dv sJ t        t        dz   t        di      j                  j                  dk(  sJ t        t        t        z   t        dt        di      j                  j                  dk(  sJ y)	zA Test specifying specific data types through the dtype argument. )float32float64int8int16int32int64dtypesr	   )r   r      r   r   N)r   r   rE   dtyper   )r   s    r   
test_dtyper      s    J FAq%j166<<EEEF 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                  p    t         t        fD ]'  } dD ]   }t        | | |i      j                  |k(  r J  ) y)zG Test the "broadcastables" argument when printing symbol-like objects. )r^   ra   rp   r   rq   rb   N)r   rx   r   rh   )sru   s     r   test_broadcastablesr      sI     X OH 	OB1b':HHBNNN	OOr-   c                      t         t        z   } g dg dg dg dg dg}|D ]0  \  }}}t        | t         |t        |i      }|j                  |k(  r0J  y)zG Test "broadcastable" attribute after applying element-wise binary op. )r^   r^   r^   )ra   ra   ra   )rp   ra   ra   )rr   r   r   )rq   r   r   rb   N)r   r   r   rh   )r   casesbc1bc2bc3r   s         r   test_broadcastingr      se     q5D 	&%77E  )S#D!S!S1AB!!S((()r-   c                     t         t        z  t        z  } t        |       }t	        |j
                  j                  t        j                        sJ t        |t        j                  t              j                  t                    sJ y r|   )rY   r[   r]   r   rC   r}   r~   rd   DotrF   rX   dotrZ   r\   )r   expr_ts     r   test_MatMulr      sV    Q3q5D$Fflloorvv...r
r*+++r-   c                      t        t        t        j                        j                  j
                  t        j                        sJ y r|   )rC   r   rY   Tr}   r~   rd   
DimShuffler^   r-   r   test_Transposer      s+    l133'--00"--@@@r-   c                      t         t        z   t        z   } t        t	        |       j
                  j                  t        j                        sJ y r|   )	rY   r[   r]   rC   r   r}   r~   rd   Elemwiser   s    r   test_MatAddr      s4    Q3q5Dl4(..112;;???r-   c                      t        t        t        j                  d      dz        t        j                  dd            sJ t        t        t        j                        t        j                  dd            sJ y )Nr      r   )rF   r   r   Integerrd   true_divr   Halfr^   r-   r   test_Rationalsr     sS    RZZ]Q./Q1BCCCQVV$bkk!Q&7888r-   c                  J    t        t        j                  d            dk(  sJ y )Nr   )r   r   r   r^   r-   r   test_Integersr     s    

1&!+++r-   c                  n    t        j                  d      } t        t        j                  |             sJ y )Nn)r   Symbolr   	factorial)r   s    r   test_factorialr     s%    
		#AQ(((r-   c                     d } t         | t        t        j                  t        j                  t
              t
        d                   | t        j                  t        j	                  t              t                          sJ y )Nc                 *    t        t        |             S r|   )r7   r,   r   s    r   <lambda>z!test_Derivative.<locals>.<lambda>  s    	$8 r-   Fevaluate)
rF   r   r   
Derivativer   r   r   gradrd   rU   )simps    r   test_Derivativer     sU    8D\"--q	1u"MNOV[[R013 3 3r-   c                  d    t        t        t        gt        t        z   g      }  | dd      dk(  sJ y)z, Test theano_function() with single output. r   r      Nr!   r   r   )r   s    r   test_theano_function_simpler     s*    !Q!A#'AQ7a<<r-   c                      t        t        t        gt        t        z   t        t        z
  g      }  | dd      \  }}|dk(  sJ |dk(  sJ y)z/ Test theano_function() with multiple outputs. r   r   r   Nr   )r   o1o2s      r   test_theano_function_multir     sC    !Q!A#qs,Aq!WFB7N78O8r-   c            	      t   t        t        t        gt        t        z   gdt        dt        di      } t        j                  j                   | ddgddg      t        j                  ddg      z
        dk  sJ t        t        t        gt        t        z   gt        dt        did	      } t        j                  d      j                  d      }dt        j                  d      j                  d      z  }t        j                  j                   | ||      dt        j                  d      z  z
        dk  sJ y
)z1 Test theano_function() vs Numpy implementation. r   r   )dimr   r   r   r      &.>)r   r   N)	r!   r   r   rA   linalgnormasarrayarangeastype)r   ri   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                     t        j                  t        t        gt        t        t        z   t        z   gg      } t        j                  ddgddgg      }t        t        t        t        g| g      }t
        j                  j                   |ddd      |       t        t        t        t        g| gd      }t
        j                  j                   |ddd      |       t        t        t        t        g| | g      }t         |ddd      t        g             sJ t
        j                  j                   |ddd      d   |       t
        j                  j                   |ddd      d   |       y )	N      ?       @g      @g      @T)scalarr   r   )r   Matrixr   r   r   rA   arrayr!   testingassert_allcloserC   rE   )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QF+AaS#&R111JJqc3/2H=JJqc3/2H=r-   c                      t        t        gd      t        dik(  sJ t        t        t        gt        dt        di      t        dt        dik(  sJ t        t        gt        di      t        dik(  sJ y )	Nr   )r   r   r   )dimsrr   ra   rb   )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                     ddl } t        t        t        t        gt        t        z   gddt        dt        dt        di      }| j
                  j                   |ddgdd	gddg       | j                  d	d
g      z
        dk  sJ t        t        t        t        gt        t        z   gt        dt        dt        didd      } | j                  d      j                  d      }d | j                  d      j                  d      z  }d | j                  d      j                  d      z  }| j
                  j                   ||||      d | j                  d      z  z
        dk  sJ y)zU
    Test passing additional kwargs from theano_function() to theano.function().
    r   Nr   ignorer   )r   on_unused_inputr   r   r   r   r   r   )r   r   r   )
numpyr!   r   r   r   r   r   r   r   r   )rA   r   ri   r   zzs        r   test_theano_function_kwargsr   @  s8    !QQqSEq(y!Y9=	?A99>>!QFQFQF3jbjj!Q6HHIDPPP!QQqSE !9aAyIx	9A 
1		Y	'B	
9299Q<y)	)B	
9299Q<y)	)B99>>!BB-!IBIIaL.89D@@@r-   c                  >   t         t        gt         t        z   gddgft        t        gt        t        z   gddgft         t        gt         t        z   gt         dt        didgft         t        gt         t        z   t         t        z
  gdddgft         t        t        t        gt         t        z   t        t        z   gdddgfg} | D ]N  \  }}}}dD ]@  }t	        ||||      }t        |j                  t        j                  j                  j                        sJ |j                  j                  D cg c]=  }t        j                  |j                  j                  D cg c]  }|rdnd
 c}      ? }	}} ||	 }
t        |
t               s|
g}
t#        |      t#        |
      k(  sJ t%        ||
      D ]V  \  }}|r"|dk(  rt        |t        j&                        r(J t        |t        j(                        sJ |j*                  |k(  rVJ  C Q yc c}w c c}}w )z2 Test the "scalar" argument to theano_function(). Nr   r   r   rr   )r   r   r   )r   r   rY   r[   r!   rC   r   r   r0   function_moduleFunctioninput_storagerA   onesrE   rh   r#   lenziprB   ndarrayndim)argsr   r    in_dimsout_dimsr   r   iru   	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 wvNA a//1O1O1X1XYYY
 **88 !&&2F2FGBbaGHI  IJj$/(\
 x=C
O333*5 	+5a1f%eRYY777 &eRZZ888 ::?*?	+%	++ Hs   2,H
H+	H
H
c                  &    t        t        d        y)za
    Passing an unknown keyword argument to theano_function() should raise an
    exception.
    c                  8    t        t        gt        dz   gd      S )Nr   r   )foobar)r!   r   r^   r-   r   r   z0test_theano_function_bad_kwarg.<locals>.<lambda>  s    /acU1E r-   N)r   	Exceptionr^   r-   r   test_theano_function_bad_kwargr  {  s    
 9EFr-   c            	      N   t        t        ddd            t        ddd      k(  sJ d } t        dt        di} | t        t        t        t              |      t        t        t
                    sJ  | t        t        dt        d      |      t        dt        d            sJ y )Nr   r   r   c                 v    dD ]4  }t        | |      }t        ||      }|||"|% yt        ||      r4 y y)N)startstopstepFT)getattrrF   )s1s2attra1a2s        r   
theq_sliceztest_slice.<locals>.theq_slice  sO    - 	DT"BT"BzRZ
bj "b\	 r-   r   r   )r   slicer   r   rU   rV   )r  r   s     r   
test_slicer    s    aA'5Aq>999	 !W%Fl5A;v>b"NNNl5Aq>&A5BPQ?SSSr-   c                  |  	
 ddl m i } t        j                  dd      }t        j                  d||      }|ddd	d
ddf   }t        ||       	t        j                  d      
t        	j                  j                  j                        t        


      t        


      fk(  sJ 	j                  j                  d   t        ||       k(  sJ t        	
fdt        dd      D              sJ t        j                  d      }t        ||di       d
|d}}}||||   }t        ||d|di      	y )Nr   )Constantr   TintegerrY   r   r   r   r   r   r   r   r   c              3   |   K   | ]3  }j                   j                  |   j                   |             5 y wr|   )r}   r   equals).0r   r  rZ   r   s     r   	<genexpr>z#test_MatrixSlice.<locals>.<genexpr>  s/     NQrxxq!((!Q8Ns   9<   kr   r   )r   r  r   r   MatrixSymbolr   rf   ScalarrD   r}   r~   idx_listr  r   allrange)r   r   rY   r[   r  r  r	  r
  r  rZ   r   s           @@@r   test_MatrixSlicer$    s!   E
		#t$A
Q"A	!Aa%1Q,A	au	%B
		'A%%&5Aq>5Aq>*JJJJ88??1au!==== N%1+NNNN
		#AAw<(1a4E	%T/A	aGQ 8	9Br-   c            
      @   t        j                  dd      } dD cg c]  }t        j                  || |        c}\  }}}}t        t        ||||f      \  }}}}	t        j
                  ||g||gg      }
t	        |
      t        j                  dt        j                  d||      t        j                  d||	            t        j                  dt        j                  d||      t        j                  d||	            g}t        fd|D              sJ y c c}w )Nr   Tr  ABCDr   r   c              3   6   K   | ]  }t        |        y wr|   )rF   )r  solutionBlockts     r   r  z#test_BlockMatrix.<locals>.<genexpr>  s     @(tFH%@s   )	r   r   r  r$   r   BlockMatrixrd   joinany)r   r   ABCDAtBtCtDtBlock	solutionsr)  s               @r   test_BlockMatrixr7    s    
		#t$A:@A$"//$1-AJAq!Q1a|4NBBNNQFQF+,E% FBGGAr2.2r0BCBGGAr2.2r0BCEI@i@@@@ Bs   Dc            	          d\  } }d}t        j                  d||       }t        j                  d||      }||f}|j                  |z  }||dz  |dz  f| dz  | dz  fg||dz  |dz  f|dz  |dz  fgi}|D cg c]  }t        j                  |g||     }	}|j	                  t        t        ||	                  }
t        t        ||gt        |      z              }t        ||g|i       }t        |t        j                  |
      g|i       }|D cg c]7  }t        j                  j                  |j                   j                  |      9 }}t        j                  || z        j!                  |j                        j                  |      t        j"                  |      j                  |      g}|dxx   t        j$                  |j                        dz  z  cc<   t        j&                   ||  || d	      sJ y c c}w c c}w )
N)r   r   r   r-  r.  r   )r   r   r   gh㈵>)rtol)r   r  Iblockcutsubsdictr   r   r!   block_collapserA   randomrandshaper   r   reshapeeyer   allclose)r  r   r   r-  r.  r   outputcutsizesr   	cutinputs	cutoutputr   r   fblockedr   ninputss                   r   "test_BlockMatrix_Inverse_executionrK    s   DAqE
Q"A
Q"ATFSSUFQT1a4L1a4A,/QT1a4L1a4A,/1H7=>!Q-!->I>DVY!789I#fugc&k123F&&CA):):9)E(F'-R9H @FF!ryy~~qww'..u5FGFyy1~%%agg.55e<vvay&(GAJ"''!''"4''J;;q'{Hg$6TBBB ? Gs   7 H<Hc                     t        j                  d      } t         j                  t         j                  fD ]  } |t        j                  |       t        j
                  |        gt        j
                  |       t        j                  |       gg      }t        |      }t        |t        j                        sJ |j                  j                  t        j                  k(  rJ  y )Ntheta)r   r   r   ImmutableMatrixr   r   r   rC   rd   re   r}   r~   join_)r   
MatrixTyperY   tXs       r   test_DenseMatrixrR    s    
		'Ayy""4"45 '
RVVAYJ/"&&)RVVAY1GHI!_"b//000xx{{bhh&&&	'r-   c                     t         t        j                  d      ft        t        j                  dgt        j
                   ft         t        j                  d      t        j                  d            fg} | D ]G  \  }}i }t        ||      }t        ||      |u sJ t        |i       |usJ t        ||      |u rGJ  y)zH Test single symbol-like objects are cached when printed by themselves. r   rY   r   r   r  N)	r   r   r   rY   r  rA  rx   r   r   )pairsr  r  r   sts        r   test_cache_basicrV    s    
 
BIIcN	
BOOC*!''*+	bkk#ryy~./E  3B"E* Be,222 Bb)333 Be,2223r-   c                  8   ddl m}  t        |       }	 | j                          t        t
        t        fD ]0  }t               5  t        |      }t        |      |u sJ 	 ddd       2 	 | j                  |       y# 1 sw Y   OxY w# | j                  |       w xY w)z Test use of the global cache. r   )global_cacheN)
sympy.printing.theanocoderX  r=  clearr   rY   rx   r   r   update)rX  backupr   rU  s       r   test_global_cacher]    s    6,F$Q 	,A') , ^"1~+++, ,	, 	F#, , 	F#s#   .B A:
B :B	?B Bc            	         t        j                  d      t        j                  ddd      t        g} i }i }| D ](  }t	        ||      }||j                         vsJ |||<   * t        t        t        t        |j                                           t        |       k(  sJ |j                         D ]*  \  }}t               5  t        ||      |u sJ 	 ddd       , y# 1 sw Y   7xY w)z
    Test that symbol-like objects of different types (Symbol, MatrixSymbol,
    AppliedUndef) are distinguished by the cache even if they have the same
    name.
    rx   r   r  N)r   r   r  rx   r   valuesr   setr$   iditemsr   r   )symbolsr   printedr   rU  s        r   test_cache_types_distinctre    s     yy1!=sCGEG !5)))))
 s3r7>>+,-.#g,>>>  52#% 	5q."444	5 	55	5 	5s   CC(	c                      t        j                  t        t        d      } t        |       }t	        |t
        t
        z         sJ t	        |t
        t        t              z         rJ y)zf
    Test that a symbol is cached and reused when it appears in an expression
    more than once.
    Fr   N)r   Addr   r   rF   rU   r   s     r   test_symbols_are_created_oncerh    sP    
 66!Q'DDb2gD"|A.////r-   c                  |   t         dz  t        t        j                  t               z
  t        j                  t
        t         t        z  z
        z  z   } | j                  D ch c]  }|j                   }}t        |       }t               }t        j                  j                  j                  |g      D ]y  }|j                  t        |t        j                  j                  j                         r?|j                  |v sJ |j                  |vsJ |j#                  |j                         { ||k(  sJ yc c}w )zf
    Test caching on a complicated expression with multiple symbols appearing
    multiple times.
    r   N)r   r   r   r   r   r   free_symbolsr   r   r`  r   r%   r&   	ancestorsr}   rC   r  r   )r   r   symbol_namesr   seenvs         r   test_cache_complexro  '  s    
 6Q]bffQQY&777D$($5$56qAFF6L6$F 5DZZ''1 77?:a1A1A1J1J#K66\)))66%%%HHQVV < 7s   !D9c                  .   t        j                  dt        dk  ft        t        dk  fd      } t        |       }|j                  j
                  t        j                  k(  sJ t        j                  t        dk  dt        j                  t        dk  t        d            }t        ||      sJ t        j                  t        t        dk  f      } t        |       }t        j                  t        dk  t        t        j                        }t        ||      sJ t        j                  dt        j                  t        dkD  t        dk        ft        t        j                  t        dkD  t        dk        f      } t        |       }t        j                  t        j                  t        dkD  t        dk        dt        j                  t        j                  t        dkD  t        dk        t        t        j                              }t        ||      sJ y )Nr   r   )r   Tr   )r   	Piecewiser   r   r}   r~   rd   switchrU   rF   rA   nanAndOrand_or_)r   resultr   s      r   test_Piecewisery  ?  sq   <<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                  
   t        t        t        j                  t        t
                    t        j                  t        t                    sJ t        t        t        t
        kD        t        t        kD        sJ t        t        t        t
        k        t        t        k        sJ t        t        t        t
        k\        t        t        k\        sJ t        t        t        t
        k        t        t        k        sJ y r|   )
rF   r   r   Eqr   r   rd   eqrU   rV   r^   r-   r   test_Relationalsr}  U  s    RUU1a[)255R=999QU#R"W---QU#R"W---Q!V$bBh///Q!V$bBh///r-   c                     t               5  t        t        t        di      t        t        t        di      }} d d d        ddlm} ddlm} ddlm} t               5  t        t        t         |t              z         j                         z        sJ t        t        dt        z        |  |d       |d	       |dd
      z  z   z        sJ 	 d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)N
complex128r   r   )	conjugate)as_tensor_variable)complexy      ?       @r   r   r   )r   r   r   r   $sympy.functions.elementary.complexesr  theano.tensorr  r  rF   conj)rU   rV   r  atvcplxs        r   test_complexfunctionsr  ^  s    		! ea<(89<STVbRc;dBe>7-		! NL9Q<0"bggi.AAAL$*BCS$q)9K0K,LMMMN Ne e
N Ns   /CA4C(C%(C1c                  t    t               5  t        g dg      } d d d                 dk(  sJ y # 1 sw Y   xY w)Ny      ?      ?)r   r!   )tfs    r   test_constantfunctionsr  i  s9    		! )b$()4::) )s   .7c                  2   t        j                  d      } t         j                  }t        j                  j                  t        |       t        j                         t        j                  j                  t        |      t        j                         t        |       }t        j                  j                  t        |       |j                                t        |      }t        j                  j                  t        |      |j                                y)zP
    Test that exp(1) prints without error and evaluates close to SymPy's E
    r   N)
r   r   ErA   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-   )\__doc__loggingsympy.externalr   sympy.testing.pytestr   r   r   	getLoggertheanologgersetLevelCRITICALr   WARNINGr   rA   r   rf   r   rd   rU   rV   rW   rX   rZ   r\   disabledsympyr   sympy.core.singletonr   	sympy.abcr   r   r   r   rY  r   r   r   r  rY   r[   r]   r   rx   r   r!   r,   r7   rF   r_   rk   rn   rv   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r$  r7  rK  rR  rV  r]  re  rh  ro  ry  r}  r  r  r  )r   r   s   00r   <module>r     s8    ( E E w  !89   g&& '	x	    goo & 
	B	B8=>"))D(+>JBBGLM!"))Hn1)=MJBB H  "      .3
3?2??1a#
31a kbkk#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-G
6G