
    [i%              	      *   d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
Z
d dlmc mZ d dlmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZmZ d dlmZ d dl m!Z! erd dl"m#Z#m$Z$ d dl m%Z% d dl&m'Z'm(Z(m)Z)  G d deeeddf   eeef         Z*y)    )annotationsN)reduce)chain)TYPE_CHECKINGAny)AlignDiagonal)combine_alias_output_namescombine_evaluate_output_namesIbisLazyFrameIbisExpr)IbisSelectorNamespace)functionlitnarwhals_to_native_dtype)SQLNamespace)Implementation)IterableSequence)Version)ConcatMethod	IntoDTypePythonLiteralc                      e Zd ZU ej                  Zded<   ddZedd       Z	edd       Z
edd       ZddZddZ	 d	 	 	 	 	 	 	 dd
ZddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZddZddZddZy	)IbisNamespacer   _implementationc                   || _         y N)_version)selfversions     i/var/www/html/userprofiledev.eatanceapp.com/venv/lib/python3.12/site-packages/narwhals/_ibis/namespace.py__init__zIbisNamespace.__init__$   s	        c                ,    t        j                  |       S r   )r   from_namespacer!   s    r#   	selectorszIbisNamespace.selectors'   s    $33D99r%   c                    t         S r   r   r(   s    r#   _exprzIbisNamespace._expr+   s    r%   c                    t         S r   r   r(   s    r#   
_lazyframezIbisNamespace._lazyframe/   s    r%   c                    t        |g| S r   )r   )r!   nameargss      r#   	_functionzIbisNamespace._function3   s    $t$$r%   c                    t        |      S r   )r   )r!   values     r#   _litzIbisNamespace._lit6   s    5zr%   Nc                f    |t        j                  ||f      S t        j                  ||f|      S )N)else_)ibiscases)r!   	conditionr3   	otherwises       r#   _whenzIbisNamespace._when9   s4     ::y%011zz9e,I>>r%   c                &    t        j                  | S r   )r7   coalesce)r!   exprss     r#   	_coalescezIbisNamespace._coalesce@   s    }}e$$r%   c               :   t        |      }|dk(  r| j                  |      }	 t        j                  d |D         }|d   j                  |      S # t        j                  $ r6 |d   j
                  t        fd|dd  D              sd}t        |      d  w xY w)Ndiagonalc              3  4   K   | ]  }|j                     y wr   )native).0lfs     r#   	<genexpr>z'IbisNamespace.concat.<locals>.<genexpr>J   s     !=f"))fs   r   c              3  <   K   | ]  }|j                   k(    y wr   )schema)rD   xfirsts     r#   rF   z'IbisNamespace.concat.<locals>.<genexpr>M   s     =*Qqxx5(*s      z&inputs should all have the same schema)	tuplealign_diagonalr7   union	IbisErrorrH   all	TypeError_with_native)r!   itemshowframesresultmsgrJ   s         @r#   concatzIbisNamespace.concatC   s     +0,*((0F	ZZ!=f!=>F ay%%f-- ~~ 	1I$$E=&*==>n$.	s   A A	Bc               n    dfd}| j                  |t         t         | j                        S )Nc                     t        j                   fdD              }|D cg c]  }|j                  d       }}rt              j	                  |      }|gS t        fd|dd  |d         }|gS c c}w )Nc              3  .   K   | ]  } |        y wr    )rD   exprdfs     r#   rF   z9IbisNamespace.concat_str.<locals>.func.<locals>.<genexpr>W   s     &BEDtBxEs   stringc                (    | j                  |      S r   )rX   )acccol	separators     r#   <lambda>z8IbisNamespace.concat_str.<locals>.func.<locals>.<lambda>^   s    SZZ	3%?r%   rK   r   )r   from_iterablecastr   joinr   )r^   colsscols_castedrV   r>   ignore_nullsrc   s   `    r#   funcz&IbisNamespace.concat_str.<locals>.funcV   s    &&&BE&BBD59:T166(+TK:Y,,[9 8O  ?ON 8O ;s   A7callevaluate_output_namesalias_output_namesr"   )r^   r   returnlist[ir.Value])r+   r
   r	   r    )r!   rc   rk   r>   rl   s    ``` r#   
concat_strzIbisNamespace.concat_strS   s:    	 zz"?"G95AMM	  
 	
r%   c                D    dd} | j                   j                  |g| S )Nc                    t        |       } t        t        j                  d | D              t        t        j                  d | D              z  S )Nc              3  P   K   | ]  }|j                  t        d                yw)r   N)	fill_nullr   rD   rb   s     r#   rF   z>IbisNamespace.mean_horizontal.<locals>.func.<locals>.<genexpr>o   s     (O$3s1v)>$s   $&c              3     K   | ]6  }|j                         j                  t        d       t        d             8 yw)r   rK   N)isnullifelser   rx   s     r#   rF   z>IbisNamespace.mean_horizontal.<locals>.func.<locals>.<genexpr>p   s,     Sdsszz|223q63q6Bds   <>)listr   operatoradd)rh   s    r#   rl   z+IbisNamespace.mean_horizontal.<locals>.funcm   sA    :D(,,(O$(OPSYSdST  r%   )rh   zIterable[ir.Value]rq   ir.Value)r+   _from_elementwise_horizontal_op)r!   r>   rl   s      r#   mean_horizontalzIbisNamespace.mean_horizontall   s%    	 :tzz99$GGGr%   c                X     d fd} j                  |d d  j                        S )Nc                    rt        j                        nd }t        t              st	        |      gS rt        j                  |      gS d}t        |      )N)typez3Cannot create an empty struct type for Ibis backend)r   r    
isinstancedictr   r7   structNotImplementedError)_df
ibis_dtyperW   dtyper!   r3   s      r#   rl   zIbisNamespace.lit.<locals>.funcv   sZ    KP1%GVZJeT*E:.//E
;<<GC%c**r%   c                    dgS )Nliteralr\   r   s    r#   rd   z#IbisNamespace.lit.<locals>.<lambda>   s    ykr%   )ro   rp   r"   )r   r   rq   zSequence[ir.Value]r+   r    )r!   r3   r   rl   s   ``` r#   r   zIbisNamespace.litu   s0    	+ zz"9#MM	  
 	
