pola-rs/polars · error · AssertionError

Series are equal (but are expected not to be)

Error message

Series are equal (but are expected not to be)

What it means

assert_series_not_equal wraps assert_series_equal in try/except; if the inner comparison does NOT raise, the series match and the else branch raises this AssertionError. Means the negative test failed because left and right are equal under the configured check_dtypes/names/order/exact and tolerances.

Source

Thrown at py-polars/src/polars/testing/asserts/series.py:228

    _assert_correct_input_type(left, right)
    try:
        assert_series_equal(
            left=left,
            right=right,
            check_dtypes=check_dtypes,
            check_names=check_names,
            check_order=check_order,
            check_exact=check_exact,
            rel_tol=rel_tol,
            abs_tol=abs_tol,
            categorical_as_str=categorical_as_str,
        )
    except AssertionError:
        return
    else:
        msg = "Series are equal (but are expected not to be)"
        raise AssertionError(msg)

View on GitHub (pinned to 5d8ebabf11)

Solutions

  1. Use `assert_series_equal` if equality is expected; otherwise change the inputs so the series actually differ.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at py-polars/src/polars/testing/asserts/series.py:219 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pola-rs/polars@5d8ebabf11 (2026-08-19). Data as JSON: /api/errors/7ff769fec3f246c7. Report an issue: GitHub.