§
    Ò¬¸jÉ9  ã                  óø   — d dl mZ d dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ er6d dlZd d	lmZ d d
lmZ d dlmZ d dlmZmZ ej        dk    rd dlm
Z
 nd dlm
Z
  G d„ d¦  «        Z dS )é    )Úannotations)ÚTYPE_CHECKINGÚLiteralÚoverloadN)Ú
deprecated)Úserialize_polars_object)Údisplay_dot_graph©Ú	wrap_expr)ÚComputeError)ÚIOBase)ÚPath)ÚExpr)Ú
SchemaDictÚSerializationFormat)é   é   c                  ó2  — e Zd ZdZdZdUd„ZdVd	„ZdVd
„ZdWd„ZdXd„Z	dXd„Z
dXd„ZdXd„ZdYd„ZdYd„ZdYd„ZddœdZd„ZddœdZd„Zeddœd[d „¦   «         Zed\d#„¦   «         Zddœd]d$„Zd%d&œd^d*„Zd_d,„Zd`d-„Zd`d.„Zdad0„Ze	 dbd1d2œdcd7„¦   «         Zedbddd9„¦   «         Zed1d2œded<„¦   «         Z	 dfd=d2œdgd@„ZedbdhdA„¦   «         ZedidB„¦   «         Z edC¦  «        dfdjdD„¦   «         Zed1d%dEœdkdH„¦   «         Zed%d&œdldI„¦   «         Zdd%dEœdmdJ„Zdd%ddKd%dLœdndS„ZdodT„Zd%S )pÚExprMetaNameSpacez*Namespace for expressions on a meta level.ÚmetaÚexprr   ÚreturnÚNonec                ó   — |j         | _         d S ©N)Ú_pyexpr©Úselfr   s     ú`/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/polars/expr/meta.pyÚ__init__zExprMetaNameSpace.__init__   s   € Ø”|ˆŒˆˆó    Ústrc                óT   — t          | j        ¦  «                             ¦   «         › d�S ©Nz.meta)r   r   Ú__str__©r   s    r   r%   zExprMetaNameSpace.__str__"   s'   € Ý˜DœLÑ)Ô)×1Ò1Ñ3Ô3Ð:Ð:Ð:Ð:r!   c                óT   — t          | j        ¦  «                             ¦   «         › d�S r$   )r   r   Ú__repr__r&   s    r   r(   zExprMetaNameSpace.__repr__%   s'   € Ý˜DœLÑ)Ô)×2Ò2Ñ4Ô4Ð;Ð;Ð;Ð;r!   Úintc                ó4   — | j                              ¦   «         S r   )r   Ú__hash__r&   s    r   r+   zExprMetaNameSpace.__hash__(   s   € ØŒ|×$Ò$Ñ&Ô&Ð&r!   ÚotherúExprMetaNameSpace | ExprÚboolc                ó@   — | j                              |j         ¦  «        S r   ©r   Úmeta_eq©r   r,   s     r   Ú__eq__zExprMetaNameSpace.__eq__+   s   € ØŒ|×#Ò# E¤MÑ2Ô2Ð2r!   c                ó   — | |k     S r   © r2   s     r   Ú__ne__zExprMetaNameSpace.__ne__.   s   € Ø˜5’=Ð Ð r!   c                ó@   — | j                              |j         ¦  «        S )aX  
        Indicate if this expression is the same as another expression.

        Examples
        --------
        >>> foo_bar = pl.col("foo").alias("bar")
        >>> foo = pl.col("foo")
        >>> foo_bar.meta.eq(foo)
        False
        >>> foo_bar2 = pl.col("foo").alias("bar")
        >>> foo_bar.meta.eq(foo_bar2)
        True
        r0   r2   s     r   ÚeqzExprMetaNameSpace.eq1   s   € ð Œ|×#Ò# E¤MÑ2Ô2Ð2r!   c                ó.   — |                       |¦  «         S )a\  
        Indicate if this expression is NOT the same as another expression.

        Examples
        --------
        >>> foo_bar = pl.col("foo").alias("bar")
        >>> foo = pl.col("foo")
        >>> foo_bar.meta.ne(foo)
        True
        >>> foo_bar2 = pl.col("foo").alias("bar")
        >>> foo_bar.meta.ne(foo_bar2)
        False
        )r8   r2   s     r   ÚnezExprMetaNameSpace.neA   s   € ð —7’7˜5‘>”>Ð!Ð!r!   c                ó4   — | j                              ¦   «         S )zá
        Indicate if this expression expands into multiple expressions.

        Examples
        --------
        >>> e = pl.col(["a", "b"]).name.suffix("_foo")
        >>> e.meta.has_multiple_outputs()
        True
        )r   Úmeta_has_multiple_outputsr&   s    r   Úhas_multiple_outputsz&ExprMetaNameSpace.has_multiple_outputsQ   s   € ð Œ|×5Ò5Ñ7Ô7Ð7r!   c                ó4   — | j                              ¦   «         S )aq  
        Indicate if this expression is a basic (non-regex) unaliased column.

        Examples
        --------
        >>> e = pl.col("foo")
        >>> e.meta.is_column()
        True
        >>> e = pl.col("foo") * pl.col("bar")
        >>> e.meta.is_column()
        False
        >>> e = pl.col(r"^col.*\d+$")
        >>> e.meta.is_column()
        False
        )r   Úmeta_is_columnr&   s    r   Ú	is_columnzExprMetaNameSpace.is_column]   s   € ð  Œ|×*Ò*Ñ,Ô,Ð,r!   c                ó4   — | j                              ¦   «         S )zè
        Indicate if this expression expands to columns that match a regex pattern.

        Examples
        --------
        >>> e = pl.col("^.*$").name.prefix("foo_")
        >>> e.meta.is_regex_projection()
        True
        )r   Úmeta_is_regex_projectionr&   s    r   Úis_regex_projectionz%ExprMetaNameSpace.is_regex_projectiono   s   € ð Œ|×4Ò4Ñ6Ô6Ð6r!   F)Úallow_aliasingrD   c               ó6   — | j                              |¦  «        S )az  
        Indicate if this expression only selects columns (optionally with aliasing).

        This can include bare columns, columns matched by regex or dtype, selectors
        and exclude ops, and (optionally) column/expression aliasing.

        .. versionadded:: 0.20.30

        Parameters
        ----------
        allow_aliasing
            If False (default), any aliasing is not considered to be column selection.
            Set True to allow for column selection that also includes aliasing.

        Examples
        --------
        >>> import polars.selectors as cs
        >>> e = pl.col("foo")
        >>> e.meta.is_column_selection()
        True
        >>> e = pl.col("foo").alias("bar")
        >>> e.meta.is_column_selection()
        False
        >>> e.meta.is_column_selection(allow_aliasing=True)
        True
        >>> e = pl.col("foo") * pl.col("bar")
        >>> e.meta.is_column_selection()
        False
        >>> e = cs.starts_with("foo")
        >>> e.meta.is_column_selection()
        True
        >>> e = cs.starts_with("foo").exclude("foo!")
        >>> e.meta.is_column_selection()
        True
        )r   Úmeta_is_column_selection©r   rD   s     r   Úis_column_selectionz%ExprMetaNameSpace.is_column_selection{   s   € ðH Œ|×4Ò4°^ÑDÔDÐDr!   c               ó6   — | j                              |¦  «        S )a•  
        Indicate if this expression is a literal value (optionally aliased).

        .. versionadded:: 1.14

        Parameters
        ----------
        allow_aliasing
            If False (default), only a bare literal will match.
            Set True to also allow for aliased literals.

        Examples
        --------
        >>> from datetime import datetime
        >>> e = pl.lit(123)
        >>> e.meta.is_literal()
        True
        >>> e = pl.lit(987.654321).alias("foo")
        >>> e.meta.is_literal()
        False
        >>> e = pl.lit(datetime.now()).alias("bar")
        >>> e.meta.is_literal(allow_aliasing=True)
        True
        )r   Úmeta_is_literalrG   s     r   Ú
