
    MZd[                        d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZmZmZmZ 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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/m0Z0 d dl1m2Z2 d dl3m4Z4 d dl5m6Z6 d dl7m8Z8 d dlm9Z9 d dlm:Z: d dl;m<Z<  e<d      Z=h dZ>g dfdZ?d Z@d ZAd ZBd ZCd ZDd ZEd ZFd ZGd  ZHd! ZId" ZJed#        ZKd$ ZLd% ZMd& ZNd d'lOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZmZmZmZmZmZmZmZmZmZ d( Zd d)lmZ d d*lmZ d d+lmZmZ d d,lmZmZmZmZ d d-lmZmZmZ d. Zd d/lmZ d0 Zd d1lmZ d2 Zd d3lmZmZ d4 Zd d5lmZ d6 Zd d7lmZ d d8lmZ d9 Zed:        Zed;        Zd d<lmZ d d=lmZ d d>lmZ d d?lmZ d@ ZdA ZedB        ZdC ZdD ZdE ZdF ZdG ZdH ZdI Zd dJlmZ d dKlmZmZ d dLlmZ d dMlmZmZ d dNlmZ d dOlmZ dP ZedQ        ZedR        ZedS        Zd dTlmZ d dUlmZ dV Zd dWlmZ d dXlmZ dY ZdZ Zd[ Zd\ Zy)]    N)meter)XFAILraises)AtomBasic)SingletonRegistry)StrDummySymbolWild)
EIpioozoonanIntegerRationalFloatAlgebraicNumber)EqualityGreaterThanLessThan
RelationalStrictGreaterThanStrictLessThan
Unequality)Add)Mul)Pow)
DerivativeFunctionFunctionClassLambdaWildFunction)Interval)	vectorize)HAS_GMPY)SymPyDeprecationWarning)S)symbols)import_modulecloudpickle>   _mat_smat_mhashis_EmptySet_assumptionsexpr_free_symbolsTc                     t         t              rdD ]  t        t         fd        dt        j                  t        j
                  ddg}t        r|j                  t        g       |D ]  |v rt              rt         t              r$        }n_t        j                        r!j                  j                               }n)t        j                  t        j                               }t               }t        |      }t!        |      t!        |      k(  sJ |sfd} | ||        || |        y)z2 Check that pickling and copying round-trips.
    )r      c                  0    t        j                         S N)pickledumps)aprotocols   E/usr/lib/python3/dist-packages/sympy/utilities/tests/test_pickling.py<lambda>zcheck.<locals>.<lambda>1   s    Q0I              c                     |D ]l  }|t         v rt        | |      st        | |      }t        |d      r2t        ||      sJ |       t        ||      |k(  rUJ t        ||      d|d        y )N__call__z != z, protocol: )excluded_attrshasattrgetattr)r:   bdiattrr;   s        r<   czcheck.<locals>.cL   s}     m&q!}q!}tZ0"1a=+!+="1a=D0lgVWYZm]ack2ll0mr>   N)
