
    \h,                    
   S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
Jr  SSKJrJr  SS	KJrJrJrJr  SS
KJr  SSKJr  SSKJr   " S S\5      rS \\'   S r " S S\5      rS \\'    " S S\5      r " S S\5      rg)zModule for SymPy containers

(SymPy objects that store other SymPy objects)

The containers implemented in this module are subclassed to Basic.
They are supposed to work seamlessly within the SymPy framework.
    )annotations)OrderedDict)
MutableSet)AnyCallable   )Basic)default_sort_keyordered)_sympifysympify_sympy_converterSympifyError)Kind)iterable)as_intc                     ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 r\rU 4S jrU 4S jrS rS rS rS rSS jrSS jr\S 5       rSrU =r$ )Tuple   ax  
Wrapper around the builtin tuple object.

Explanation
===========

The Tuple is a subclass of Basic, so that it works well in the
SymPy framework.  The wrapped tuple is available as self.args, but
you can also access elements or slices with [:] syntax.

Parameters
==========

sympify : bool
    If ``False``, ``sympify`` is not called on ``args``. This
    can be used for speedups for very large tuples where the
    elements are known to already be SymPy objects.

Examples
========

>>> from sympy import Tuple, symbols
>>> a, b, c, d = symbols('a b c d')
>>> Tuple(a, b, c)[1:]
(b, c)
>>> Tuple(a, b, c).subs(a, d)
(d, b, c)