is_literalzExprMetaNameSpace.is_literal¡   s   € ð2 Œ|×+Ò+¨NÑ;Ô;Ð;r!   T)Úraise_if_undeterminedrL   úLiteral[True]c               ó   — d S r   r5   ©r   rL   s     r   Úoutput_namezExprMetaNameSpace.output_name¼   s   € ØRUÐRUr!   úLiteral[False]ú
str | Nonec               ó   — d S r   r5   rO   s     r   rP   zExprMetaNameSpace.output_name¿   s   € ØSVÐSVr!   c               ó^   — 	 | j                              ¦   «         S # t          $ r |sY dS ‚ w xY w)aa  
        Get the column name that this expression would produce.

        It may not always be possible to determine the output name as that can depend
        on the schema of the context; in that case this will raise `ComputeError` if
        `raise_if_undetermined` is True (the default), or `None` otherwise.

        Examples
        --------
        >>> e = pl.col("foo") * pl.col("bar")
        >>> e.meta.output_name()
        'foo'
        >>> e_filter = pl.col("foo").filter(pl.col("bar") == 13)
        >>> e_filter.meta.output_name()
        'foo'
        >>> e_sum_over = pl.sum("foo").over("groups")
        >>> e_sum_over.meta.output_name()
        'foo'
        >>> e_sum_slice = pl.sum("foo").slice(pl.len() - 10, pl.col("bar"))
        >>> e_sum_slice.meta.output_name()
        'foo'
        >>> pl.len().meta.output_name()
        'len'
        N)r   Úmeta_output_namer   rO   s     r   rP   zExprMetaNameSpace.output_nameÂ   sH   € ð2	Ø”<×0Ò0Ñ2Ô2Ð2øÝð 	ð 	ð 	Ø(ð Ø�t�tØð	øøøs   ‚ ›,ª,N)ÚschemarV   úSchemaDict | Noneú