isinstancer   r   NotImplementedErrorcopydeepcopyr-   extendcallabletypeinspectismoduleloadsr9   r8   dirset)	r:   exclude
check_attr	protocolsrG   d1d2rK   r;   s	   `       @r<   checkr]   +   s    !U 	KH&(IJ	K DIIt}}a3I+' !wH!T"Ah'x~~a01AV\\!X67AVV2w#b'!!!		m 	
!Q	!QC!r>   c                  t    t         t               t        t               t        t        fD ]  } t	        |         y r7   )r   r   r   r*   r]   rK   s    r<   test_core_basicr`   _   s*    DFE57,=qA ar>   c                  ,    t        t        d             y Nx)r]   r	    r>   r<   test_core_Strre   c   s    	#c(Or>   c                      t         t        dd      t        t        dd      t        t        d      fD ]  } t        |         y )Nrc   F)commutative_issue_3130)r
   r   r   r]   r_   s    r<   test_core_symbolri   f   s=     U3E2F=e4dDIG ar>   c                      t        d      t        dd      t        d      fD ]  } t        |         t        t	        t        d            fD ]  } t        | d        y )Nr?   r@   z1.2FrY   )r   r   r   r]   r   sqrtr_   s    r<   test_core_numbersrm   o   sT    aj(1a.%,7 atAw78 #aE"#r>   c                  6    t        d      dz   } t        |        y )Nrc   g      ?)r   r]   )ys    r<   test_core_float_copyrp   v   s    scA	!Hr>   c                  4   t        d      } t        d      }t        t        | |      t        t        | |      t        t        | |      t        t	        | |      t
        t        | |      t        t        | |      t        t        | |      fD ]  }t        |        y )Nrc   ro   )	r   r   r   r   r   r   r   r   r]   )rc   ro   rK   s      r<   test_core_relationalrr   |   s    sAsAA[A5FA
Jq!4D!21a!8.Q"J
1a0@B  	a	r>   c                  ^    t        d      } t        t        | d      fD ]  }t        |        y Nrc   rA   )r   r   r]   rc   rK   s     r<   test_core_addrv      ,    sA3q!9 ar>   c                  ^    t        d      } t        t        | d      fD ]  }t        |        y rt   )r   r   r]   ru   s     r<   test_core_mulry      rw   r>   c                  ^    t        d      } t        t        | d      fD ]  }t        |        y rt   )r   r    r]   ru   s     r<   test_core_powerr{      rw   r>   c                      t        d      } t        t        |       t        t        t        t
        fD ]  }t        |        y rb   )r   r!   r"   r#   r$   r%   r]   )rc   fs     r<   test_core_functionr~      s5    sA*Q-=& ar>   c                      t        d      } t        t        d            }|j                  t               t        | |       y )Nr}      rX   )r"   listrangeappendr-   r]   )r}   rX   s     r<   test_core_undefinedfunctionsr      s0    A58nG NN;	!Wr>   c                  0    t        d      } t        |        y )Nr}   )r"   r]   )r}   s    r<   !test_core_undefinedfunctions_failr      s     	A	!Hr>   c                  H    t         t        dd      fD ]  } t        |         y )Nr   r?   )r&   r]   r_   s    r<   test_core_intervalr      s#    A' ar>   c                  F    t         t        d      fD ]  } t        |         y )Nr   )r'   r]   r_   s    r<   test_core_multidimensionalr      s!    1& ar>   c                  "   g d} t         j                   t         j                  g}|| D cg c]  fd	 c}z  }t        r|d gz  }t        d      t        d      t        d      t	        dd      t
        t        t        t        t         t        t        t        j                  t        j                  t        j                  t        j                  t        j                   t        j"                  fD ]  }|D ]  } ||      |u rJ   y c c}w )N)r   r5   r?   r@   rA   c                 V    t        j                  t        j                  |             S r7   )r8   rU   r9   )rc   protos    r<   r=   z!test_Singletons.<locals>.<lambda>   s    &,,v||Au'=> r>   c                 R    t         j                  t         j                  |             S r7   )r-   rU   r9   )rc   s    r<   r=   z!test_Singletons.<locals>.<lambda>   s    k//0A0A!0DE r>   r   r5   r?   )rN   rO   r-   r   r   r   r   r   r   r   r   r*   GoldenRatioTribonacciConstant
EulerGammaCatalanEmptySetIdentityFunction)rZ   copiersr   objfuncs     `  r<   test_Singletonsr      s    Iyy$--(G"$ ? $ $GEFFWQZXa^RAS#q}}a.B.BLL!))QZZ1C1CE $  	$D9###	$$$s   D);	Piecewise
lowergammaacosh
chebyshevu
chebyshevtlnchebyshevt_rootlegendre	Heaviside	bernoullicothtanhassoc_legendresignargasin
DiracDeltarerfAbs
uppergammabinomialsinhcoscotacosacotgammabellhermiteharmonicLambertWzetalog	factorialasinhacothcoshdirichlet_etaEijkloggammaerfceilingim	fibonacci
tribonacci	conjugatetanchebyshevu_rootflooratanhrl   sinatanfflucasatan2	polygammaexpc                     g t         t        t        t        t        t
        t        t        t        t        t        t        t        t        t        t        t         t"        t$        t&        t(        t*        t,        t.        t        t0        t2        t4        t6        t8        t:        t<        t>        t@        tB        tD        tF        tH        tJ        tL        tN        tP        tR        } tT        tV        tX        tZ        t\        t^        t`        tb        td        tf        th        f}tk        d      \  }}}tl        tn        tq        |||      ts        d|dk  f|dz  |dk  f|dz  df      tt        f}| D ]   }tw        |        ||      }tw        |       " |D ]!  }tw        |        |||      }tw        |       # |D ]  }tw        |        y )Nx,y,zr   r   r?   r5   r@   T)<r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r+   r   r   r   r   r   r]   )one_vartwo_varrc   ro   zothersclsrK   s           r<   test_functionsr      s   Mu Mb M) MY M	 M4 M MMMM'M)+M-0M26M8;M=@MBFMHLMMM!M#+M-1M36M8AMCHM M M 'M )1M 36M 8?M ACM ENM 	M "	M $'	M ).	M 05	M 7:	M <@	M BG	M IL	MG
 2z:z89gx=GgGAq!Q11r6{QT16NQT4LAF  c
Fa  c
1Ia  c
r>   )GeometryEntity)Point)CircleEllipse)LineLinearEntityRaySegment)PolygonRegularPolygonTrianglec                     t        dd      } t        dd      }t        dd      }t        dd      }t        t               t         | t        t        | d      t        t        | dd      t        t	        | |      t
        t        | |      t        t        | |      t        t        | |      t        t        | |||      t        t        | dd      t        t        | ||      fD ]  }t        |d        y )	Nr5   r?   r@   r   rA   r   Frk   )r   r   r   r   r   r   r   r   r   r   r   r]   )p1p2p3p4rK   s        r<   test_geometryr      s    	q!B	q!B	q!B	q!B(%VVB]Q"D$r2,Rc3r2;RRR(.2q!$hR0DF # 	aE"#r>   )Integralc                  \    t        d      } t        t        |       fD ]  }t        |        y rb   )r   r   r]   ru   s     r<   test_integralsr     s*    sA$ ar>   )Logicc                  F    t         t        d      fD ]  } t        |         y Nr5   )r   r]   r_   s    r<   
