
    ˀhi#              	      X   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 d dlmZ d dlmZ  ed	d
d      dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 ddZddZ ed	d
d      dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zy)    )annotations)cast)deprecate_renamed_parameter)	DataFrame)InvalidOperationError)	LazyFrame)_assert_series_values_equal)raise_assertion_errorcheck_dtypecheck_dtypesz0.20.31)versionTFgh㈵>g:0yE>)check_row_ordercheck_column_orderr   check_exactrtolatolcategorical_as_strc          
     ~   d}	t        | |      }
|
rdnd}t        | ||||       |
r | j                         |j                         }} t        t        |       t        t        |      }} | j
                  |j
                  k7  r"t        |d| j
                  |j
                         |st        | |      \  } }| j                  D ]7  }| j                  |      |j                  |      }}	 t        ||d||||       9 y	# t        $ r9}t        |d||j                         |j                         |       Y d	}~xd	}~ww xY w)
a  
    Assert that the left and right frame are equal.

    Raises a detailed `AssertionError` if the frames differ.
    This function is intended for use in unit tests.

    .. versionchanged:: 0.20.31
        The `check_dtype` parameter was renamed `check_dtypes`.

    Parameters
    ----------
    left
        The first DataFrame or LazyFrame to compare.
    right
        The second DataFrame or LazyFrame to compare.
    check_row_order
        Requires row order to match.
    check_column_order
        Requires column order to match.
    check_dtypes
        Requires data types to match.
    check_exact
        Requires float values to match exactly. If set to `False`, values are considered
        equal when within tolerance of each other (see `rtol` and `atol`).
        Only affects columns with a Float data type.
    rtol
        Relative tolerance for inexact checking. Fraction of values in `right`.
    atol
        Absolute tolerance for inexact checking.
    categorical_as_str
        Cast categorical columns to string before comparing. Enabling this helps
        compare columns that do not share the same string cache.

    See Also
    --------
    assert_series_equal
    assert_frame_not_equal

    Notes
    -----
    When using pytest, it may be worthwhile to shorten Python traceback printing
    by passing `--tb=short`. The default mode tends to be unhelpfully verbose.
    More information in the
    `pytest docs <https://docs.pytest.org/en/latest/how-to/output.html#modifying-python-traceback-printing>`_.

    Examples
    --------
    >>> from polars.testing import assert_frame_equal
    >>> df1 = pl.DataFrame({"a": [1, 2, 3]})
    >>> df2 = pl.DataFrame({"a": [1, 5, 3]})
    >>> assert_frame_equal(df1, df2)
    Traceback (most recent call last):
    ...
    AssertionError: DataFrames are different (value mismatch for column 'a')
    [left]:  [1, 2, 3]
    [right]: [1, 5, 3]
    T
LazyFrames
DataFrames)r   r   objectsznumber of rows does not match)check_orderr   r   r   r   zvalue mismatch for column )causeN)_assert_correct_input_type_assert_frame_schema_equalcollectr   r   heightr
   _sort_dataframescolumns
get_columnr	   AssertionErrorto_list)leftrightr   r   r   r   r   r   r   __tracebackhide__lazyr   cs_lefts_rightexcs                   x/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/polars/testing/asserts/frame.pyassert_frame_equalr,      s<   L %dE2D"lG-! llnemmoey$'i)?%D{{ell"4dkk5<<	
 &tU3e\\ //!,e.>.>q.A	' '#5  	!,QE2 ! 	s   %C::	D</D77D<c                    d}t        | t              rt        |t              ryt        | t              rt        |t              ryt        ddt	        |       j
                  t	        |      j
                         y )NTFinputszunexpected input types)
isinstancer   r   r
   type__name__)r#   r$   r%   s      r+   r   r      s^     $	"z%'C	D)	$E9)E$JK  		
    c                  d}| j                         |j                         }}||k(  ry |j                         |j                         k7  rY|D cg c]	  }||vs| c}x}	rd|	d|d d  d}
t        |
      |D cg c]	  }||vs| }}d|d|d d  d}
