o
    $&]i"                  
   @  s  U d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
mZmZmZmZmZmZmZmZmZ d dlmZmZmZ d dlmZ erwd dlmZmZ d dlmZmZ d d	l m!Z! d d
lm"Z"m#Z# d dl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* eZ+de,d< g dZ-G dd deee
f Z.G dd de.eef eeef Z/G dd de.eef eeeef Z0G dd de/eef eeeeeef Z1dS )    )annotations)partial)TYPE_CHECKINGAnyProtocoloverload)
CompliantExprTCompliantFrameTCompliantLazyFrameTDepthTrackingExprTEagerDataFrameT
EagerExprTEagerSeriesT_co	LazyExprTNativeFrameTNativeSeriesT)exclude_column_namesget_column_namespassthrough_column_names)is_numpy_array_2d)IterableSequence)	TypeAliasTypeIs)CompliantSelectorNamespace)ImplementationVersion)ConcatMethodInto1DArray	IntoDType
IntoSchemaNonNestedLiteral_2DArrayr   
Incomplete)CompliantNamespaceDepthTrackingNamespaceEagerNamespaceLazyNamespacec                   @  s   e Zd ZU ded< ded< edEddZdFd
dZdGddZdGddZdHddZ	dFddZ
dIddZdJd!d"ZdJd#d$ZdKd%d&ZdKd'd(ZdKd)d*ZdKd+d,ZdLd2d3ZdMd5d6ZedNd8d9ZdKd:d;ZdOd>d?ZdPdBdCZdDS )Qr$   r   _implementationr   _versionreturntype[CompliantExprT]c                 C     d S N selfr.   r.   [/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/narwhals/_compliant/namespace.py_expr8      zCompliantNamespace._exprr   c                 C     | j jt| dS Ncontextr2   from_column_namesr   r/   r.   r.   r1   all;      zCompliantNamespace.allnamesstrc                 G     | j jt|| dS r5   r2   r9   r   r0   r<   r.   r.   r1   col>      zCompliantNamespace.colc                 G     | j jtt|d| dS N)r<   r6   r2   r9   r   r   r@   r.   r.   r1   excludeA      zCompliantNamespace.excludeindicesSequence[int]c                 C  s   | j j|d| iS )Nr7   )r2   from_column_indices)r0   rH   r.   r.   r1   nthF   s   zCompliantNamespace.nthc                 C  r,   r-   r.   r/   r.   r.   r1   lenI       zCompliantNamespace.lenvaluer!   dtypeIntoDType | Nonec                 C  r,   r-   r.   )r0   rN   rO   r.   r.   r1   litJ   rM   zCompliantNamespace.litexprsignore_nullsboolc                G  r,   r-   r.   r0   rS   rR   r.   r.   r1   all_horizontalK      z!CompliantNamespace.all_horizontalc                G  r,   r-   r.   rU   r.   r.   r1   any_horizontalN   rW   z!CompliantNamespace.any_horizontalc                 G  r,   r-   r.   r0   rR   r.   r.   r1   sum_horizontalQ   rM   z!CompliantNamespace.sum_horizontalc                 G  r,   r-   r.   rY   r.   r.   r1   mean_horizontalR   rM   z"CompliantNamespace.mean_horizontalc                 G  r,   r-   r.   rY   r.   r.   r1   min_horizontalS   rM   z!CompliantNamespace.min_horizontalc                 G  r,   r-   r.   rY   r.   r.   r1   max_horizontalT   rM   z!CompliantNamespace.max_horizontalitemsIterable[CompliantFrameT]howr   r	   c                C  r,   r-   r.   )r0   r^   r`   r.   r.   r1   concatU   rW   zCompliantNamespace.concat	separatorc                G  r,   r-   r.   )r0   rb   rS   rR   r.   r.   r1   
concat_strX   rW   zCompliantNamespace.concat_str$CompliantSelectorNamespace[Any, Any]c                 C  r,   r-   r.   r/   r.   r.   r1   	selectors[   r3   zCompliantNamespace.selectorsc                 G  r,   r-   r.   rY   r.   r.   r1   coalesce]   rM   zCompliantNamespace.coalescedatar   c                C  r,   r-   r.   r0   rg   r.   r.   r1   from_native_   rM   zCompliantNamespace.from_nativeobjTypeIs[Any]c                C  s   dS )z6Return `True` if `obj` can be passed to `from_native`.Nr.   r0   rj   r.   r.   r1   	is_native`   rW   zCompliantNamespace.is_nativeN)r*   r+   )r*   r   )r<   r=   r*   r   )rH   rI   r*   r   )rN   r!   rO   rP   r*   r   )rR   r   rS   rT   r*   r   )rR   r   r*   r   )r^   r_   r`   r   r*   r	   )rR   r   rb   r=   rS   rT   r*   r   )r*   rd   )rg   r   r*   r   )rj   r   r*   rk   )__name__
__module____qualname____annotations__propertyr2   r:   rA   rF   rK   rL   rQ   rV   rX   rZ   r[   r\   r]   ra   rc   re   rf   ri   rm   r.   r.   r.   r1   r$   3   s0   
 















r$   c                   @  s*   e Zd ZdddZdddZdd	d
ZdS )r%   r*   r   c                 C  r4   r5   r8   r/   r.   r.   r1   r:   i   r;   zDepthTrackingNamespace.allr<   r=   c                 G  r>   r5   r?   r@   r.   r.   r1   rA   l   rB   zDepthTrackingNamespace.colc                 G  rC   rD   rE   r@   r.   r.   r1   rF   o   rG   zDepthTrackingNamespace.excludeN)r*   r   )r<   r=   r*   r   )rn   ro   rp   r:   rA   rF   r.   r.   r.   r1   r%   e   s    

r%   c                   @  s<   e Zd ZedddZedddZdddZdddZdS )r'   r*   tuple[int, ...]c                 C  
   | j  S r-   r(   _backend_versionr/   r.   r.   r1   rv   y      
zLazyNamespace._backend_versiontype[CompliantLazyFrameT]c                 C  r,   r-   r.   r/   r.   r.   r1   
_lazyframe}   r3   zLazyNamespace._lazyframerj   r   TypeIs[NativeFrameT]c                C  s   | j |S r-   )ry   
_is_nativerl   r.   r.   r1   rm      s   zLazyNamespace.is_nativerg   NativeFrameT | Anyr
   c                C  s4   | j |r| j j|| dS dt|j}t|Nr6   zUnsupported type: )ry   r{   ri   typern   	TypeErrorr0   rg   msgr.   r.   r1   ri      s   zLazyNamespace.from_nativeNr*   rs   )r*   rx   )rj   r   r*   rz   )rg   r|   r*   r
   )rn   ro   rp   rr   rv   ry   rm   ri   r.   r.   r.   r1   r'   u   s    
r'   c                   @  s   e Zd ZedAddZedBddZedCd	d
Z	dDdEddZ	dDdFddZdGddZ	e
dHd d!Ze
dId#d!ZdJd&d!Ze
dKdLd+d,Ze
dMd/d,Z	dDdNd1d,ZdOd4d5ZdPd7d8ZdOd9d:ZdQd?d@ZdS )Rr&   r*   rs   c                 C  rt   r-   ru   r/   r.   r.   r1   rv      rw   zEagerNamespace._backend_versiontype[EagerDataFrameT]c                 C  r,   r-   r.   r/   r.   r.   r1   
_dataframe   r3   zEagerNamespace._dataframetype[EagerSeriesT_co]c                 C  r,   r-   r.   r/   r.   r.   r1   _series   r3   zEagerNamespace._seriesNwhenr   then	otherwiseNativeSeriesT | Nonec                 C  r,   r-   r.   )r0   r   r   r   r.   r.   r1   _if_then_else   s   zEagerNamespace._if_then_else	predicater   EagerExprT | Nonec                   s<   d fdd}j j|tddd	 td
d dS )Ndfr   r*   Sequence[EagerSeriesT_co]c                   s   |  }|j}|  } d u r |||\}}|j|j} d u r4|||\}}|j|j}n|   }||||\}}}|j|j|j}||gS r-   )_evaluate_single_output_expr_align_full_broadcastr   native_with_native)r   predicate_salignthen_sresultotherwise_sr   r   r0   r   r.   r1   func   s   


z&EagerNamespace.when_then.<locals>.func_evaluate_output_namesc                 S  s   dgS )Nliteralr.   )_dfr.   r.   r1   <lambda>   s    z*EagerNamespace.when_then.<locals>.<lambda>_alias_output_names)r   evaluate_output_namesalias_output_namesr7   )r   r   r*   r   )r2   _from_callablegetattr)r0   r   r   r   r   r.   r   r1   	when_then   s   

zEagerNamespace.when_thenrj   r   $TypeIs[NativeFrameT | NativeSeriesT]c                C  s   | j |p| j|S r-   )r   r{   r   rl   r.   r.   r1   rm      s   zEagerNamespace.is_nativerg   r   r   c                C  r,   r-   r.   rh   r.   r.   r1   ri      r3   zEagerNamespace.from_nativer   c                C  r,   r-   r.   rh   r.   r.   r1   ri      r3   "NativeFrameT | NativeSeriesT | Any!EagerDataFrameT | EagerSeriesT_coc                C  sP   | j |r| j j|| dS | j|r| jj|| dS dt|j}t|r}   )r   r{   ri   r   r~   rn   r   r   r.   r.   r1   ri      s   .schemaNoner   c                C  r,   r-   r.   r0   rg   r   r.   r.   r1   
from_numpy   r3   zEagerNamespace.from_numpy!IntoSchema | Sequence[str] | Noner"   c                C  r,   r-   r.   r   r.   r.   r1   r      s   Into1DArray | _2DArrayc                C  s*   t |r| jj||| dS | jj|| dS )N)r   r7   r6   )r   r   r   r   r   r.   r.   r1   r      s   dfsSequence[NativeFrameT]c                C  r,   r-   r.   r0   r   r.   r.   r1   _concat_diagonal   rM   zEagerNamespace._concat_diagonalSequence[NativeFrameT | Any]c                C  r,   r-   r.   r   r.   r.   r1   _concat_horizontal   rW   z!EagerNamespace._concat_horizontalc                C  r,   r-   r.   r   r.   r.   r1   _concat_vertical   rM   zEagerNamespace._concat_verticalr^   Iterable[EagerDataFrameT]r`   r   c                C  s^   dd |D }|dkr|  |}n|dkr| |}n|dkr%| |}nt| jj|| dS )Nc                 S  s   g | ]}|j qS r.   )r   ).0itemr.   r.   r1   
<listcomp>   s    z)EagerNamespace.concat.<locals>.<listcomp>
horizontalverticaldiagonalr6   )r   r   r   NotImplementedErrorr   ri   )r0   r^   r`   r   r   r.   r.   r1   ra      s   zEagerNamespace.concatr   )r*   r   )r*   r   r-   )r   r   r   r   r   r   r*   r   )r   r   r   r   r   r   r*   r   )rj   r   r*   r   )rg   r   r*   r   )rg   r   r*   r   )rg   r   r*   r   ).)r   r   rg   r   r*   r   )r   r   rg   r"   r*   r   )r   r   rg   r   r*   r   )r   r   r*   r   )r   r   r*   r   )r^   r   r`   r   r*   r   )rn   ro   rp   rr   rv   r   r   r   r   rm   r   ri   r   r   r   r   ra   r.   r.   r.   r1   r&      s6    
 





r&   N)2
__future__r   	functoolsr   typingr   r   r   r   narwhals._compliant.typingr   r	   r
   r   r   r   r   r   r   r   narwhals._utilsr   r   r   narwhals.dependenciesr   collections.abcr   r   typing_extensionsr   r   narwhals._compliant.selectorsr   r   r   narwhals.typingr   r   r   r    r!   r"   r#   rq   __all__r$   r%   r'   r&   r.   r.   r.   r1   <module>   s6    0 	
2





