+
    i/                       a  0 t $ ^ RIHt ^ RIHt ^ RIt^RIHtHtH	t	H
t
 ^RIHt ^ RIt ! R R]4      tR t ! R	 R
4      tR t]! 4       tR]R&   R.tR t]3R lt ! R R4      tR t ! R R]4      tR tR tR# )    )annotations)warnN)orderingambiguitiessuper_signatureAmbiguityWarning)expand_tuplesc                      ] tR t^
tRtRtR# )MDNotImplementedErrorz,A NotImplementedError for multiple dispatch  N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       _/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/multipledispatch/dispatcher.pyr   r   
   s    7r   r   c                N    \        \        V P                  V4      \        4       R# )a  Raise warning when ambiguity is detected

Parameters
----------
dispatcher : Dispatcher
    The dispatcher on which the ambiguity was detected
ambiguities : set
    Set of type signature pairs that are ambiguous within this dispatcher

See Also:
    Dispatcher.add
    warning_text
N)r   warning_textnamer   )
dispatcherr   s   &&r   ambiguity_warnr      s     	joo{	35EFr   c                  &    ] tR t^!tRtR tR tRtR# )RaiseNotImplementedErrorz*Raise ``NotImplementedError`` when called.c                	    Wn         R # Nr   )selfr   s   &&r   __init__!RaiseNotImplementedError.__init__$   s    $r   c                	    \         ;QJ d    . R  V 4       F  NK  	  5M! R  V 4       4      p\        RV P                  P                  : R\	        V4      : R24      h)c              3  8   "   T F  p\        V4      x  K  	  R # 5ir   )type).0as   & r   	<genexpr>4RaiseNotImplementedError.__call__.<locals>.<genexpr>(   s     ,t!d1ggt   zAmbiguous signature for : <>)tupleNotImplementedErrorr   r   str_signature)r   argskwargstypess   &*, r   __call__!RaiseNotImplementedError.__call__'   sF    ,t,,t,,!OO  -"6
 	r   r   N)r   r   r   r   r   r    r2   r   r   r   r   r   r   !   s    4%r   r   c                    V FS  p\        \        V4      4      p\        \        V4      4      ^8X  d   K2  V P	                  V\        V 4      \        R7       KU  	  R# )a  
If super signature for ambiguous types is duplicate types, ignore it.
Else, register instance of ``RaiseNotImplementedError`` for ambiguous types.

Parameters
----------
dispatcher : Dispatcher
    The dispatcher on which the ambiguity was detected
ambiguities : set
    Set of type signature pairs that are ambiguous within this dispatcher

See Also:
    Dispatcher.add
    ambiguity_warn
on_ambiguityN)r,   r   lensetaddr   #ambiguity_register_error_ignore_dup)r   r   amb	signatures   &&  r   r:   r:   .   sP      /#./	s9~!#/
;< 	 	
	 r   zset[Dispatcher]_unresolved_dispatchersTc                     R \         ^ &   R# )FN)_resolver   r   r   halt_orderingr@   N   s    HQKr   c                    R \         ^ &   \        '       d)   \        P                  4       pVP                  V R7       K4  R# )Tr5   N)r?   r=   popreorder)r6   r   s   & r   restart_orderingrD   R   s5    HQK
!
!,002
5 "r   c                      ] tR t^YtRtRtRR ltR t]R 4       t	]R 4       t
]3R lt]3R ltR	 tR
 t]tR tR tR tR tR t]R 4       tR tR tR tR tRtR# )
Dispatchera-  Dispatch methods based on type signature

Use ``dispatch`` to add implementations

Examples
--------

>>> from sympy.multipledispatch import dispatch
>>> @dispatch(int)
... def f(x):
...     return x + 1

>>> @dispatch(float)
... def f(x): # noqa: F811
...     return x - 1

>>> f(3)
4
>>> f(3.0)
2.0
Nc                	X    V;V n         V n        / V n        / V n        . V n        W n        R # r   )r   r   funcs_cacher   doc)r   r   rJ   s   &&&r   r    Dispatcher.__init__q   s*    $((	DM
r   c                   a aa VV V3R lpV# )a  Register dispatcher with new implementation