test_logicr     s!    U1X ar>   )MatrixSparseMatrixc                  t    t         t        g d      t        t        ddgddgg      fD ]  } t        |         y )Nr5   r?   r@   r5   r?   r@   rA   )r   r   r]   r_   s    r<   test_matricesr     s9    fY'|aVaQRVDT7UV ar>   )Sievec                  D    t         t               fD ]  } t        |         y r7   )r   r]   r_   s    r<   test_ntheoryr     s    UW ar>   )Pauli)Unitc                  Z    t         t        t        t        d      fD ]  } t        |         y r   )r   r   r   r]   r_   s    r<   test_physicsr   %  s%    E5%(+ ar>   c                  8   ddl m} m} ddlm} ddlm}m} ddlm	}m
}m}m} ddlm}	 ddlm}
 ddlm} dd	lm} dd
lm} ddlm}m}m}m}m}m}m}m} ddl m!} ddl"m#} ddl$m%} |  | dd      ||||||||||	|
||||||||||||||fD ]  }tM        |        y )Nr   )ColorGradientColorScheme)ManagedWindow)Plot
ScreenShot)PlotAxesPlotAxesBasePlotAxesFramePlotAxesOrdinate)
PlotCamera)PlotController)	PlotCurve)PlotInterval)PlotMode)Cartesian2DCartesian3DCylindricalParametricCurve2DParametricCurve3DParametricSurfacePolar	Spherical)
PlotObject)PlotSurface)
PlotWindowg?g?)'&sympy.plotting.pygletplot.color_schemer  r  (sympy.plotting.pygletplot.managed_windowr  sympy.plotting.plotr  r  #sympy.plotting.pygletplot.plot_axesr  r  r	  r
  %sympy.plotting.pygletplot.plot_camerar  )sympy.plotting.pygletplot.plot_controllerr  $sympy.plotting.pygletplot.plot_curver  'sympy.plotting.pygletplot.plot_intervalr  #sympy.plotting.pygletplot.plot_moder  $sympy.plotting.pygletplot.plot_modesr  r  r  r  r  r  r  r  %sympy.plotting.pygletplot.plot_objectr  &sympy.plotting.pygletplot.plot_surfacer  %sympy.plotting.pygletplot.plot_windowr  r]   )r  r  r  r  r  r  r  r	  r
  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rK   s                             r<   test_plottingr(  -  s    QF4kk@H>D<R R R@B@}S#.]tZ<'^<;&(95)Z  	ar>   c                      ddl m}  ddlm} ddlm} t         | d             t         |dd             t         |              y )	Nr   )r  )r  )r  rainbowr5   F)visible)r  r  r  r  r  r  r]   )r  r  r  s      r<   test_plotting2r,  H  s6     C(< 