list[Expr]c               óJ   — d„ | j                              |¦  «        D ¦   «         S )a<  
        Pop the latest expression and return the input(s) of the popped expression.

        Returns
        -------
        list of Expr
            A list of expressions which in most cases will have a unit length.
            This is not the case when an expression has multiple inputs.
            For instance in a `fold` expression.

        Examples
        --------
        >>> e = pl.col("foo") + pl.col("bar")
        >>> first = e.meta.pop()[0]
        >>> first.meta == pl.col("bar")
        True
        >>> first.meta == pl.col("foo")
        False
        c                ó,   — g | ]}t          |¦  «        ‘ŒS r5   r
   )Ú.0Úes     r   ú
<listcomp>z)ExprMetaNameSpace.pop.<locals>.<listcomp>ö   s   € ÐDÐDÐD •	˜!‘”ÐDÐDÐDr!   )r   Úmeta_pop)r   rV   s     r   ÚpopzExprMetaNameSpace.popâ   s)   € ð( EÐD d¤l×&;Ò&;¸FÑ&CÔ&CÐDÑDÔDÐDr!   ú	list[str]c                ó4   — | j                              ¦   «         S )aD  
        Get a list with the root column name.

        Examples
        --------
        >>> e = pl.col("foo") * pl.col("bar")
        >>> e.meta.root_names()
        ['foo', 'bar']
        >>> e_filter = pl.col("foo").filter(pl.col("bar") == 13)
        >>> e_filter.meta.root_names()
        ['foo', 'bar']
        >>> e_sum_over = pl.sum("foo").over("groups")
        >>> e_sum_over.meta.root_names()
        ['foo', 'groups']
        >>> e_sum_slice = pl.sum("foo").slice(pl.len() - 10, pl.col("bar"))
        >>> e_sum_slice.meta.root_names()
        ['foo', 'bar']
        )r   Úmeta_root_namesr&   s    r   Ú