t        |
      |r+t        |      t        |      }}||k7  rd}t	        ||||       |r/t        |      t        |      }}|s||k7  rd	}t	        ||||       y y y c c}w c c}w )
NTzcolumns z	 in left z, but not in rightz
 in right z, but not in leftz!columns are not in the same orderzdtypes do not match)collect_schemakeysr!   listr
   dict)r#   r$   r   r   r   r%   left_schemaright_schemar'   left_not_rightmsgright_not_leftleft_columnsright_columnsdetailleft_schema_dictright_schema_dicts                    r+   r   r      sT     $ 3 3 5u7K7K7MK l" \..00)4NA8MaNN>N^.i~EWXC %%)5NA+9MaNNN^.j"FWXC %%&*;&7l9Km=(8F!'6<O.2;.?lAS+!15F!F*F!'63CEVW "G  O Os   	DD<	DDc                    | j                   }	 | j                  |      } |j                  |      }| |fS # t        $ r}d}t        |      |d }~ww xY w)NzCcannot set `check_row_order=False` on frame with unsortable columns)r   sortr   	TypeError)r#   r$   byr*   r<   s        r+   r   r      sY    	B&yy}

2 ; ! &Sn#%&s   "4 	AAAc                   d}	t        | |      }
	 t        | ||||||||	       |
rdnd}| d}t        |      # t        $ r Y yw xY w)a  
    Assert that the left and right frame are **not** equal.

    This function is intended for use in unit tests.

    .. versionchanged:: 0.20.31
        The `check_dtype` parameter was renamed `check_dtypes`.

    Parameters
    ----------
    left
        The first DataFrame or LazyFrame to compare.
    right
        The second DataFrame or LazyFrame to compare.
    check_row_order
        Requires row order to match.
    check_column_order
        Requires column order to match.
    check_dtypes
        Requires data types to match.
    check_exact
        Requires float values to match exactly. If set to `False`, values are considered
        equal when within tolerance of each other (see `rtol` and `atol`).
        Only affects columns with a Float data type.
    rtol
        Relative tolerance for inexact checking. Fraction of values in `right`.
    atol
        Absolute tolerance for inexact checking.
    categorical_as_str
        Cast categorical columns to string before comparing. Enabling this helps
        compare columns that do not share the same string cache.

    See Also
    --------
    assert_frame_equal
    assert_series_not_equal

    Examples
    --------
    >>> from polars.testing import assert_frame_not_equal
    >>> df1 = pl.DataFrame({"a": [1, 2, 3]})
    >>> df2 = pl.DataFrame({"a": [1, 2, 3]})
    >>> assert_frame_not_equal(df1, df2)
    Traceback (most recent call last):
    ...
    AssertionError: DataFrames are equal (but are expected not to be)
    T)	r#   r$   r   r   r   r   r   r   r   r   r   z' are equal (but are expected not to be)N)r   r,   r!   )r#   r$   r   r   r   r   r   r   r   r%   r&   r   r<   s                r+   assert_frame_not_equalrH      sv    x %dE2D"1+%#1
	
 #',L	@AS!!  s   : 	AAN)r#   DataFrame | LazyFramer$   rI   r   boolr   rJ   r   rJ   r   rJ   r   floatr   rK   r   rJ   returnNone)r#   rI   r$   rI   rL   rJ   )r#   rI   r$   rI   r   rJ   r   rJ   r   strrL   rM   )r#   r   r$   r   rL   ztuple[DataFrame, DataFrame])
__future__r   typingr   polars._utils.deprecationr   polars.dataframer   polars.exceptionsr   polars.lazyframer   polars.testing.asserts.seriesr	   polars.testing.asserts.utilsr
   r,   r   r   r   rH    r2   r+   <module>rX      s   "  A & 3 & E > ]NIN
 !#$q
q q 	q
 q q q q q q 
q Oqh


(=
	
$$X
$X $X 	$X
 $X $X 
$XN ]NIN
 !#$O"
O" O" 	O"
 O" O" O" O" O" O" 
O" OO"r2   