ó
    ±“,ji#  ã                   ó2  • S SK r S r\ " S S\5      5       r\ " S S\5      5       r\ " S S\5      5       r\ " S	 S
\5      5       r\ " S S\5      5       r\ " S S\5      5       r\ " S S\5      5       r	\ " S S\5      5       r
\ " S S\5      5       rg)é    Nc                 ó   • SU l         U $ )Nzeinx.errors)Ú
__module__)Úobjs    Ú§C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\einx/_src/frontend/errors.pyÚexportr      s   € Ø"€C„NØ€Jó    c                   ó   • \ rS rSrSrg)Ú	EinxErroré	   © N)Ú__name__r   Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   r   r   r
   r
   	   s   † âr   r
   c                   ó"   • \ rS rSrSrSS jrSrg)ÚSyntaxErroré   a  
This error occurs if einx operations encounter invalid syntax in an expression.

Example:
    >>> x = np.random.rand(3, 4)
    >>> einx.id("a (b -> b a", x)
    einx.errors.SyntaxError: Found an opening parenthesis that is not closed:
    Expression: "a (b"
                ^
Nc                 ó¬  ^• [        T[        5      (       d  [        S5      eSSKJn  U" T5      n[        U[
        5      (       a	  U/U l        OUc  / U l        O[        U5      U l        [        U4S jU R                   5       5      (       d   eSU;   a+  UR                  SUR                  U R                  5      5      n[        R                  X5        g )Nzexpression must be a stringr   )ÚExpressionIndicatorc              3   óV   >#   • U  H  oS :¬  =(       a    U[        T5      :  v •  M      g7f©r   N)Úlen)Ú.0ÚpÚ
expressions     €r   Ú	<genexpr>Ú'SyntaxError.__init__.<locals>.<genexpr>)   s$   øé € ÐDº8°a˜‘6×1˜a¤# j£/Ñ1Ô1º8ùs   ƒ&)ú%EXPR%)Ú
isinstanceÚstrÚ
ValueErrorÚeinx._src.namedtensorr   ÚintÚposÚlistÚallÚreplaceÚcreater
   Ú__init__)Úselfr   Úmessager$   r   Ú	indicators    `    r   r)   ÚSyntaxError.__init__   s¦   ø€ Ü˜*¤c×*Ñ*ÜÐ:Ó;Ð;å=á'¨
Ó3ˆ	ä�cœ3×ÑØ�uˆD�HØ‰[ØˆD�Hä˜C“yˆDŒHÜÔD¸4¿8º8ÓD×DÑDÐDÐDà�wÓØ—o‘o h°	×0@Ñ0@ÀÇÁÓ0JÓKˆGä×Ñ˜4Õ)r   ©r$   ©N©r   r   r   r   Ú__doc__r)   r   r   r   r   r   r      s   † ñ	÷*r   r   c                   ó"   • \ rS rSrSrSS jrSrg)Ú	RankErroré1   aÌ  
This error occurs if the ranks (i.e. number of dimensions) of all expressions cannot
be determined under the given input tensor shapes and additional constraints.

Example:
    >>> x = np.random.rand(3, 4)
    >>> einx.id("a b c -> a c b", x)
    einx.errors.RankError: The number of tensor dimensions and axes in the expression does not match.
    The operation was called with the following arguments:
    - Positional argument #1: Tensor with shape (3, 4)
Nc                 óÄ  ^• Uc  / n[        U[        5      (       a	  U/U l        OUc  / U l        O[        U5      U l        [	        U4S jU R                   5       5      (       d   e/ nU Hh  n[        U[
        5      (       a  UR                  U5        M+  [        U5      S:X  d   eUS   c  MD  US   c  ML  UR                  US    SUS    35        Mj     SU;   a5  UR                  STR                  R                  U R                  5      5      n[        U5      S:”  a  US-  nU H  nUSU 3-  nM     US	TR                  5       -   -  n[        R                  X5        g )
Nc              3   ój   >#   • U  H(  oS :¬  =(       a    U[        TR                  5      :  v •  M*     g7fr   ©r   r   ©r   r   Ú
invocations     €r   r   Ú%RankError.__init__.<locals>.<genexpr>I   ó+   øé € ÐOÂhÀ˜‘6×<˜a¤# j×&;Ñ&;Ó"<Ñ<Ô<Âhùó   ƒ03é   r   é   ú = r   z>
The following equation(s) were determined for the expression:ú
    Ú
©r   r#   r$   r%   r&   r    Úappendr   r'   r,   r(   Úto_call_signature_stringr
   r)   ©r*   r9   r+   r$   ÚconstraintsÚconstraints2Ú
constraints    `     r   r)   ÚRankError.__init__?   sN  ø€ ØÑØˆKä�cœ3×ÑØ�uˆD�HØ‰[ØˆD�Hä˜C“yˆDŒHÜÔOÀdÇhÂhÓO×OÑOÐOÐOàˆÛ%ˆJÜ˜*¤c×*Ñ*Ø×#Ñ# JÖ/ä˜:“¨!Ó+Ð+Ð+Ø˜a‘=Ó,°¸A±Ó1JØ ×'Ñ'¨:°a©=¨/¸¸ZÈ¹]¸OÐ(LÖMñ &ð �wÓØ—o‘o h°
×0DÑ0D×0KÑ0KÈDÏHÉHÓ0UÓVˆGÜˆ|Ó˜qÓ ØÐXÑXˆGÛ*�
Ø˜V J <Ð0Ñ0’ñ +à�4˜*×=Ñ=Ó?Ñ?Ñ?ˆä×Ñ˜4Õ)r   r.   ©NNr0   r   r   r   r3   r3   1   s   † ñ
÷*r   r3   c                   ó"   • \ rS rSrSrSS jrSrg)ÚAxisSizeErroré_   aS  
This error occurs if the size of all axes in an einx expression cannot be determined
under the given input tensor shapes and additional constraints.

Example:
    >>> x = np.random.rand(3, 4)
    >>> y = np.random.rand(4, 4)
    >>> einx.add("a b, a c -> a b c", x, y)
    einx.errors.AxisSizeError: Failed to determine the size of all axes in the expression under the given constraints.
    Expression: "a b, a c -> a b c"

    The operation was called with the following arguments:
    - Positional argument #1: Tensor with shape (3, 4)
    - Positional argument #2: Tensor with shape (4, 4)
Nc                 óÄ  ^• Uc  / n[        U[        5      (       a	  U/U l        OUc  / U l        O[        U5      U l        [	        U4S jU R                   5       5      (       d   e/ nU Hh  n[        U[
        5      (       a  UR                  U5        M+  [        U5      S:X  d   eUS   c  MD  US   c  ML  UR                  US    SUS    35        Mj     SU;   a5  UR                  STR                  R                  U R                  5      5      n[        U5      S:”  a  US-  nU H  nUSU 3-  nM     US	TR                  5       -   -  n[        R                  X5        g )
Nc              3   ój   >#   • U  H(  oS :¬  =(       a    U[        TR                  5      :  v •  M*     g7fr   r7   r8   s     €r   r   Ú)AxisSizeError.__init__.<locals>.<genexpr>{   r;   r<   r=   r   r>   r?   r   zT
The expression, tensor shapes and contraints resulted in the following equation(s):r@   rA   rB   rE   s    `     r   r)   ÚAxisSizeError.__init__q   sN  ø€ ØÑØˆKä�cœ3×ÑØ�uˆD�HØ‰[ØˆD�Hä˜C“yˆDŒHÜÔOÀdÇhÂhÓO×OÑOÐOÐOàˆÛ%ˆJÜ˜*¤c×*Ñ*Ø×#Ñ# JÖ/ä˜:“¨!Ó+Ð+Ð+Ø˜a‘=Ó,°¸A±Ó1JØ ×'Ñ'¨:°a©=¨/¸¸ZÈ¹]¸OÐ(LÖMñ &ð �wÓØ—o‘o h°
×0DÑ0D×0KÑ0KÈDÏHÉHÓ0UÓVˆGÜˆ|Ó˜qÓ ØÐnÑnˆGÛ*�
Ø˜V J <Ð0Ñ0’ñ +à�4˜*×=Ñ=Ó?Ñ?Ñ?ˆä×Ñ˜4Õ)r   r.   rJ   r0   r   r   r   rL   rL   _   s   † ñ÷ *r   rL   c                   ó"   • \ rS rSrSrSS jrSrg)ÚSemanticErroré‘   a#  
This error occurs if the expression requirements of a particular einx operation are not met.

Example:
    >>> x = np.random.rand(3, 4)
    >>> y = np.random.rand(4, 5)
    >>> einx.dot("a [b], [c] d -> a d", x, y)
    einx.errors.SemanticError: All contracted axes must appear in exactly two input expressions.
    Expression: "a [b], [c] d -> a d"
                    ^    ^
    The operation was called with the following arguments:
    - Positional argument #1: Tensor with shape (3, 4)
    - Positional argument #2: Tensor with shape (4, 5)
Nc                 óÔ  ^• [        U[        5      (       d   eTb±  [        U[        5      (       a	  U/U l        OUc  / U l        O[	        U5      U l        [        U4S jU R                   5       5      (       d   eSU;   a5  UR                  STR                  R                  U R                  5      5      nUSTR                  5       -   -  nOS U l        [        R                  X5        g )Nc              3   ój   >#   • U  H(  oS :¬  =(       a    U[        TR                  5      :  v •  M*     g7fr   r7   r8   s     €r   r   Ú)SemanticError.__init__.<locals>.<genexpr>«   s+   øé € ÐSÊ(ÀQ˜A‘v×@ !¤c¨*×*?Ñ*?Ó&@Ñ"@Ô@Ê(ùr<   r   rA   )r   r    r#   r$   r%   r&   r'   r,   r(   rD   r
   r)   )r*   r+   r9   r$   s     ` r   r)   ÚSemanticError.__init__¢   sÃ   ø€ Ü˜'¤3×'Ñ'Ð'Ð'ØÑ!Ü˜#œs×#Ñ#Ø˜5�•Ø‘Ø�•ä ›9�”ÜÔSÈ$Ï(Ê(ÓS×SÑSÐSÐSà˜7Ó"Ø!Ÿ/™/¨(°J×4HÑ4H×4OÑ4OÐPT×PXÑPXÓ4YÓZ�Ø�t˜j×AÑAÓCÑCÑC‰Gð ˆDŒHä×Ñ˜4Õ)r   r.   rJ   r0   r   r   r   rS   rS   ‘   s   † ñ÷*r   rS   c                   ó"   • \ rS rSrSrSS jrSrg)ÚOperationNotSupportedErroré·   a  
This error occurs if an einx operation is not supported by the selected backend.

Example:
    >>> x = np.random.rand(3, 4)
    >>> einx.min("a [b]", x, backend="numpy.einsum")
    einx.errors.OperationNotSupportedError: min operation is not supported by the numpy.einsum backend.
Nc                 ó8   • Uc  Sn[         R                  X5        g )Nz0This operation is not supported by this backend.)r
   r)   )r*   r+   s     r   r)   Ú#OperationNotSupportedError.__init__Â   s   € Ø‰?ØHˆGÜ×Ñ˜4Õ)r   r   r/   r0   r   r   r   rZ   rZ   ·   s   † ñ÷*r   rZ   c                   ó   • \ rS rSrSrSrg)ÚImportBackendErroréÈ   ar  
This error occurs if a requested backend failed to be imported or initialized.

Example:
    >>> sys.modules["jax"] = types.SimpleNamespace()  # Create some invalid jax module
    >>> x = np.random.rand(3, 4)
    >>> einx.min("a [b]", x, backend="jax")
    einx.errors.ImportBackendError: Failed to import backend "jax" for module "jax" due to the following error: ...
r   N©r   r   r   r   r1   r   r   r   r   r_   r_   È   ó   † ñò 	r   r_   c                   ó   • \ rS rSrSrSrg)ÚBackendResolutionErroré×   a9  
This error occurs if the backend with which to execute an einx operation could not be determined.

Example:
    >>> x = jnp.zeros((10, 11))
    >>> y = torch.zeros(10, 11)
    >>> einx.add("a b, a b", x, y)
    einx.errors.BackendResolutionError: Failed to determine which backend to use for this operation: ...
r   Nra   r   r   r   rd   rd   ×   rb   r   rd   c                   ó(   • \ rS rSrSr\S 5       rSrg)ÚCallOperationErroréæ   aî  
This error occurs if the Python function that einx compiles for an einx operation fails to execute.

Example:
    >>> op = lambda x: None  # Create some invalid operation
    >>> einop = einx.jax.adapt_with_vmap(op)
    >>> x = np.random.rand(3, 4)
    >>> einop("a [b] -> a", x)
    einx.errors.CallOperationError: The function that was compiled for this operation failed to execute.
    ...
    The error was: AssertionError: Expected 1st return value of the adapted function to be a tensor
c                 ó:  • SnUb¯  US-  n[        UR                  5       S5       H  u  p4X#S SU S3-  nM     U R                  bo  [        R                  " U R                  5      nU(       aH  U Vs/ s H   ofR
                  S:X  d  M  UR                  PM"     nn[        U5      S:X  a  USUS	    S
3-  nUS-  n[        [        U 5      S5      (       a  U[        U 5      R                   -  n[        [        U 5      5      S	:”  a  USU  3-  n[        U5      $ s  snf )NzDThe function that was compiled for this operation failed to execute.z# The following code was generated:
r>   Ú4z: rA   z<string>zThe error occurred at line r   z.
z
The error was: r   )Ú	enumerateÚ
splitlinesÚ__traceback__Ú	tracebackÚ
extract_tbÚfilenameÚlinenor   ÚhasattrÚtyper   r    rg   )ÚeÚcoder+   ÚiÚlineÚtbÚframeÚlinenoss           r   r(   ÚCallOperationError.createõ   s  € àXˆØÑØÐ=Ñ=ˆGÜ$ T§_¡_Ó%6¸Ö:‘�Ø ˜U " T F¨"Ð-Ñ-’ñ ;ð �‰Ñ*Ü×)Ò)¨!¯/©/Ó:�ÞÙ9;Ó\º°¿~¹~ÐQ[Ñ?[›|˜uŸ|œ|¹�GÐ\Ü˜7“| qÓ(ØÐ%@ÀÈÁÀÈCÐ#PÑP˜àÐ&Ñ&ˆÜ”4˜“7˜J×'Ñ'Øœ$˜q›'×*Ñ*Ð+Ñ,ˆGÜŒs�1‹v‹;˜‹?Ø˜˜A˜3�xÑˆGÜ! 'Ó*Ð*ùò ]s   Á1DÂDr   N)r   r   r   r   r1   Ústaticmethodr(   r   r   r   r   rg   rg   æ   s   † ñð ñ+ó ó+r   rg   )rn   r   Ú	Exceptionr
   r   r3   rL   rS   rZ   r_   rd   rg   r   r   r   Ú<module>r~      s  ðÛ òð
 ô	�	ó 	ó ð	ð ô*�)ó *ó ð*ðD ô**�	ó **ó ð**ðZ ô.*�Ió .*ó ð.*ðb ô"*�Ió "*ó ð"*ðJ ô* ó *ó ð*ð  ô	˜ó 	ó ð	ð ô	˜Yó 	ó ð	ð ô"+˜ó "+ó ñ"+r   