root_nameszExprMetaNameSpace.root_namesø   s   € ð& Œ|×+Ò+Ñ-Ô-Ð-r!   c                óN   — t          | j                             ¦   «         ¦  «        S )aR  
        Undo any renaming operation like `alias` or `name.keep`.

        Examples
        --------
        >>> e = pl.col("foo").alias("bar")
        >>> e.meta.undo_aliases().meta == pl.col("foo")
        True
        >>> e = pl.col("foo").sum().over("bar")
        >>> e.name.keep().meta.undo_aliases().meta == e
        True
        )r   r   Úmeta_undo_aliasesr&   s    r   Úundo_aliaseszExprMetaNameSpace.undo_aliases  s    € õ ˜œ×7Ò7Ñ9Ô9Ñ:Ô:Ð:r!   c                ó*   — t          | j        ¦  «        S )zReturn the original expression.)r   r   r&   s    r   Úas_expressionzExprMetaNameSpace.as_expression  s   € å˜œÑ&Ô&Ð&r!   úpl.Selectorc                ón   — t           j                             | j                             ¦   «         ¦  «        S )a2  
        Try to turn this expression in a selector.

        Raises if the underlying expressions is not a column or selector.

        .. warning::
            This functionality is considered **unstable**. It may be changed
            at any point without it being considered a breaking change.
        )ÚplÚSelectorÚ_from_pyselectorr   Úinto_selectorr&   s    r   Úas_selectorzExprMetaNameSpace.as_selector   s(   € õ Œ{×+Ò+¨D¬L×,FÒ,FÑ,HÔ,HÑIÔIÐIr!   .©ÚformatÚfilerq   úLiteral['binary']Úbytesc               ó   — d S r   r5   ©r   rr   rq   s      r   Ú	serializezExprMetaNameSpace.serialize,  s	   € ð �r!   úLiteral['json']c               ó   — d S r   r5   rv   s      r   rw   zExprMetaNameSpace.serialize1  s   € ØNQÈcr!   úIOBase | str | Pathr   c               ó   — d S r   r5   rv   s      r   rw   zExprMetaNameSpace.serialize4  s	   € ð ˆsr!   ÚbinaryúIOBase | str | Path | Noneúbytes | str | Nonec               ó˜   — |dk    r| j         j        }n'|dk    r| j         j        }nd|›�}t          |¦  «        ‚t	          |||¦  «        S )u§  
        Serialize this expression to a file or string in JSON format.

        Parameters
        ----------
        file
            File path to which the result should be written. If set to `None`
            (default), the output is returned as a string instead.
        format
            The format in which to serialize. Options:

            - `"binary"`: Serialize to binary format (bytes). This is the default.
            - `"json"`: Serialize to JSON format (string).

        See Also
        --------
        Expr.deserialize

        Notes
        -----
        Serialization is not stable across Polars versions: a LazyFrame serialized
        in one Polars version may not be deserializable in another Polars version.

        Examples
        --------
        Serialize the expression into a binary representation.

        >>> expr = pl.col("foo").sum().over("bar")
        >>> bytes = expr.meta.serialize()
        >>> type(bytes)
        <class 'bytes'>

        The bytes can later be deserialized back into an `Expr` object.

        >>> import io
        >>> pl.Expr.deserialize(io.BytesIO(bytes))
        <Expr ['col("foo").sum().over([col("baâ€¦'] at ...>
        r|   Újsonz0`format` must be one of {'binary', 'json'}, got )r   Úserialize_binaryÚserialize_jsonÚ
