
    bZhc                    h   d dl mZ d dlmZ erd dlmZmZ  G d de      Z G d de	      Z
 G d d	e
e      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d dee      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy )!    )annotations)TYPE_CHECKING)IterableSequencec                      e Zd ZdZy)NarwhalsErrorz'Base class for all Narwhals exceptions.N__name__
__module____qualname____doc__     b/mounts/lovelace/software/anaconda3/envs/py312/lib/python3.12/site-packages/narwhals/exceptions.pyr   r   	   s    1r   r   c                       e Zd ZdZddZddZy)FormattedKeyErrora7  KeyError with formatted error message.

    Python's `KeyError` has special casing around formatting
    (see https://bugs.python.org/issue2651). Use this class when the error
    message has newlines and other special format characters.
    Needed by https://github.com/tensorflow/tensorflow/issues/36857.
    c                    || _         y Nmessage)selfr   s     r   __init__zFormattedKeyError.__init__   s	    r   c                    | j                   S r   r   )r   s    r   __str__zFormattedKeyError.__str__   s    ||r   Nr   strreturnNone)r   r   )r
   r   r   r   r   r   r   r   r   r   r      s    r   r   c                  B     e Zd ZdZd fdZe	 	 	 	 	 	 dd       Z xZS )ColumnNotFoundErrorz0Exception raised when column name isn't present.c                F    || _         t        | 	  | j                          y r   r   superr   r   r   	__class__s     r   r   zColumnNotFoundError.__init__        &r   c               N    dt        |       dt        |       d}t        |      S )Nz&The following columns were not found: z+

Hint: Did you mean one of these columns: ?)sortedlistr    )clsmissing_columnsavailable_columnsr   s       r   'from_missing_and_available_column_namesz;ColumnNotFoundError.from_missing_and_available_column_names$   s:    
 5VO5L4M;DAR<S;TTUW 	 #7++r   r   )r,   zIterable[str]r-   zSequence[str]r   r    )r
   r   r   r   r   classmethodr.   __classcell__r%   s   @r   r    r       s7    :' ,+,@M,	, ,r   r    c                      e Zd ZdZy)ComputeErrorzHException raised when the underlying computation could not be evaluated.Nr	   r   r   r   r3   r3   /   s    Rr   r3   c                      e Zd ZdZy)
ShapeErrorz_Exception raised when trying to perform operations on data structures with incompatible shapes.Nr	   r   r   r   r5   r5   3       ir   r5   c                      e Zd ZdZy)MultiOutputExpressionErrorzKException raised when using multi-output expression in unsupported context.Nr	   r   r   r   r8   r8   7   s    Ur   r8   c                      e Zd ZdZy)DuplicateErrorz6Exception when duplicate column names are encountered.Nr	   r   r   r   r:   r:   ;   s    @r   r:   c                      e Zd ZdZy)InvalidOperationErrorz+Exception raised during invalid operations.Nr	   r   r   r   r<   r<   ?   s    5r   r<   c                  6     e Zd ZdZd fdZedd       Z xZS )InvalidIntoExprErrorz>Exception raised when object can't be converted to expression.c                F    || _         t        | 	  | j                          y r   r"   r$   s     r   r   zInvalidIntoExprError.__init__F   r&   r   c                $    d| d}t        |      S )NzBExpected an object which can be converted into an expression, got a  

Hint:
- if you were trying to select a column which does not have a string
  column name, then you should explicitly use `nw.col`.
  For example, `df.select(nw.col(0))` if you have a column named `0`.
- if you were trying to create a new literal column, then you 
  should explicitly use `nw.lit`.
  For example, `df.select(nw.lit(0))` if you want to create a new
  column with literal value `0`.)r>   )r+   invalid_typer   s      r   from_invalid_typez&InvalidIntoExprError.from_invalid_typeJ   s+     QQ]P^ _/ / 	 $G,,r   r   )r+   typerA   rC   r   r>   )r
   r   r   r   r   r/   rB   r0   r1   s   @r   r>   r>   C   s    H' - -r   r>   c                  6     e Zd ZdZd fdZedd       Z xZS )AnonymousExprErrorzLException raised when trying to perform operations on anonymous expressions.c                F    || _         t        | 	  | j                          y r   r"   r$   s     r   r   zAnonymousExprError.__init__]   r&   r   c                $    d| d}t        |      S )Nz,Anonymous expressions are not supported in `zR`.
Instead of `nw.all()`, try using a named expression, such as `nw.col('a', 'b')`)rE   )r+   	expr_namer   s      r   from_expr_namez!AnonymousExprError.from_expr_namea   s(     ;9+ F! ! 	
 "'**r   r   )r+   rC   rH   r   r   rE   )r
   r   r   r   r   r/   rI   r0   r1   s   @r   rE   rE   Z   s    V' + +r   rE   c                  $     e Zd ZdZd fdZ xZS )OrderDependentExprErrorzSException raised when trying to use an order-dependent expressions with LazyFrames.c                F    || _         t        | 	  | j                          y r   r"   r$   s     r   r   z OrderDependentExprError.__init__n   r&   r   r   r
   r   r   r   r   r0   r1   s   @r   rK   rK   k   s    ]' 'r   rK   c                  $     e Zd ZdZd fdZ xZS )LengthChangingExprErrorzWException raised when trying to use an expression which changes length with LazyFrames.c                F    || _         t        | 	  | j                          y r   r"   r$   s     r   r   z LengthChangingExprError.__init__v   r&   r   r   rM   r1   s   @r   rO   rO   s   s    a' 'r   rO   c                      e Zd ZdZy)UnsupportedDTypeErrorz_Exception raised when trying to convert to a DType which is not supported by the given backend.Nr	   r   r   r   rR   rR   {   r6   r   rR   c                      e Zd ZdZy)NarwhalsUnstableWarningzRWarning issued when a method or function is considered unstable in the stable api.Nr	   r   r   r   rT   rT      s    \r   rT   N)
__future__r   typingr   collections.abcr   r   
ValueErrorr   KeyErrorr   r    r3   r5   r8   r:   r<   	TypeErrorr>   rE   rK   rO   rR   UserWarningrT   r   r   r   <module>r\      s    "  22J 2  ,+] ,$S= Sj jV VA] A6M 6-9m -.+ +"'m ''m 'jM j]k ]r   