{"record":{"id":"964a84226c525998","repo":"pola-rs/polars","slug":"frame","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"panic","errorClass":"panic","httpStatus":null,"severity":"error","filePath":"crates/polars-testing/src/asserts/frame.rs","lineNumber":49,"sourceCode":"///     .with_check_row_order(false);\n/// assert_dataframe_equal!(&df1, &df2, options);\n/// ```\n///\n/// # Panics\n///\n/// Panics when the DataFrames are not equal according to the specified comparison criteria.\n///\n#[macro_export]\nmacro_rules! assert_dataframe_equal {\n    ($left:expr, $right:expr $(, $options:expr)?) => {\n        #[allow(unused_assignments)]\n        #[allow(unused_mut)]\n        let mut options = $crate::asserts::DataFrameEqualOptions::default();\n        $(options = $options;)?\n\n        match $crate::asserts::assert_dataframe_equal($left, $right, options) {\n            Ok(_) => {},\n            Err(e) => panic!(\"{}\", e),\n        }\n    };\n}\n\n#[cfg(test)]\nmod tests {\n    #[allow(unused_imports)]\n    use polars_core::prelude::*;\n\n    // Testing default struct implementation\n    #[test]\n    fn test_dataframe_equal_options() {\n        let options = crate::asserts::DataFrameEqualOptions::default();\n\n        assert!(options.check_row_order);\n        assert!(options.check_column_order);\n        assert!(options.check_dtypes);\n        assert!(!options.check_exact);","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-testing/src/asserts/frame.rs#L31-L67","documentation":"The assert_frame_equal macro in polars-testing panics with the full mismatch report produced by assert_dataframe_equal when two DataFrames are not equal. The panic message ('{}') is the formatted DataFrameEqualError, which describes which columns, dtypes, or cell values differ. This is a test-side assertion, not a runtime data error.","triggerScenarios":"Invoking assert_frame_equal!(left, right) (optionally with options) where the two frames differ in shape, column names, dtypes, or cell values.","commonSituations":"Unit tests comparing a computed frame against an expected fixture; float rounding differences; schema drift after a Polars version upgrade; column ordering changes.","solutions":["Inspect the printed mismatch report to find the differing column/dtype/value","Use DataFrameEqualOptions (e.g. check_dtype: false, float tolerance/check_row_order) to relax non-essential checks","Round or cast float columns before comparison, or sort both frames if ordering is irrelevant"],"exampleFix":"// before\nassert_frame_equal!(result, expected);\n// after\nassert_frame_equal!(\n    result,\n    expected,\n    DataFrameEqualOptions::default().with_float_cmp(rust_decimal::Decimal::from_f64_retain(1e-6).unwrap())\n);","handlingStrategy":"try-catch","validationCode":"// Rust: pre-check shapes before asserting\nassert_eq!(left.height(), right.height());\nassert_eq!(left.width(), right.width());\nassert_eq!(left.get_column_names(), right.get_column_names());","typeGuard":null,"tryCatchPattern":"// in tests, prefer should_panic with a message fragment\n#[test]\n#[should_panic(expected = \"dtypes are not equal\")]\nfn mismatched_dtypes_fail() { assert_frame_equal!(a, b); }","preventionTips":["Normalize floats (round/cast) before comparing frames","Relax non-essential checks via DataFrameEqualOptions (dtype, row order)","Compare against committed fixtures regenerated after Polars upgrades"],"tags":["rust","testing","assertions","dataframe"],"backgroundTag":"internal-invariant-violation","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}