>>> from sympy.multipledispatch.dispatcher import Dispatcher
>>> f = Dispatcher('f')
>>> @f.register(int)
... def inc(x):
...     return x + 1

>>> @f.register(float)
... def dec(x):
...     return x - 1

>>> @f.register(list)
... @f.register(tuple)
... def reverse(x):
...     return x[::-1]

>>> f(1)
2

>>> f(1.0)
0.0

>>> f([1, 2, 3])
[3, 2, 1]
c                0   < SP                   ! SV 3/ SB  V # r   )r9   )funcr0   r   r1   s   &r   _Dispatcher.register.<locals>._   s    HHUD+F+Kr   r   )r   r1   r0   rO   s   fjl r   registerDispatcher.registerx   s    6	 r   c                	    \        \        R 4      '       d1   \        P                  ! V4      pVP                  P	                  4       # R# r<   N)hasattrinspectr<   
parametersvaluesclsrN   sigs   && r   get_func_paramsDispatcher.get_func_params   s7    7K((##D)C>>((** )r   c                R  a V P                  V4      pV'       d   \        P                  oV3R lV 4       p\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p\        ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       g   V# R# R# )z:Get annotations of function positional parameters
        c              3  z   <"   T F0  pVP                   SP                  SP                  39   g   K,  Vx  K2  	  R # 5ir   )kindPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORD)r%   param	Parameters   & r   r'   2Dispatcher.get_func_annotations.<locals>.<genexpr>   s;      9 00 6688 es   );
;c              3  :   "   T F  pVP                   x  K  	  R # 5ir   )
annotation)r%   rc   s   & r   r'   re      s       %#E   #s   c              3  >   <"   T F  qSP                   J x  K  	  R # 5ir   )empty)r%   annrd   s   & r   r'   re      s     E#ioo-s   TFN)r\   rV   rd   r,   any)rZ   rN   paramsr   rd   s   &&  @r   get_func_annotationsDispatcher.get_func_annotations   s     $$T*))I9 9F
  %  %# %%%  %# % %K 3EE333EEEE"" F r   c           	     0   V'       g   V P                  V4      pV'       d   Tp\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d'   \        V4       F  pV P                  WRV4       K  	  R# V FR  p\	        V\
        4      '       d   K  RP                  R V 4       4      p\        RV: RV: R	V P                  : 24      h	  W P                  V&   V P                  VR
7       V P                  P                  4        R# )a  Add new types/method pair to dispatcher

>>> from sympy.multipledispatch import Dispatcher
>>> D = Dispatcher('add')
>>> D.add((int, int), lambda x, y: x + y)
>>> D.add((float, float), lambda x, y: x + y)

>>> D(1, 2)
3
>>> D(1, 2.0)
Traceback (most recent call last):
...
NotImplementedError: Could not find signature for add: <int, float>

When ``add`` detects a warning it calls the ``on_ambiguity`` callback
with a dispatcher/itself, and a set of ambiguous type signature pairs
as inputs.  See ``ambiguity_warn`` for an example.
c              3  B   "   T F  p\        V\        4      x  K  	  R # 5ir   )
isinstancer,   )r%   typs   & r   r'   !Dispatcher.add.<locals>.<genexpr>   s     ;#z#u%%s   TFN, c              3  |   "   T F2  p\        V\        4      '       d   VP                  M
\        V4      x  K4  	  R # 5ir   )rq   r$   r   str)r%   cs   & r   r'   rs      s4      $D9BA 3=Q2E2EAJJ),Q%09Bs   :<zTried to dispatch on non-type: z
In signature: <z>
In function: r5   )rm   rk   r	   r9   rq   r$   join	TypeErrorr   rH   rC   rI   clear)r   r<   rN   r6   r   typsrr   str_sigs   &&&&    r   r9   Dispatcher.add   s    ( 33D9K'	 3;;333;;;;%i0\2 1Cc4(()) $D9B$D D "%gtyy!: ; ;	  !%

9,/r   c                	    \         ^ ,          '       dD   \        V P                  4      V n        \        V P                  4      pV'       d   V! W4       R# R# \        P                  V 4       R# )r   N)r?   r   rH   r   r=   r9   )r   r6   r;   s   && r   rC   Dispatcher.reorder   sI    A;;$TZZ0DMdjj)CT'  $''-r   c           	     	8   \        V Uu. uF  p\        V4      NK  	  up4      p V P                  V,          p V! V/ VB # u upi   \         dQ    T P                  ! T!  pT'       g(   \        R T P                  : R\        T4      : R24      hYPP                  T&    Lhi ; i  \         dj    T P                  ! T!  p\        T4       T F   p T! T/ TB u u #   \         d     K  i ; i	  \        RT P                  : R\        T4      : R24      hi ; i)Could not find signature for r*   r+   zMatching functions for z(> found, but none completed successfully)r,   r$   rI   KeyErrordispatchr-   r   r.   r   dispatch_iternext)r   r/   r0   argr1   rN   rH   s   &*,    r   r2   Dispatcher.__call__   s   D1DStCyD12	&;;u%D	K((( 2  	&==%(D)YYe 467 7 "&KK	& % 
	K&&.EK000,  
 &)-M%4H'J K K
	KsK   AA B% "B"*5B"!B"%+DCDC,(D+C,,-Dc                	(    R V P                   ,          # )z<dispatched %s>)r   r   s   &r   __str__Dispatcher.__str__  s     499,,r   c                    WP                   9   d   V P                   V,          #  \        V P                  ! V!  4      #   \         d     R# i ; i)a  Deterimine appropriate implementation for this type signature

This method is internal.  Users should call this object as a function.
Implementation resolution occurs within the ``__call__`` method.

>>> from sympy.multipledispatch import dispatch
>>> @dispatch(int)
... def inc(x):
...     return x + 1

>>> implementation = inc.dispatch(int)
>>> implementation(3)
4

>>> print(inc.dispatch(float))
None

See Also:
    ``sympy.multipledispatch.conflict`` - module to determine resolution order
N)rH   r   r   StopIterationr   r1   s   &*r   r   Dispatcher.dispatch  sJ    , JJ::e$$	**E233 		s   > AAc              '  	   "   \        V4      pV P                   FM  p\        V4      V8X  g   K  \        \        \        W4      4      '       g   K6  V P
                  V,          pVx  KO  	  R # 5ir   )r7   r   allmap
issubclassrH   )r   r1   nr<   results   &*   r   r   Dispatcher.dispatch_iter#  sL     JI9~"s3z5+L'M'MI. 's   (A-A-A-c                B    \        R\        4       V P                  ! V!  # )zzDeterimine appropriate implementation for this type signature

