ó
    Î›‘h  ã                  ó6  • % S r SSKJr  SSKrSSKJr  SSKJrJrJ	r	J
r
JrJr  \R                  S:¼  a  SSKJr  OSSKJr  Sr\" S	\S
9r\" S\S
9r\" S\S
9r " S S\\\\4   5      r " S S\\\\4   5      r\\/S4   rSrS\S'    " S S\\\\4   5      rg)zp
A core state-machine abstraction.

Perhaps something that could be replaced with or integrated into machinist.
é    )ÚannotationsN)Úchain)ÚCallableÚGenericÚOptionalÚSequenceÚTypeVarÚHashable)é   é
   )Ú	TypeAliasz
<no state>ÚState)ÚboundÚInputÚOutputc                  ó0   ^ • \ rS rSrSrSU 4S jjrSrU =r$ )ÚNoTransitioné   z�
A finite state machine in C{state} has no transition for C{symbol}.

@ivar state: See C{state} init parameter.

@ivar symbol: See C{symbol} init parameter.
c                ób   >• Xl         X l        [        [        U ]  SR                  X!5      5        g)zº
Construct a L{NoTransition}.

@param state: the finite state machine's state at the time of the
    illegal transition.

@param symbol: the input symbol for which no transition exists.
zno transition for {} in {}N)ÚstateÚsymbolÚsuperÚ	ExceptionÚ__init__Úformat)Úselfr   r   Ú	__class__s      €ÚQC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\automat/_core.pyr   ÚNoTransition.__init__"   s,   ø€ ð Œ
ØŒÜŒi˜Ñ'Ø(×/Ñ/°Ó>õ	
ó    ©r   r   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r      s   ø† ñ÷
õ 
r    r   c                  óÐ   • \ rS rSrSrSSS jjr\SS j5       r\R                  SS j5       r        SS jr	      SS jr
SS	 jrSS
 jrSS jrSS jr      SS jrSrg)Ú	Automatoné2   zf
A declaration of a finite state machine.

Note that this is not the machine itself; it is immutable.
Nc                óX   • Uc  [         nUc   eXl        [        5       U l        SU l        g)z:
Initialize the set of transitions and the initial state.
N)Ú	_NO_STATEÚ_initialStateÚsetÚ_transitionsÚ_unhandledTransition)r   Úinitials     r   r   ÚAutomaton.__init__9   s2   € ð ‰?ÜˆGØÑ"Ð"Ð"Ø$+ÔÜORËuˆÔØNRˆÕ!r    c                ó   • U R                   $ )z(
Return this automaton's initial state.
)r.   ©r   s    r   ÚinitialStateÚAutomaton.initialStateD   s   € ð
 ×!Ñ!Ð!r    c                ó~   • U R                   [        La$  [        SR                  U R                   5      5      eXl         g)zj
Set this automaton's initial state.  Raises a ValueError if
this automaton already has an initial state.
zinitial state already set to {}N)r.   r-   Ú
ValueErrorr   )r   r   s     r   r6   r7   K   s;   € ð ×Ñ¤YÒ.ÜØ1×8Ñ8¸×9KÑ9KÓLóð ð #Õr    c                óÌ   • U R                    H-  u  pVpxXQ:X  d  M  Xb:X  d  M  [        SR                  XU5      5      e   U R                   R                  XU[	        U5      45        g)zˆ
Add the given transition to the outputSymbol. Raise ValueError if
there is already a transition with the same inState and inputSymbol.
z,already have transition from {} to {} via {}N)r0   r9   r   ÚaddÚtuple)	r   ÚinStateÚinputSymbolÚoutStateÚoutputSymbolsÚ	anInStateÚanInputSymbolÚ
anOutStateÚ_s	            r   ÚaddTransitionÚAutomaton.addTransitionY   sg   € ð 8<×7HÔ7HÑ3ˆI jØÕ#¨Õ(DÜ ØB×IÑIØ¨[óóð ñ 8Ið 	×Ñ×Ñ˜w°X¼uÀ]Ó?SÐTÕUr    c                ó(   • U[        U5      4U l        g)zx
All unhandled transitions will be handled by transitioning to the given
error state and error-handling output symbols.
N)r<   r1   )r   r?   r@   s      r   ÚunhandledTransitionÚAutomaton.unhandledTransitionp   s   € ð &.¬u°]Ó/CÐ$DˆÕ!r    c                ó,   • [        U R                  5      $ )z
All transitions.
)Ú	frozensetr0   r5   s    r   ÚallTransitionsÚAutomaton.allTransitionsy   s   € ô ˜×*Ñ*Ó+Ð+r    c           
     ó^   • U R                    VVVVs1 s H  u  pp4UiM
     snnnn$ s  snnnnf )z7