r%   c                J    dd}| j                  |d d | j                        S )Nc                8    | j                   j                         gS r   )rC   countr   s    r#   rl   zIbisNamespace.len.<locals>.func   s    JJ$$&''r%   c                    dgS )Nlenr\   r   s    r#   rd   z#IbisNamespace.len.<locals>.<lambda>   s    ugr%   rm   )r   r   rq   rr   r   )r!   rl   s     r#   r   zIbisNamespace.len   s/    	( zz"5#MM	  
 	
r%   )r"   r   rq   None)rq   r   )rq   ztype[IbisExpr])rq   ztype[IbisLazyFrame])r/   strr0   zir.Value | PythonLiteralrq   r   )r3   r   rq   r   r   )r9   r   r3   r   r:   zir.Expr | Nonerq   r   )r>   r   rq   r   )rS   zIterable[IbisLazyFrame]rT   r   rq   r   )r>   r   rc   r   rk   boolrq   r   )r>   r   rq   r   )r3   r   r   zIntoDType | Nonerq   r   )rq   r   )__name__
__module____qualname__r   IBISr   __annotations__r$   propertyr)   r+   r-   r1   r4   r;   r?   rX   rs   r   r   r   r\   r%   r#   r   r      s     '5&9&9O^9  : :    % QU?!?*2??M?	?%.,.6B.	. 

+.
>B
	
2H
"	
r%   r   zir.Tabler   )+
__future__r   r}   	functoolsr   	itertoolsr   typingr   r   r7   ibis.expr.typesr]   typesirnarwhals._compliant.namespacer   narwhals._expression_parsingr	   r
   narwhals._ibis.dataframer   narwhals._ibis.exprr   narwhals._ibis.selectorsr   narwhals._ibis.utilsr   r   r   narwhals._sql.namespacer   narwhals._utilsr   collections.abcr   r   r   narwhals.typingr   r   r   r   r\   r%   r#   <module>r      su    "    %    7 3 ( : H H 0 *2'FFq
*j@A-)*q
r%   