
    \hI              !      
   % S SK Jr  S SKrS SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKrS SKJr  \" S	5      r\(       Ga  \R"                  r\R&                  rS S
KJr  S SKJr  S SKJr  \" \SS5      r\c  \R8                  r0 \R:                  \R<                  _\R>                  \R@                  _\RB                  \RD                  _\RF                  \RH                  _\RJ                  \RL                  _\RN                  \RN                  _\RP                  \RP                  _\RR                  \RR                  _\RT                  \RT                  _\RV                  \RV                  _\RX                  \RZ                  _\R\                  \R\                  _\R^                  \R`                  _\Rb                  \Rb                  _\Rd                  \Rf                  _\Rh                  \Rj                  _\Rl                  \Rl                  _0 \Rn                  \Rp                  _\Rr                  \Rr                  _\Rt                  \Rv                  _\Rx                  \Rx                  _\Rz                  \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                  _E\R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  R                  R                  S \R                  \" \R<                  5      \R                  \" \R@                  5      \R                  \R                  \R                  \R                  \R                  \R                  \R                  \" SSS /5      0Ero " S S\5      rp0 rqS\rS'   SS jrsSS jrtSSSSS.S jjrug)    )annotationsN)Any)import_module)Printer)sympy_deprecation_warning)is_sequence)partialaesara)nlinalg)Elemwise)
DimShuffletrue_dividec                 .    [         R                  SS5      $ Nr      )aetcomplex     Q/var/www/auris/envauris/lib/python3.13/site-packages/sympy/printing/aesaracode.py<lambda>r   G   s    S[[15Er   )FFr   c                     ^  \ rS rSrSrSrU 4S jrSS jrSS jrS r	S r
S	 rS
 rS rS r\=rrS rS rS rS rS rS rS rS rS rS rS rS rSS jrSrU =r$ )AesaraPrinterR   a  
.. deprecated:: 1.14.
    The ``Aesara Code printing`` is deprecated.See its documentation for
    more information. See :ref:`deprecated-aesaraprinter` for details.

Code printer which creates Aesara symbolic expression graphs.

Parameters
==========

cache : dict
    Cache dictionary to use. If None (default) will use
    the global cache. To create a printer which does not depend on or alter
    global state pass an empty dictionary. Note: the dictionary is not
    copied on initialization of the printer and will be updated in-place,
    so using the same dict object when creating multiple printers or making
    multiple calls to :func:`.aesara_code` or :func:`.aesara_function` means
    the cache is shared between all these applications.

Attributes
==========

cache : dict
    A cache of Aesara variables which have been created for SymPy
    symbol-like objects (e.g. :class:`sympy.core.symbol.Symbol` or
    :class:`sympy.matrices.expressions.MatrixSymbol`). This is used to
    ensure that all references to a given symbol in an expression (or
    multiple expressions) are printed as the same Aesara variable, which is
    created only once. Symbols are differentiated only by name and type. The
    format of the cache's contents should be considered opaque to the user.
_aesarac                T   > UR                  S0 5      U l        [        TU ]  " U0 UD6  g )Ncache)popr   super__init__)selfargskwargs	__class__s      r   r    AesaraPrinter.__init__t   s'    ZZ,
$)&)r   c                R    Uc  UR                   nU[        U5      UR                  X44$ )zGet the cache key for a SymPy object.

Parameters
==========

s : sympy.core.basic.Basic
    SymPy object to get key for.

name : str
    Name of object, if it does not have a ``name`` attribute.
)nametyper"   )r!   sr'   dtypebroadcastables        r   _get_keyAesaraPrinter._get_keyx   s)     <66Dd1gqvvu<<r   c                    Uc  UR                   nUc  SnUc  SnU R                  XX4S9nXPR                  ;   a  U R                  U   $ [        R	                  X#US9nX`R                  U'   U$ )z_
Get the Aesara variable for a SymPy symbol from the cache, or create it
if it does not exist.
floatXr   r*   r+   )r'   r*   shape)r'   r,   r   r   tensor)r!   r)   r'   r*   r+   keyvalues          r   _get_or_createAesaraPrinter._get_or_create   ss     <66D=E MmmA5mN**::c?"


G