.. deprecated:: 0.4.4
    Use ``dispatch(*types)`` instead
z-resolve() is deprecated, use dispatch(*types))r   DeprecationWarningr   r   s   &&r   resolveDispatcher.resolve*  s#     	<	! }}e$$r   c                	6    R V P                   RV P                  /# r   rH   r   r   s   &r   __getstate__Dispatcher.__getstate__5  s    		% 	%r   c                	    VR ,          V n         VR,          V n        \        V P                  4      V n        / V n        R# )r   rH   N)r   rH   r   rI   )r   ds   &&r   __setstate__Dispatcher.__setstate__9  s/    fI	wZ
 ,r   c                	   R V P                   ,          .pV P                  '       d   VP                  V P                  4       . pV P                  RRR1,           F  pV P                  V,          pVP
                  '       df   R\        V4      ,          pVR\        V4      ,          R,           ,          pWTP
                  P                  4       ,          pVP                  V4       K  VP                  \        V4      4       K  	  V'       d(   VP                  RRP                  V4      ,           4       RP                  V4      # )	zMultiply dispatched method: %sNzInputs: <%s>
-
zOther signatures:
    z
    

)
r   rJ   appendr   rH   r   r.   r7   striprx   )r   docsotherr[   rN   ss   &     r   r   Dispatcher.__doc__?  s    0499<=888KK!==2&&C::c?D|||$}S'99S3q6\D((\\''))A]3/0 ' KK1HMM%4HHI{{4  r   c                	R    V P                   ! \        \        V4      !  P                  # r   )r   r   r$   r   )r   r/   s   &*r   _helpDispatcher._helpV  s    }}c$o.666r   c                8    \        V P                  ! V!  4       R# )z9Print docstring for the function corresponding to inputs N)printr   r   r/   r0   s   &*,r   helpDispatcher.helpY  s    djj$ r   c                	z    V P                   ! \        \        V4      !  pV'       g   \        R 4      h\	        V4      # )zNo function found)r   r   r$   ry   source)r   r/   rN   s   &* r   _sourceDispatcher._source]  s/    }}c$o./00d|r   c                8    \        V P                  ! V!  4       R# )z;Print source code for the function corresponding to inputs N)r   r   r   s   &*,r   r   Dispatcher.sourcec  s    dllD!"r   )r   rI   rJ   rH   r   r   )r   r   rH   r   rI   rJ   r   )r   r   r   r   r   	__slots__r    rQ   classmethodr\   rm   r   r9   rC   r2   r   __repr__r   r   r   r   r   propertyr   r   r   r   r   r   r   r   rF   rF   Y   s    * II@ + +
 # #& 1? *X $2 .K4-H<	%% ! !,7!#r   rF   c                z    R \         P                  ! V 4      ,          pV\         P                  ! V 4      ,           pV# )z
File: %s

)rV   getsourcefile	getsource)rN   r   s   & r   r   r   h  s1    ..t44A	Gd##AHr   c                  6    ] tR tRtRt]R 4       tR tR tRt	R# )MethodDispatcherin  zCDispatch methods based on type signature

