polars_python/testing/
frame.rs

1use polars_testing::asserts::{DataFrameEqualOptions, assert_dataframe_equal};
2use pyo3::prelude::*;
3
4use crate::PyDataFrame;
5use crate::error::PyPolarsErr;
6
7#[pyfunction]
8#[pyo3(signature = (left, right, *, check_row_order, check_column_order, check_dtypes, check_exact, rtol, atol, categorical_as_str))]
9pub fn assert_dataframe_equal_py(
10    left: &PyDataFrame,
11    right: &PyDataFrame,
12    check_row_order: bool,
13    check_column_order: bool,
14    check_dtypes: bool,
15    check_exact: bool,
16    rtol: f64,
17    atol: f64,
18    categorical_as_str: bool,
19) -> PyResult<()> {
20    let left_df = &left.df;
21    let right_df = &right.df;
22
23    let options = DataFrameEqualOptions {
24        check_row_order,
25        check_column_order,
26        check_dtypes,
27        check_exact,
28        rtol,
29        atol,
30        categorical_as_str,
31    };
32
33    assert_dataframe_equal(left_df, right_df, options).map_err(|e| PyPolarsErr::from(e).into())
34}