The full set of symbols acceptable to this automaton.
)r0   )r   r=   r>   r?   ÚoutputSymbols        r   ÚinputAlphabetÚAutomaton.inputAlphabet   s6   € ð CG×BSÒBSö
âBSÑ>� xó ÙBSô
ð 	
ùõ 
s   ’'
c                ób   • [        [        R                  " S U R                   5       5      5      $ )zB
The full set of symbols which can be produced by this automaton.
c              3  ó,   #   • U  H
  u  pp4Uv •  M     g 7f©N© )Ú.0r=   r>   r?   r@   s        r   Ú	<genexpr>Ú+Automaton.outputAlphabet.<locals>.<genexpr>�   s   é € ð  âGXÑC�W¨8õ ÚGXùs   ‚)r/   r   Úfrom_iterabler0   r5   s    r   ÚoutputAlphabetÚAutomaton.outputAlphabetˆ   s2   € ô Ü×Òñ  àGK×GXÒGXó ó ó
ð 	
r    c                ób   • [        [        R                  " S U R                   5       5      5      $ )zK
All valid states; "Q" in the mathematical description of a state
machine.
c              3  ó.   #   • U  H  u  pp4X4v •  M     g 7frT   rU   )rV   r=   r>   r?   rO   s        r   rW   Ú#Automaton.states.<locals>.<genexpr>™   s   é € ð  âFWÑB�W¨8ð Õ#ÚFWùs   ‚)rK   r   rY   r0   r5   s    r   ÚstatesÚAutomaton.states“   s2   € ô
 Ü×Òñ  àFJ×FWÒFWó ó ó
ð 	
r    c                ó    • U R                    H  u  p4pVX4X44:X  d  M  U[        U5      4s  $    U R                  c	  [        XS9eU R                  $ )z9
A 2-tuple of (outState, outputSymbols) for inputSymbol.
r!   )r0   Úlistr1   r   )r   r=   r>   rA   rB   r?   r@   s          r   ÚoutputForInputÚAutomaton.outputForInputŸ   s`   € ð BF×ARÔARÑ=ˆI hØÐ%¨)Ð)CÕCØ ¤$ }Ó"5Ð6Ò6ñ BSð ×$Ñ$Ñ,Ü WÑAÐAØ×(Ñ(Ð(r    )r.   r0   r1   rT   )r2   zState | NoneÚreturnÚNone)re   r   )r   r   re   rf   )r=   r   r>   r   r?   r   r@   ztuple[Output, ...])r?   r   r@   zSequence[Output]re   rf   )re   z7frozenset[tuple[State, Input, State, Sequence[Output]]])re   z
set[Input])re   zset[Output])re   zfrozenset[State])r=   r   r>   r   re   ztuple[State, Sequence[Output]])r"   r#   r$   r%   r&   r   Úpropertyr6   ÚsetterrE   rH   rL   rP   rZ   r_   rc   r'   rU   r    r   r*   r*   2   s½   † ñö	Sð ó"ó ð"ð ×Ñó#ó ð#ðVàðVð ðVð ð	Vð
 *ôVð.EØðEØ.>ðEà	ôEô,ô
ô	
ô

ð)Øð)Ø+0ð)à	'÷)r    r*   z<Callable[[State, Input, State], OutputTracer[Output] | None]r   ÚTracerc                  ó>   • \ rS rSrSrSS jrS	S jr    S
S jrSrg)ÚTransitioneré±   z9
The combination of a current state and an L{Automaton}.
c                ó*   • Xl         X l        S U l        g rT   ©Ú
_automatonÚ_stateÚ_tracer)r   Ú	automatonr6   s      r   r   ÚTransitioner.__init__¶   s   € Ø;DŒØ)ŒØ<@ˆ�r    c                ó   • Xl         g rT   )rq   )r   Útracers     r   ÚsetTraceÚTransitioner.setTrace»   s   € Ø�r    c                óÂ   • U R                   R                  U R                  U5      u  p#SnU R                  (       a  U R                  U R                  X5      nX l        X44$ )z3
Transition between states, returning any outputs.
N)ro   rc   rp   rq   )r   r>   r?   r@   Ú	outTracers        r   Ú
transitionÚTransitioner.transition¾   sT   € ð #'§/¡/×"@Ñ"@Ø�K‰K˜ó#
Ñˆð ˆ	Ø�<�<ØŸ™ T§[¡[°+ÓHˆIØŒØÐ)Ð)r    rn   N)rr   zAutomaton[State, Input, Output]r6   r   )ru   z#Tracer[State, Input, Output] | Nonere   rf   )r>   r   re   z4tuple[Sequence[Output], OutputTracer[Output] | None])	r"   r#   r$   r%   r&   r   rv   rz   r'   rU   r    r   rk   rk   ±   s'   † ñôAô
ð*Ø ð*à	=÷*r    rk   )r&   Ú
__future__r   ÚsysÚ	itertoolsr   Útypingr   r   r   r   r	   r
   Úversion_infor   Útyping_extensionsr-   r   r   r   r   r   r*   ÚOutputTracerri   Ú__annotations__rk   rU   r    r   Ú<module>r„      s¾   ðòõ
 #ã 
Ý ß K× Kà×Ñ�wÓÞ å+à€	Ù�˜xÑ(€Ù�˜xÑ(€Ù	� Ñ	*€ô
�9˜g e¨U lÑ3ô 
ô2x)�˜˜u fÐ,Ñ-ô x)ðv ˜˜ $˜Ñ'€ØR€ˆ	Ó Rô*�7˜5 %¨Ð/Ñ0õ *r    