+i
 !	$q%
 !	(*r>   )ZZ)QQ)lex)Polyc                      ddl m}  t        d      }t        t        ||      fD ]  }t	        |        |  | |      fD ]  }t	        |        y )Nr   )PurePolyrc   )sympy.polys.polytoolsr2  r   r0  r]   )r2  rc   rK   s      r<   test_pickling_polys_polytoolsr4  e  sP    .sADAJ a $ ar>   c            	         ddl m} m}m} |  | t	        d      gt	        d      gt	        d      ggt              fD ]  }t        |        | |t	        d      t	        d      gt	        d      t	        d      gft              fD ]  }t        |        | |t        d      t        d      gt        d      t        d      t        d      gt              fD ]  }t        |        y )Nr   )DMPDMFANPr5   r?   r@   )sympy.polys.polyclassesr6  r7  r8  r-  r]   r.  )r6  r7  r8  rK   s       r<   test_pickling_polys_polyclassesr:  t  s    553A"Q%2a5'2B78 a3A1A17<= a31r!u~1r!ube'<bAB ar>   c                      ddl m}   | dt        t              }| |fD ]  }t	        |ddg        |j
                  |j                  fD ]  }t	        |ddgd        y )Nr   )PolyRingr   r5   r   F)rX   rY   )sympy.polys.ringsr<  r-  r/  r]   dtypeone)r<  ringrK   s      r<   test_pickling_polys_ringsrA  ~  se    
 +GR%D !a!Q ! jj$((# 3a!QE23r>   c                       y r7   rd   rd   r>   r<   test_pickling_polys_fieldsrC    s    r>   c                  F    ddl m}  |  | dd      fD ]  }t        |        y )Nr   )PythonRationalr5      )"sympy.polys.domains.pythonrationalrE  r]   )rE  rK   s     r<   test_pickling_polys_elementsrH    s)    A nQ23 ar>   c                     ddl m}  ddlm} |  |        fD ]  }t	        |d        | |       fD ]  }t	        |d        t
        rBddlm} ddlm	} | |       fD ]  }t	        |d        | |       fD ]  }t	        |d        ddl
m} dd	lm} | |t        t        d
            fD ]  }t	        |d        | |       fD ]  }t	        |d        y )Nr   )PythonIntegerRing)PythonRationalFieldFrk   )GMPYIntegerRing)GMPYRationalField)AlgebraicField)ExpressionDomainr@   )%sympy.polys.domains.pythonintegerringrJ  'sympy.polys.domains.pythonrationalfieldrK  r]   r(   #sympy.polys.domains.gmpyintegerringrL  %sympy.polys.domains.gmpyrationalfieldrM  "sympy.polys.domains.algebraicfieldrN  $sympy.polys.domains.expressiondomainrO  r.  rl   )rJ  rK  rK   rL  rM  rN  rO  s          r<   test_pickling_polys_domainsrV    s    GK  !2!45 #aE"# "#6#89 #aE"# GK "?#45 	'A!&	' $%6%89 	'A!&	'
 B F nRa9: #aE"#  0 23 #aE"#r>   c                      ddl m} m}m}m} |  |        fD ]  }t        |        | |       fD ]  }t        |        | |       fD ]  }t        |        | | |              fD ]  }t        |        y )Nr   )LexOrderGradedLexOrderReversedGradedLexOrderInverseOrder)sympy.polys.orderingsrX  rY  rZ  r[  r]   )rX  rY  rZ  r[  rK   s        r<   test_pickling_polys_orderingsr]    s    . . 
# a n./ a %&<&>? a L45 ar>   c                      ddl m} m} t        d      \  }}}|  | d      fD ]  }t	        |        | |d|||f      fD ]  }t	        |        y )Nr   )MonomialOpsMonomialr   r@   r   )sympy.polys.monomialsr_  r`  r+   r]   )r_  r`  rc   ro   r   rK   s         r<   test_pickling_polys_monomialsrb  
  s^    ;gGAq!;q>* a Q1I67 ar>   c                     ddl m} m}m}m}m}m}m}m}m	}m
}	m}
m}m}m}m}m}m}m}m} |  |        fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        |	 |	       fD ]  }t)        |        |
 |
       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        | |       fD ]  }t)        |        y )Nr   )HeuristicGCDFailedHomomorphismFailedIsomorphismFailedExtraneousFactorsEvaluationFailedRefinementFailedCoercionFailedNotInvertibleNotReversibleNotAlgebraicDomainErrorPolynomialErrorUnificationFailedGeneratorsErrorGeneratorsNeededUnivariatePolynomialErrorMultivariatePolynomialErrorOptionError	FlagError)sympy.polys.polyerrorsrd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  ro  rp  rq  rr  rs  rt  ru  rv  r]   )rd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  ro  rp  rq  rr  rs  rt  ru  rv  rK   s                       r<   test_pickling_polys_errorsrx    s        ( !"4"67 a !"4"67 a  !2!45 a  !2!45 a  0 23 a  0 23 a n./ a ]_- a ]_- a LN+ a ;=) a 01 a  !2!45 a 01 a  0 23 a ()B)DE a *+F+HI a ;=) a % ar>   c                      ddl m} m} t        d      }|dz  |z   dz   }|  | |d      fD ]  }t	        |        | ||t
              fD ]  }t	        |        y )Nr   )CRootOfRootSumrc   r@   )sympy.polys.rootoftoolsrz  r{  r   r]   r   )rz  r{  rc   r}   rK   s        r<   test_pickling_polys_rootoftoolsr}  u  sc    8sA	1q1Awq!}% a wq#' ar>   )LatexPrinter)MathMLContentPrinterMathMLPresentationPrinter)PrettyPrinter)
