
    -Ph"                       d dl mZ 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dS )     )annotations)IterableSequencec                      e Zd ZdZdS )NarwhalsErrorz'Base class for all Narwhals exceptions.N__name__
__module____qualname____doc__     S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/narwhals/exceptions.pyr   r      s        1111r   r   c                  "    e Zd ZdZd	dZd
dZdS )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.
    messagestrreturnNonec                    || _         d S Nr   )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   r   r   r   )r   r   )r	   r
   r   r   r   r   r   r   r   r   r   
   sF                 r   r   c                  <     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.r   r   r   r   c                b    || _         t                                          | j                    d S r   r   superr   r   r   	__class__s     r   r   zColumnNotFoundError.__init__   *    &&&&&r   missing_columnsIterable[str]available_columnsSequence[str]c               f    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   )clsr&   r(   r   s       r   'from_missing_and_available_column_namesz;ColumnNotFoundError.from_missing_and_available_column_names!   sQ    
WVO5L5L W W<@AR<S<SW W W 	 #7+++r   r   )r&   r'   r(   r)   r   r   )r	   r
   r   r   r   classmethodr/   __classcell__r$   s   @r   r   r      sc        ::' ' ' ' ' ' , , , [, , , , ,r   r   c                      e Zd ZdZdS )ComputeErrorzHException raised when the underlying computation could not be evaluated.Nr   r   r   r   r4   r4   ,   s        RRRRr   r4   c                      e Zd ZdZdS )
ShapeErrorz_Exception raised when trying to perform operations on data structures with incompatible shapes.Nr   r   r   r   r6   r6   0           iiiir   r6   c                      e Zd ZdZdS )MultiOutputExpressionErrorzKException raised when using multi-output expression in unsupported context.Nr   r   r   r   r9   r9   4   s        UUUUr   r9   c                      e Zd ZdZdS )DuplicateErrorz6Exception when duplicate column names are encountered.Nr   r   r   r   r;   r;   8   s        @@@@r   r;   c                      e Zd ZdZdS )InvalidOperationErrorz+Exception raised during invalid operations.Nr   r   r   r   r=   r=   <   s        5555r   r=   c                  <     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.r   r   r   r   c                b    || _         t                                          | j                    d S r   r!   r#   s     r   r   zInvalidIntoExprError.__init__C   r%   r   r.   typeinvalid_typec                ,    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.   rB   r   s      r   from_invalid_typez&InvalidIntoExprError.from_invalid_typeG   s.    /Q] / / / 	 $G,,,r   r   )r.   rA   rB   rA   r   r?   )r	   r
   r   r   r   r0   rD   r1   r2   s   @r   r?   r?   @   sc        HH' ' ' ' ' ' - - - [- - - - -r   r?   c                  <     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.r   r   r   r   c                b    || _         t                                          | j                    d S r   r!   r#   s     r   r   zAnonymousExprError.__init__Z   r%   r   r.   rA   	expr_namec                ,    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')`)rF   )r.   rH   r   s      r   from_expr_namez!AnonymousExprError.from_expr_name^   s-    !9 ! ! ! 	
 "'***r   r   )r.   rA   rH   r   r   rF   )r	   r
   r   r   r   r0   rJ   r1   r2   s   @r   rF   rF   W   sc        VV' ' ' ' ' ' + + + [+ + + + +r   rF   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.r   r   r   r   c                b    || _         t                                          | j                    d S r   r!   r#   s     r   r   z OrderDependentExprError.__init__k   r%   r   r   r	   r
   r   r   r   r1   r2   s   @r   rL   rL   h   sC        ]]' ' ' ' ' ' ' ' ' 'r   rL   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.r   r   r   r   c                b    || _         t                                          | j                    d S r   r!   r#   s     r   r   z LengthChangingExprError.__init__s   r%   r   r   rN   r2   s   @r   rP   rP   p   sC        aa' ' ' ' ' ' ' ' ' 'r   rP   c                      e Zd ZdZdS )UnsupportedDTypeErrorz_Exception raised when trying to convert to a DType which is not supported by the given backend.Nr   r   r   r   rS   rS   x   r7   r   rS   c                      e Zd ZdZdS )NarwhalsUnstableWarningzRWarning issued when a method or function is considered unstable in the stable api.Nr   r   r   r   rU   rU   |   s        \\\\r   rU   N)
__future__r   typingr   r   
ValueErrorr   KeyErrorr   r   r4   r6   r9   r;   r=   	TypeErrorr?   rF   rL   rP   rS   UserWarningrU   r   r   r   <module>r\      s   " " " " " " % % % % % % % %2 2 2 2 2J 2 2 2        , , , , ,+] , , ,$S S S S S= S S Sj j j j j j j jV V V V V V V VA A A A A] A A A6 6 6 6 6M 6 6 6- - - - -9m - - -.+ + + + + + + +"' ' ' ' 'm ' ' '' ' ' ' 'm ' ' 'j j j j jM j j j] ] ] ] ]k ] ] ] ] ]r   