3r   c                    UR                  S0 5      R                  U5      nUR                  S0 5      R                  U5      nU R                  XUS9$ )Ndtypesbroadcastablesr0   getr5   )r!   r)   r#   r*   bcs        r   _print_SymbolAesaraPrinter._print_Symbol   sO    

8R(,,Q/ZZ("-11!4""1"DDr   c                   [        [        U5      5      S-   [        UR                  S   5      -   nUR                  S0 5      R                  U5      nUR                  S0 5      R                  U5      nU R	                  XXES9$ )N_r   r8   r9   )r'   r*   r+   )strr(   r"   r;   r5   )r!   r)   r#   r'   r*   r<   s         r   _print_AppliedUndef!AesaraPrinter._print_AppliedUndef   sr    47|c!Cq	N2

8R(,,Q/ZZ("-11!4""1u"OOr   c                    [         [        U5         nUR                   Vs/ s H  o@R                  " U40 UD6PM     nnU" U6 $ s  snf N)mappingr(   r"   _print)r!   exprr#   opargchildrens         r   _print_BasicAesaraPrinter._print_Basic   sD    T$Z :>))D)3KK.v.)D8} Es   Ac                4    [        UR                  5       5      $ rE   )floatevalf)r!   nr#   s      r   _print_NumberAesaraPrinter._print_Number   s    QWWYr   c                d    UR                  S0 5      R                  U5      nU R                  XSS9$ )Nr8   NNr0   r:   )r!   Xr#   r*   s       r   _print_MatrixSymbol!AesaraPrinter._print_MatrixSymbol   s3    

8R(,,Q/""1"NNr   c                   [        [        S5      (       d  [        S5      e[        R                  UR	                  5        VVs/ s H&  nU Vs/ s H  o@R
                  " U40 UD6PM     snPM(     snn5      $ s  snf s  snnf )N
stacklistsz>Matrix translation not yet supported in this version of Aesara)hasattrr   NotImplementedErrorrZ   tolistrG   )r!   rV   r#   LrJ   s        r   _print_DenseMatrix AesaraPrinter._print_DenseMatrix   sx    sL))%OQ Q ~~XXZ
 4551C[[''15
  	5
s   
A=
A8)A=
8A=
c                    UR                    Vs/ s H  o0R                  " U40 UD6PM     nnUS   nUSS   H  n[        R                  XV5      nM     U$ s  snf r   )r"   rG   r   dot)r!   rH   r#   rJ   rK   resultchilds          r   _print_MatMulAesaraPrinter._print_MatMul   sX    :>))D)3KK.v.)D!ab\EWWV+F "	 Es   Ac                   UR                    Vs/ s H  o0R                  " U40 UD6PM     nnSn[        US   [        5      (       a8  US   S:  a/  [	        US   5       H  n[
        R                  XTS   5      nM     U$ [        S5      es  snf )Nr   r   z^Only non-negative integer
           powers of matrices can be handled by Aesara at the moment)r"   rG   
isinstanceintranger   rb   r\   )r!   rH   r#   rJ   rK   rc   is          r   _print_MatPowAesaraPrinter._print_MatPow   s    :>))D)3KK.v.)Dhqk3''HQK!O8A;'!5 (
  & 'H I I Es   B
c                    U R                   " UR                  40 UD6nU R                   " [        UR                  6 40 UD6nU R                   " [        UR                  6 40 UD6nX4U4   $ rE   )rG   parentslicerowslicecolslice)r!   rH   r#   ro   rq   rr   s         r   _print_MatrixSlice AesaraPrinter._print_MatrixSlice   s_    T[[3F3;;udmm4??;;udmm4??())r   c                x   UR                   R                  u  p4[        U5       VVs/ s H>  n[        U5       Vs/ s H$  nU R                  " UR                   XV4   40 UD6PM&     snPM@     nnn[        R
                  " S/U Vs/ s H  n[        R
                  " S/UQ76 PM     snQ76 $ s  snf s  snnf s  snf r   )blocksr1   rj   rG   r   join)	r!   rH   r#   nrowsncolsrcrv   rows	            r   _print_BlockMatrix AesaraPrinter._print_BlockMatrix   s    {{(( "'u/!-A "'u/!-A ;;t{{140;F;!-/!- 	 / xxB&A&3SXXa.#.&ABB/ / Bs   B1+B,%B1!B7
,B1c           
         [        UR                  UR                  UR                  4 Vs/ s H7  n[	        U[
        R                  5      (       a  U R                  " U40 UD6OUPM9     sn6 $ s  snf rE   )rp   startstopsteprh   sympyBasicrG   )r!   rH   r#   rk   s       r   _print_sliceAesaraPrinter._print_slice   sp    "&**dii!CE!CA &a55 {{1//;<=!CE F 	F Es   >A-c                "    [         R                  $ rE   )mathpir!   rH   r#   s      r   	_print_PiAesaraPrinter._print_Pi   s    wwr   c                   SS K nUR                  S   R                  u  pEU R                  " U40 UD6nU R                  " U40 UD6n[        UR                  5      S:X  a   [        R                  XgUR                  5      $ U R                  " [        R                  " UR                  SS  6 40 UD6n[        R                  XgU5      $ r   )	numpyr"   rG   lenr   switchnanr   	Piecewise)	r!   rH   r#   npecondp_condp_ep_remainings	            r   _print_PiecewiseAesaraPrinter._print_Piecewise   s    ))A,## T,V,kk!&v& tyy>Q::f26622 kk%//499QR="ALVLzz&{33r   c                    [        U R                  " UR                  40 UD6U R                  " UR                  40 UD65      $ rE   )r   rG   pqr   s      r   _print_RationalAesaraPrinter._print_Rational   s8    4;;tvv88;;tvv88: 	:r   c                    UR                   $ rE   )r   r   s      r   _print_IntegerAesaraPrinter._print_Integer  s    vvr   c                p    U R                   " [        R                  " UR                  S   S-   5      40 UD6$ r   )rG   r   gammar"   r   s      r   _print_factorialAesaraPrinter._print_factorial  s,    {{5;;tyy|a'78CFCCr   c                    SSK Jn  U R                  " UR                  40 UD6nUR                   H2  nU R                  " U40 UD6nU" XE[
        R                  U5      5      nM4     U$ )Nr   )Rop)aesara.gradientr   rG   rH   	variablesr   	ones_like)r!   derivr#   r   rvvars         r   _print_DerivativeAesaraPrinter._print_Derivative  sY    '[[.v.??C++c,V,CRcmmC01B # 	r   c                    U$ rE   r   )r!   rH   s     r   emptyPrinterAesaraPrinter.emptyPrinter  s    r   c                6    Uc  0 nUc  0 nU R                  XUS9$ )aX  Convert a SymPy expression to a Aesara graph variable.

The ``dtypes`` and ``broadcastables`` arguments are used to specify the
data type, dimension, and broadcasting behavior of the Aesara variables
corresponding to the free symbols in ``expr``. Each is a mapping from
SymPy symbols to the value of the corresponding argument to
``aesara.tensor.var.TensorVariable``.

See the corresponding `documentation page`__ for more information on
broadcasting in Aesara.


.. __: https://aesara.readthedocs.io/en/latest/reference/tensor/shapes.html#broadcasting

Parameters
==========

expr : sympy.core.expr.Expr
    SymPy expression to print.

dtypes : dict
    Mapping from SymPy symbols to Aesara datatypes to use when creating
    new Aesara variables for those symbols. Corresponds to the ``dtype``
    argument to ``aesara.tensor.var.TensorVariable``. Defaults to ``'floatX'``
    for symbols not included in the mapping.

broadcastables : dict
    Mapping from SymPy symbols to the value of the ``broadcastable``
    argument to ``aesara.tensor.var.TensorVariable`` to use when creating Aesara
    variables for those symbols. Defaults to the empty tuple for symbols
    not included in the mapping (resulting in a scalar).

Returns
=======

aesara.graph.basic.Variable
    A variable corresponding to the expression's value in a Aesara
    symbolic expression graph.

)r8   r9   )rG   )r!   rH   r8   r9   s       r   doprintAesaraPrinter.doprint  s-    R >F!N{{4~{NNr   )r   NNNrU   ) __name__
__module____qualname____firstlineno____doc__printmethodr    r,   r5   r=   rB   rL   rR   rW   r_   _print_ImmutableMatrix_print_ImmutableDenseMatrixre   rl   rs   r}   r   r   r   r   r   r   r   r   r   __static_attributes____classcell__)r$   s   @r   r   r   R   s    > K*=$.E
P
 O <NM8	*CF
4":D.O .Or   r   zdict[Any, Any]global_cachec                    [        SSSS9  [        (       d  [        S5      eUc  [        n[	        U0 S9R
                  " U 40 UD6$ )a6  
Convert a SymPy expression into a Aesara graph variable.

Parameters
==========

expr : sympy.core.expr.Expr
    SymPy expression object to convert.

cache : dict
    Cached Aesara variables (see :class:`AesaraPrinter.cache
    <AesaraPrinter>`). Defaults to the module-level global cache.

dtypes : dict
    Passed to :meth:`.AesaraPrinter.doprint`.

broadcastables : dict
    Passed to :meth:`.AesaraPrinter.doprint`.

Returns
=======

aesara.graph.basic.Variable
    A variable corresponding to the expression's value in a Aesara symbolic
    expression graph.

z9
        The aesara_code function is deprecated.
        1.14deprecated-aesaraprinterdeprecated_since_versionactive_deprecations_targetz"aesara is required for aesara_code)r   settings)r   r
   ImportErrorr   r   r   )rH   r   r#   s      r   aesara_coder   H  sS    8 	 "(#= 6>??}ur2::4J6JJr   c           	         Ub  [         R                  U SU-  5      $ UbJ  [        UR                  5       5      nUR	                  5        VVs0 s H  u  pVUSU-  SXF-
  -  -   _M     snn$ Ub  U$ 0 $ s  snnf )a  
Get value of ``broadcastables`` argument to :func:`.aesara_code` from
keyword arguments to :func:`.aesara_function`.

Included for backwards compatibility.

Parameters
==========

inputs
    Sequence of input symbols.

dim : int
    Common number of dimensions for all inputs. Overrides other arguments
    if given.

dims : dict
    Mapping from input symbols to number of dimensions. Overrides
    ``broadcastables`` argument if given.

broadcastables : dict
    Explicit value of ``broadcastables`` argument to
    :meth:`.AesaraPrinter.doprint`. If not None function will return this value unchanged.

Returns
=======
dict
    Dictionary mapping elements of ``inputs`` to their "broadcastable"
    values (tuple of ``bool``\ s).
F)T)dictfromkeysmaxvaluesitems)inputsdimdimsr9   maxdimr)   ds          r   dim_handlingr   u  s    > }}VX^44T[[]# 


$ x!|g444$
 	

 !I
s   A1r   r   r9   c               :  ^^ [        SSSS9  [        (       d  [        S5      eUR                  S0 5      nUR                  S0 5      n[	        XXES9n[        [        XxUS	9n	[        [        X5      5      n
[        [        X5      5      nU Vs/ s HM  n[        U[        R                  R                  R                  5      (       a  UO[        R                  U5      PMO     nn[        U5      S
:X  a  US   n[        R                   " X40 UD6mTR"                   Vs/ s H%  n[        UR$                  R&                  5      S:H  PM'     snmU(       a  [)        T5      (       d	  TTl        T$ UU4S jnTUl        TR.                  Ul        TUl        U$ s  snf s  snf )ao
  
Create a Aesara function from SymPy expressions.

The inputs and outputs are converted to Aesara variables using
:func:`.aesara_code` and then passed to ``aesara.function``.

Parameters
==========

inputs
    Sequence of symbols which constitute the inputs of the function.

outputs
    Sequence of expressions which constitute the outputs(s) of the
    function. The free symbols of each expression must be a subset of
    ``inputs``.

scalar : bool
    Convert 0-dimensional arrays in output to scalars. This will return a
    Python wrapper function around the Aesara function object.

cache : dict
    Cached Aesara variables (see :class:`AesaraPrinter.cache
    <AesaraPrinter>`). Defaults to the module-level global cache.

dtypes : dict
    Passed to :meth:`.AesaraPrinter.doprint`.

broadcastables : dict
    Passed to :meth:`.AesaraPrinter.doprint`.

dims : dict
    Alternative to ``broadcastables`` argument. Mapping from elements of
    ``inputs`` to integers indicating the dimension of their associated
    arrays/tensors. Overrides ``broadcastables`` argument if given.

dim : int
    Another alternative to the ``broadcastables`` argument. Common number of
    dimensions to use for all arrays/tensors.
    ``aesara_function([x, y], [...], dim=2)`` is equivalent to using
    ``broadcastables={x: (False, False), y: (False, False)}``.

Returns
=======
callable
    A callable object which takes values of ``inputs`` as positional
    arguments and returns an output array for each of the expressions
    in ``outputs``. If ``outputs`` is a single expression the function will
    return a Numpy array, if it is a list of multiple expressions the
    function will return a list of arrays. See description of the ``squeeze``
    argument above for the behavior when a single output is passed in a list.
    The returned object will either be an instance of
    ``aesara.compile.function.types.Function`` or a Python wrapper
    function around one. In both cases, the returned value will have a
    ``aesara_function`` attribute which points to the return value of
    ``aesara.function``.

Examples
========

>>> from sympy.abc import x, y, z
>>> from sympy.printing.aesaracode import aesara_function

A simple function with one input and one output:

>>> f1 = aesara_function([x], [x**2 - 1], scalar=True)
>>> f1(3)
8.0

A function with multiple inputs and one output:

>>> f2 = aesara_function([x, y, z], [(x**z + y**z)**(1/z)], scalar=True)
>>> f2(3, 4, 2)
5.0

A function with multiple inputs and multiple outputs:

>>> f3 = aesara_function([x, y], [x**2 + y**2, x**2 - y**2], scalar=True)
>>> f3(2, 3)
[13.0, -5.0]

See also
========

dim_handling

z=
        The aesara_function function is deprecated.
        r   r   r   z&Aesara is required for aesara_functionr   r8   r   )r   r8   r9   r   r   c                    > T" U 6 n[        U5      (       a/  [        U5       VVs/ s H  u  p#TU   (       a  US   OUPM     snn$ US   $ s  snnf )Nr   )r   	enumerate)r"   outrk   ofuncis_0ds       r   wrapper aesara_function.<locals>.wrapper'  sR    Dk s9B3HU1XAbE1,HHr7N Is   A)r   r
   r   r   r   r	   r   listmaprh   graphbasicVariabler   as_tensor_variabler   functionoutputsvariabler+   anyaesara_function__wrapped__r   )r   r   scalarr   r   r9   r#   r   r8   codetinputstoutputsoutputr   r   r   r   s                  @@r   r   r     s   r 	 "(#= 6BCC JJw#EZZ"%F!dN
 ;e"02D3t$%GC&'H }E  F  }Erx*VV\\-?-?-H-HIIsOeOeflOmm  }EH  F
8}A; ??777D9=FAS))*a/FE U# GllGO"GN9 F Gs   AF,FrE   r   r   )v
__future__r   r   typingr   sympy.externalr   sympy.printing.printerr   sympy.utilities.exceptionsr   sympy.utilities.iterablesr   r   	functoolsr	   r
   r   aesr2   r   aesara.tensorr   aesara.tensor.elemwiser   r   getattrr   true_divAddaddMulmulAbsabssignsgnceilingceilfloorlogexpsqrtcosacosarccossinasinarcsintanatanarctanatan2arctan2coshacosharccoshsinhasinharcsinhtanhatanharctanhrerealimimagrJ   angleerfr   loggammagammalnPowpowEqeqStrictGreaterThangtStrictLessThanltLessThanleGreaterThangeAndbitwise_andOr
bitwise_orNotinvertXorbitwise_xorMaxmaximumMinminimum	conjugateconjcorenumbersImaginaryUnitMatAddHadamardProductTracetraceDeterminantdetInversematrix_inverse	TransposerF   r   r   __annotations__r   r   r   r   r   r   <module>rQ     s=   "   ( * @ 1   
x	 	
--C
--C%/1
 #}d3Kll2IIsww2IIsww2 IIsww2 JJ	2
 MM3882 KK2 IIsww2 IIsww2 JJ2 IIsww2 JJ

2 IIsww2 JJ

2 IIsww2 JJ

2  KK!2" JJ#2$ KK%2& JJ'2( KK)2* JJ+2, KK-2. HHchh/20 HHchh122 IIsyy324 IIsww526 KK728 NNCKK92: IIsww;2< HHcff=2> ##SVV?2@   #&&A2B NNCFFC2D svvE2F IIsHHcnnIIszzIIsIIs{{IIs{{OOSXXJJ,,.ELL(377+!!8CGG#4KKMM711OOZA?c2GjpOG pOf  "n !*KZ,^OtDOr   