ValueErrorr   )r   rr   rq   Ú
serializerÚmsgs        r   rw   zExprMetaNameSpace.serialize9  s^   € ðX �XÒÐØœÔ6ˆJˆJØ�vÒÐØœÔ4ˆJˆJàQÀvÐQÐQˆCÝ˜S‘/”/Ð!å& z°4¸Ñ@Ô@Ð@r!   c                ó   — d S r   r5   ©r   rr   s     r   Ú
write_jsonzExprMetaNameSpace.write_jsono  s   € Ø36°3r!   c                ó   — d S r   r5   r‡   s     r   rˆ   zExprMetaNameSpace.write_jsonr  s   € Ø=@¸Sr!   z;`meta.write_json` was renamed; use `meta.serialize` insteadc                ó0   — |                       |d¬¦  «        S )z‹
        Write expression to json.

        .. deprecated:: 0.20.11
            This method has been renamed to :meth:`serialize`.
        r€   rp   )rw   r‡   s     r   rˆ   zExprMetaNameSpace.write_jsonu  s   € ð �~Š~˜d¨6ˆ~Ñ2Ô2Ð2r!   )Úreturn_as_stringrV   r‹   úNone | SchemaDictc               ó   — d S r   r5   ©r   r‹   rV   s      r   Útree_formatzExprMetaNameSpace.tree_format  s	   € ð ˆsr!   c               ó   — d S r   r5   rŽ   s      r   r�   zExprMetaNameSpace.tree_format‡  s	   € ð ˆcr!   c               ó`   — | j                              |¦  «        }|r|S t          |¦  «         dS )am  
        Format the expression as a tree.

        Parameters
        ----------
        return_as_string:
            If True, return as string rather than printing to stdout.
        schema
            Optionally provide a schema for the expression tree formatter.
            This is a mapping of column names to their data types. If provided,
            it may be used to enhance the tree formatting with type information.

        Examples
        --------
        >>> e = (pl.col("foo") * pl.col("bar")).sum().over(pl.col("ham")) / 2
        >>> e.meta.tree_format(return_as_string=True)  # doctest: +SKIP
        N)r   Úmeta_tree_formatÚprint)r   r‹   rV   Úss       r   r�   zExprMetaNameSpace.tree_formatŒ  s6   € ð( ŒL×)Ò)¨&Ñ1Ô1ˆØð 	ØˆHå�!‰HŒHˆHØ�4r!   )g      0@g      (@)ÚshowÚoutput_pathÚ
raw_outputÚfigsizerV   r•   r–   ústr | Path | Noner—   r˜   útuple[float, float]c               ó^   — | j                              |¦  «        }t          |||||¬¦  «        S )a¿  
        Format the expression as a Graphviz graph.

        Note that Graphviz must be installed to render the visualization (if not
        already present, you can download it here: `<https://graphviz.org/download>`_).

        Parameters
        ----------
        show
            Show the figure.
        output_path
            Write the figure to disk.
        raw_output
            Return dot syntax. This cannot be combined with `show` and/or `output_path`.
        figsize
            Passed to matplotlib if `show == True`.
        schema
            Optionally provide a schema for the expression tree formatter.
            This is a mapping of column names to their data types. If provided,
            it may be used to enhance the tree formatting with type information.

        Examples
        --------
        >>> e = (pl.col("foo") * pl.col("bar")).sum().over(pl.col("ham")) / 2
        >>> e.meta.show_graph()  # doctest: +SKIP
        )Údotr•   r–   r—   r˜   )r   Úmeta_show_graphr	   )r   r•   r–   r—   r˜   rV   rœ   s          r   Ú