c                t    UR                  SS5      (       a	  S U 5       n[        R                  " U /UQ76 nU$ )Nr   Tc              3  8   #    U  H  n[        U5      v   M     g 7fN)r   .0args     M/var/www/auris/envauris/lib/python3.13/site-packages/sympy/core/containers.py	<genexpr> Tuple.__new__.<locals>.<genexpr>8   s     1DSGCLLD   )getr	   __new__)clsargskwargsobjs       r   r!   Tuple.__new__6   s5    ::i&&1D1DmmC'$'
    c                   ^  [        U[        5      (       a2  UR                  [        T 5      5      n[	        U 4S j[        U6  5       6 $ T R                  U   $ )Nc              3  B   >#    U  H  nTR                   U   v   M     g 7fr   r#   )r   jselfs     r   r   $Tuple.__getitem__.<locals>.<genexpr>?   s     AA499Q<s   )
isinstancesliceindiceslenr   ranger#   )r,   ir0   s   `  r   __getitem__Tuple.__getitem__<   sE    aiiD	*GAABByy|r'   c                ,    [        U R                  5      $ r   )r1   r#   r,   s    r   __len__Tuple.__len__B   s    499~r'   c                    XR                   ;   $ r   r*   )r,   items     r   __contains__Tuple.__contains__E   s    yy  r'   c                ,    [        U R                  5      $ r   )iterr#   r7   s    r   __iter__Tuple.__iter__H       DIIr'   c                    [        U[        5      (       a  [        U R                  UR                  -   6 $ [        U[        5      (       a  [        U R                  U-   6 $ [        $ r   r.   r   r#   tupleNotImplementedr,   others     r   __add__Tuple.__add__K   sN    eU##499uzz133u%%499u,..!!r'   c                    [        U[        5      (       a  [        UR                  U R                  -   6 $ [        U[        5      (       a  [        XR                  -   6 $ [        $ r   rD   rG   s     r   __radd__Tuple.__radd__S   sL    eU##5::		133u%%599,..!!r'   c                     [        U5      nU R                  " U R
                  U-  6 $ ! [         a    [        S[        U5      -  5      ef = f)Nz3Can't multiply sequence by non-integer of type '%s')r   
ValueError	TypeErrortypefuncr#   )r,   rH   ns      r   __mul__Tuple.__mul__[   sU    	auA yy499Q;((  	aQTXY^T__``	as	   ) "Ac                j   > [        U[        5      (       a  [        TU ]  U5      $ U R                  U:H  $ r   )r.   r	   super__eq__r#   r,   rH   	__class__s     r   rX   Tuple.__eq__d   .    eU##7>%((yyE!!r'   c                j   > [        U[        5      (       a  [        TU ]  U5      $ U R                  U:g  $ r   )r.   r	   rW   __ne__r#   rY   s     r   r^   Tuple.__ne__i   r\   r'   c                ,    [        U R                  5      $ r   )hashr#   r7   s    r   __hash__Tuple.__hash__n   rB   r'   c                B   ^ [        U4S jU R                   5       5      $ )Nc              3  D   >#    U  H  oR                  T5      v   M     g 7fr   )
_to_mpmath)r   aprecs     r   r   #Tuple._to_mpmath.<locals>.<genexpr>r   s     ;A\\$''s    )rE   r#   )r,   rh   s    `r   rf   Tuple._to_mpmathq   s    ;;;;r'   c                F    [        U R                  UR                  :  5      $ r   r   r#   rG   s     r   __lt__Tuple.__lt__t       		EJJ.//r'   c                F    [        U R                  UR                  :*  5      $ r   rl   rG   s     r   __le__Tuple.__le__w   s    		UZZ/00r'   c                8    U R                   R                  U5      $ )z&Return number of occurrences of value.)r#   count)r,   values     r   tuple_countTuple.tuple_count|   s    yyu%%r'   c                    Uc  Uc  U R                   R                  U5      $ Uc  U R                   R                  X5      $ U R                   R                  XU5      $ )z2Searches and returns the first index of the value.)r#   index)r,   ru   startstops       r   ry   Tuple.index   sM     =T\99??5))\99??50099??566r'   c                4    [        S U R                   5       6 $ )a  
The kind of a Tuple instance.

The kind of a Tuple is always of :class:`TupleKind` but
parametrised by the number of elements and the kind of each element.

Examples
========

>>> from sympy import Tuple, Matrix
>>> Tuple(1, 2).kind
TupleKind(NumberKind, NumberKind)
>>> Tuple(Matrix([1, 2]), 1).kind
TupleKind(MatrixKind(NumberKind), NumberKind)
>>> Tuple(1, 2).kind.element_kind
(NumberKind, NumberKind)

See Also
========

sympy.matrices.kind.MatrixKind
sympy.core.kind.NumberKind
c              3  8   #    U  H  oR                   v   M     g 7fr   )kind)r   r3   s     r   r   Tuple.kind.<locals>.<genexpr>   s     59a669r   )	TupleKindr#   r7   s    r   r   
Tuple.kind   s    2 5499566r'    )returnint)NN)__name__
__module____qualname____firstlineno____doc__r!   r4   r8   r<   r@   rI   rL   rT   __rmul__rX   r^   rb   rf   rm   rq   rv   ry   propertyr   __static_attributes____classcell__rZ   s   @r   r   r      ss    <!"") H"
"
<01
&7, 7 7r'   r   c                    [        U 6 $ r   )r   )tups    r   <lambda>r      s    eSkr'   c                   ^  U 4S jnU$ )a   
Decorator that converts any tuple in the function arguments into a Tuple.

Explanation
===========

The motivation for this is to provide simple user interfaces.  The user can
call a function with regular tuples in the argument, and the wrapper will
convert them to Tuples before handing them to the function.

Explanation
===========

>>> from sympy.core.containers import tuple_wrapper
>>> def f(*args):
...    return args
>>> g = tuple_wrapper(f)

The decorated function g sees only the Tuple argument:

>>> g(0, (1, 2), 3)
(0, (1, 2), 3)

c                    > / nU  HB  n[        U[        5      (       a  UR                  [        U6 5        M1  UR                  U5        MD     T" U0 UD6$ r   )r.   rE   appendr   )r#   kw_argsnewargsr   methods       r   wrap_tuples"tuple_wrapper.<locals>.wrap_tuples   sM    C#u%%uc{+s#	 
 w*'**r'   r   )r   r   s   ` r   tuple_wrapperr      s    2+ r'   c                     ^  \ rS rSr% SrS\S'   S\S'   S rS rS	 rS
 r	S r
S rS rS rSS jrS rS r\S 5       rU 4S jr\R*                  rS\S'   SrU =r$ )Dict   a  
Wrapper around the builtin dict object.

Explanation
===========

The Dict is a subclass of Basic, so that it works well in the
SymPy framework.  Because it is immutable, it may be included
in sets, but its values must all be given at instantiation and
cannot be changed afterwards.  Otherwise it behaves identically
to the Python dict.

Examples
========

>>> from sympy import Dict, Symbol

>>> D = Dict({1: 'one', 2: 'two'})
>>> for key in D:
...    if key == 1:
...        print('%s %s' % (key, D[key]))
1 one

The args are sympified so the 1 and 2 are Integers and the values
are Symbols. Queries automatically sympify args so the following work:

>>> 1 in D
True
>>> D.has(Symbol('one')) # searches keys and values
True
>>> 'one' in D # not in the keys
False
>>> D[1]
one

zfrozenset[Tuple]elementszdict[Basic, Basic]_dictc                    [        U5      S:X  aO  [        US   [        [        45      (       a1  US   R	                  5        VVs/ s H  u  p#[        X#5      PM     nnnOR[        U5      (       a7  [        S U 5       5      (       a   U VVs/ s H  u  p#[        X#5      PM     nnnO[        S5      e[        U5      n[        R                  " U /[        U5      Q76 nXVl        [        U5      Ul        U$ s  snnf s  snnf )Nr   r   c              3  >   #    U  H  n[        U5      S :H  v   M     g7f)   N)r1   r   s     r   r   Dict.__new__.<locals>.<genexpr>  s     #BTcCHMTs   z<Pass Dict args as Dict((k1, v1), ...) or Dict({k1: v1, ...}))r1   r.   dictr   itemsr   r   allrP   	frozensetr	   r!   r   r   r   )r"   r#   kvr   r   r%   s          r   r!   Dict.__new__  s    t9>ja4,??-1!W]]_=_TQU1[_E=Ed^^#BT#B B B-12TTQU1[TE2EZ[[U#mmC1'%.1K	
 >2s   C4C:c                j     [        U5      nU R                  U   $ ! [         a    [        U5      ef = f)zx.__getitem__(y) <==> x[y])r   r   KeyErrorr   r,   keys     r   r4   Dict.__getitem__  s;    	 3-C zz#  	 3-	 s    2c                    [        S5      e)NzSymPy Dicts are Immutable)NotImplementedError)r,   r   ru   s      r   __setitem__Dict.__setitem__  s    !"=>>r'   c                6    U R                   R                  5       $ )zDReturns a set-like object providing a view on dict's items.
        )r   r   r7   s    r   r   
Dict.items  s     zz!!r'   c                6    U R                   R                  5       $ )z$Returns the list of the dict's keys.)r   keysr7   s    r   r   	Dict.keys"  s    zz  r'   c                6    U R                   R                  5       $ )z&Returns the list of the dict's values.)r   valuesr7   s    r   r   Dict.values&  s    zz  ""r'   c                ,    [        U R                  5      $ )zx.__iter__() <==> iter(x))r?   r   r7   s    r   r@   Dict.__iter__*  s    DJJr'   c                6    U R                   R                  5       $ )zx.__len__() <==> len(x))r   r8   r7   s    r   r8   Dict.__len__.  s    zz!!##r'   c                t     [        U5      nU R                  R                  X5      $ ! [         a    Us $ f = f)z:Returns the value for key if the key is in the dictionary.)r   r   r   r    )r,   r   defaults      r   r    Dict.get2  s;    	3-C zz~~c++  	N	s   ( 77c                V     [        U5      nXR                  ;   $ ! [         a     gf = f)z6D.__contains__(k) -> True if D has a key k, else FalseF)r   r   r   r   s     r   r<   Dict.__contains__:  s3    	3-C jj    		s    
((c                F    [        U R                  UR                  :  5      $ r   rl   rG   s     r   rm   Dict.__lt__B  ro   r'   c                D    [        [        U R                  [        S95      $ )N)r   )rE   sortedr#   r
   r7   s    r   _sorted_argsDict._sorted_argsE  s    VDII+;<==r'   c                h   > [        U[        5      (       a  U [        U5      :H  $ [        TU ]  U5      $ r   )r.   r   r   rW   rX   rY   s     r   rX   Dict.__eq__I  s.    eT""4;&&w~e$$r'   zCallable[[Basic], Any]rb   r   r   )r   r   r   r   r   __annotations__r!   r4   r   r   r   r   r@   r8   r    r<   rm   r   r   rX   r	   rb   r   r   r   s   @r   r   r      s{    #J ?"
!# $,!0 > >%
 ).H%66r'   r   c                .    [        U R                  5       6 $ r   )r   r   )ds    r   r   r   Q  s    4#3r'   c                  ^    \ rS rSrSS jrS rS rS rS rSS jr	S	 r
S
 rS rS rS rSrg)
OrderedSetiS  Nc                `    U(       a  [        S U 5       5      U l        g [        5       U l        g )Nc              3  (   #    U  H  oS 4v   M
     g 7fr   r   )r   r;   s     r   r   &OrderedSet.__init__.<locals>.<genexpr>V  s     "EHD$<Hs   )r   map)r,   r   s     r   __init__OrderedSet.__init__T  s     ""EH"EEDH"}DHr'   c                ,    [        U R                  5      $ r   )r1   r   r7   s    r   r8   OrderedSet.__len__Z  s    488}r'   c                    XR                   ;   $ r   r   r   s     r   r<   OrderedSet.__contains__]  s    hhr'   c                "    S U R                   U'   g r   r   r   s     r   addOrderedSet.add`  s    r'   c                :    U R                   R                  U5        g r   )r   popr   s     r   discardOrderedSet.discardc  s    Sr'   c                :    U R                   R                  US9S   $ )N)lastr   )r   popitem)r,   r   s     r   r   OrderedSet.popf  s    xxT*1--r'   c              #  T   #    U R                   R                  5        S h  vN   g  N7fr   )r   r   r7   s    r   r@   OrderedSet.__iter__i  s     88==?""s   (&(c                    U R                   (       d  U R                  R                  < S3$ U R                  R                  < S[        U R                   R	                  5       5      < S3$ )Nz()())r   rZ   r   listr   r7   s    r   __repr__OrderedSet.__repr__l  s@    xx!^^4466>>22D4IJJr'   c                ^    U R                  U  Vs/ s H  o"U;   d  M
  UPM     sn5      $ s  snf r   r   r,   rH   vals      r   intersectionOrderedSet.intersectionq  s'    ~~dCdsUlsdCDDC   	**c                ^    U R                  U  Vs/ s H  o"U;  d  M
  UPM     sn5      $ s  snf r   r   r   s      r   
differenceOrderedSet.differencet  s(    ~~dGds6FsdGHHGr   c                8    U H  nU R                  U5        M     g r   )r   )r,   r   r   s      r   updateOrderedSet.updatew  s    CHHSM r'   r   r   )T)r   r   r   r   r   r8   r<   r   r   r   r@   r   r   r   r   r   r   r'   r   r   r   S  s<    %.#K
EIr'   r   c                  2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )r   i{  a  
TupleKind is a subclass of Kind, which is used to define Kind of ``Tuple``.

Parameters of TupleKind will be kinds of all the arguments in Tuples, for
example

Parameters
==========

args : tuple(element_kind)
   element_kind is kind of element.
   args is tuple of kinds of element

Examples
========

>>> from sympy import Tuple
>>> Tuple(1, 2).kind
TupleKind(NumberKind, NumberKind)
>>> Tuple(1, 2).kind.element_kind
(NumberKind, NumberKind)

See Also
========

sympy.core.kind.NumberKind
MatrixKind
sympy.sets.sets.SetKind
c                6   > [         TU ]  " U /UQ76 nXl        U$ r   )rW   r!   element_kind)r"   r#   r%   rZ   s      r   r!   TupleKind.__new__  s!    goc)D)
r'   c                8    SR                  U R                  5      $ )NzTupleKind{})formatr   r7   s    r   r   TupleKind.__repr__  s    ##D$5$566r'   r   )	r   r   r   r   r   r!   r   r   r   r   s   @r   r   r   {  s    :
7 7r'   r   N) r   
__future__r   collectionsr   collections.abcr   typingr   r   basicr	   sortingr
   r   r   r   r   r   sympy.core.kindr   sympy.utilities.iterablesr   sympy.utilities.miscr   r   rE   r   r   r   r   r   r   r'   r   <module>r     s    # # &    . F F   . 'X7E X7t 2  !Hs75 s7l 4  & &P$7 $7r'   