See Also:
    Dispatcher
c                	    \        \        R 4      '       dG   \        P                  ! V4      p\        P                  ! VP
                  P                  4       ^R4      # R# rT   )rU   rV   r<   itlislicerW   rX   rY   s   && r   r\    MethodDispatcher.get_func_paramsu  sD    7K((##D)C::cnn335q$?? )r   c                	    Wn         W n        V # r   )objrZ   )r   instanceowners   &&&r   __get__MethodDispatcher.__get__{  s    r   c                	    \        V Uu. uF  p\        V4      NK  	  up4      pV P                  ! V!  pV'       g(   \        R V P                  : R\        V4      : R24      hV! V P                  .VO5/ VB # u upi )r   r*   r+   )r,   r$   r   r-   r   r.   r   )r   r/   r0   r   r1   rN   s   &*,   r   r2   MethodDispatcher.__call__  sq    D1DStCyD12}}e$%'+yy-2F'H I IDHH.t.v.. 2s   A:)rZ   r   N)
r   r   r   r   r   r   r\   r   r2   r   r   r   r   r   r   n  s'     @ @

/r   r   c                2    RP                  R V  4       4      # )zString representation of type signature

>>> from sympy.multipledispatch.dispatcher import str_signature
>>> str_signature((int, float))
'int, float'
rt   c              3  8   "   T F  qP                   x  K  	  R # 5ir   )r   )r%   rZ   s   & r   r'    str_signature.<locals>.<genexpr>  s     1Sc\\Sr)   )rx   )r[   s   &r   r.   r.     s     991S111r   c                P   RV ,          pVR,          pV F0  pVRRP                  R V 4       4      ,           R,           ,          pK2  	  VR,          pTRP                  V Uu. uF,  pR	\        \        V4      4      ,           R
V ,          ,           NK.  	  up4      ,          pV# u upi )z The text for ambiguity warnings z.
Ambiguities exist in dispatched function %s

z;The following signatures may result in ambiguous behavior:
	rt   c              3  T   "   T F  pR \        V4      ,           R,           x  K   	  R# 5i)[]N)r.   )r%   r   s   & r   r'   warning_text.<locals>.<genexpr>  s"     ADqcM!,,s22Ds   &(r   z,

Consider making the following additions:

r   z
@dispatch(z)
def %s(...))rx   r.   r   )r   r;   textpairr   s   &&   r   r   r     s    >$GDJJDIIADAABDHI 	I  	>>DFKK<?A<?q &oa6H(II+d23 3<?A B BDKAs   "2B#
)__conditional_annotations__
__future__r   warningsr   rV   conflictr   r   r   r   utilsr	   	itertoolsr   r-   r   r   r   r:   r8   r=   __annotations__r?   r@   rD   rF   r   r   r.   r   )r   s   @r   <module>r      s    " "   N N   8/ 8G" 
8 ,/5  06 #1 6L# L#^/z /62
r   