show_graphzExprMetaNameSpace.show_graph§  s@   € ðF Œl×*Ò*¨6Ñ2Ô2ˆÝ ØØØ#Ø!Øð
ñ 
ô 
ð 	
r!   c                óZ   — t          | j                             |j        ¦  «        ¦  «        S r   )r   r   Úmeta_replace_elementr   s     r   Ú_replace_elementz"ExprMetaNameSpace._replace_elementÓ  s"   € Ý˜œ×:Ò:¸4¼<ÑHÔHÑIÔIÐIr!   )r   r   r   r   )r   r"   )r   r)   )r,   r-   r   r.   )r   r.   )rD   r.   r   r.   )rL   rM   r   r"   )rL   rQ   r   rR   )rL   r.   r   rR   )rV   rW   r   rX   )r   r`   )r   r   )r   ri   ).)rr   r   rq   rs   r   rt   )rr   r   rq   rx   r   r"   )rr   rz   rq   r   r   r   r   )rr   r}   rq   r   r   r~   )rr   r   r   r"   )rr   rz   r   r   )rr   r}   r   rR   )r‹   rQ   rV   rŒ   r   r   )r‹   rM   rV   rŒ   r   r"   )r‹   r.   rV   rŒ   r   rR   )r•   r.   r–   r™   r—   r.   r˜   rš   rV   rŒ   r   rR   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	_accessorr    r%   r(   r+   r3   r6   r8   r:   r=   r@   rC   rH   rK   r   rP   r_   rc   rf   rh   ro   rw   rˆ   r   r�   rž   r¡   r5   r!   r   r   r      sþ  € € € € € Ø4Ð4à€Ið$ð $ð $ð $ð;ð ;ð ;ð ;ð<ð <ð <ð <ð'ð 'ð 'ð 'ð3ð 3ð 3ð 3ð!ð !ð !ð !ð3ð 3ð 3ð 3ð "ð "ð "ð "ð 
8ð 
8ð 
8ð 
8ð-ð -ð -ð -ð$
7ð 
7ð 
7ð 
7ð =Bð $Eð $Eð $Eð $Eð $Eð $EðL 49ð <ð <ð <ð <ð <ð <ð6 ØDHÐUÐUÐUÐUÐUñ „XØUàØVÐVÐVñ „XØVà;?ð ð ð ð ð ð ð@ 26ð Eð Eð Eð Eð Eð Eð,.ð .ð .ð .ð*;ð ;ð ;ð ;ð'ð 'ð 'ð 'ð
Jð 
Jð 
Jð 
Jð àðØ?Bðð ð ð ð ñ „Xðð ØQÐQÐQÐQñ „XØQààJMðð ð ð ð ñ „Xðð ,0ð4Að '/ð	4Að 4Að 4Að 4Að 4Að 4Aðl Ø6Ð6Ð6Ð6ñ „XØ6àØ@Ð@Ð@ñ „XØ@à€ZÐMÑNÔNð3ð 3ð 3ð 3ñ OÔNð3ð ð ,/Ø$(ð	ð ð ð ð ñ „Xðð àNRðð ð ð ð ñ „Xðð
 +0ÈTðð ð ð ð ð ð< Ø)-Ø Ø'3Ø$(ð*
ð *
ð *
ð *
ð *
ð *
ðXJð Jð Jð Jð Jð Jr!   r   )!Ú
__future__r   Útypingr   r   r   Úpolars._reexportÚ	_reexportrk   Úpolars._utils.deprecationr   Úpolars._utils.serder   Úpolars._utils.variousr	   Úpolars._utils.wrapr   Úpolars.exceptionsr   ÚsysÚior   Úpathlibr   Úpolarsr   Úpolars._typingr   r   Úversion_infoÚwarningsÚtyping_extensionsr   r5   r!   r   ú<module>r¸      s{  ðØ "Ð "Ð "Ð "Ð "Ð "à 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3à Ð Ð Ð Ð Ð Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø (Ð (Ð (Ð (Ð (Ð (Ø *Ð *Ð *Ð *Ð *Ð *àð 1Ø€J€J€JØÐÐÐÐÐØÐÐÐÐÐàÐÐÐÐÐØ>Ð>Ð>Ð>Ð>Ð>Ð>Ð>à
Ô˜7Ò"Ð"Ø'Ð'Ð'Ð'Ð'Ð'Ð'à0Ð0Ð0Ð0Ð0Ð0ðzJð zJð zJð zJð zJñ zJô zJð zJð zJð zJr!   