prettyForm
stringPict)Printer)PythonPrinterc                      t         t               t        t        t        t        t
        t        d      t        t               t        t               fD ]  } t        |         y )Nr:   )	r~  r  r  r  r  r  r  r  r]   r_   s    r<   test_printingr    sC    LN,@'
Jow	=o  	a	r>   c                  *    t        t                      y r7   )r]   r  rd   r>   r<   test_printing1r    s    	

 !r>   c                  *    t        t                      y r7   )r]   r  rd   r>   r<   test_printing2r    s    	
#
%&r>   c                  *    t        t                      y r7   )r]   r  rd   r>   r<   test_printing3r    s    	-/r>   )Limit)Orderc                      t        d      } t        d      }t        t        | |d      t        t        |       fD ]  }t        |        y )Nerc   r5   )r   r  r  r]   )r  rc   rK   s      r<   test_seriesr    s?    sAsAU1a^UE!H5 ar>   )Product)Sumc            	          t        d      } t        t        | | ddf      t        t        | | ddf      fD ]  }t        |        y )Nrc   r?   rA   )r   r  r  r]   ru   s     r<   test_concreter    sD    sAwq1a),c3q1a)3DE ar>   c                  6    t        ddd      } t        |        y )Nmessagez1.0zactive-deprecations)deprecated_since_versionactive_deprecations_target)r)   r]   )ws    r<   test_deprecation_warningr    s    	Ef{|A	!Hr>   c                      t        j                  t        j                  t        j                              t        j                  k(  sJ y r7   )r8   rU   r9   r*   Halfrd   r>   r<   test_issue_18438r    s*    <<QVV,-777r>   c                  N    d} t        j                  |       t        d      k(  sJ y )Nsi   ^       sympy.core.powerPowsympy.core.numbersIntegerKR}bhHalf)R}bR}b.r?   )r8   rU   rl   )datas    r<   !test_unpickle_from_older_versionsr    s)    	8 	 <<a(((r>   )rS   rN   r8   sympy.physics.unitsr   sympy.testing.pytestr   r   sympy.core.basicr   r   sympy.core.singletonr   sympy.core.symbolr	   r
   r   r   sympy.core.numbersr   r   r   r   r   r   r   r   r   r   sympy.core.relationalr   r   r   r   r   r   r   sympy.core.addr   sympy.core.mulr   sympy.core.powerr    sympy.core.functionr!   r"   r#   r$   r%   sympy.sets.setsr&   sympy.core.multidimensionalr'   sympy.external.gmpyr(   sympy.utilities.exceptionsr)   r*   r+   sympy.externalr,   r-   rD   r]   r`   re   ri   rm   rp   rr   rv   ry   r{   r~   r   r   r   r   r   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   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   sympy.geometry.entityr   sympy.geometry.pointr   sympy.geometry.ellipser   r   sympy.geometry.liner   r   r   r   sympy.geometry.polygonr   r   r   r   sympy.integrals.integralsr   r   sympy.core.logicr   r   sympy.matricesr   r   r   sympy.ntheory.generater   r   sympy.physics.paulialgebrar   r   r   r(  r,  sympy.polys.domains.integerringr-  !sympy.polys.domains.rationalfieldr.  r\  r/  r3  r0  r4  r:  rA  rC  rH  rV  r]  rb  rx  r}  sympy.printing.latexr~  sympy.printing.mathmlr  r  sympy.printing.pretty.prettyr   sympy.printing.pretty.stringpictr  r  sympy.printing.printerr  sympy.printing.pythonr  r  r  r  r  sympy.series.limitsr  sympy.series.orderr  r  sympy.concrete.productsr  sympy.concrete.summationsr  r  r  r  r  rd   r>   r<   <module>r     s|      % . ( 2 6 6* * *7 7 7      $ 1 ( > " % (M* D -h#  

$ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 1 & 2 @ @ D D# / #
 0
 )
 - $  4  . / 0 % &	 3 3	"09#x0TB
 . Q 6 C * / " " ' '   & $ , )
8
)r>   