{"record":{"id":"7ff769fec3f246c7","repo":"pola-rs/polars","slug":"series-are-equal-but-are-expected-not-to-be","errorCode":null,"errorMessage":"Series are equal (but are expected not to be)","messagePattern":"Series are equal \\(but are expected not to be\\)","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/testing/asserts/series.py","lineNumber":228,"sourceCode":"\n    _assert_correct_input_type(left, right)\n    try:\n        assert_series_equal(\n            left=left,\n            right=right,\n            check_dtypes=check_dtypes,\n            check_names=check_names,\n            check_order=check_order,\n            check_exact=check_exact,\n            rel_tol=rel_tol,\n            abs_tol=abs_tol,\n            categorical_as_str=categorical_as_str,\n        )\n    except AssertionError:\n        return\n    else:\n        msg = \"Series are equal (but are expected not to be)\"\n        raise AssertionError(msg)\n","sourceCodeStart":210,"sourceCodeEnd":229,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/testing/asserts/series.py#L210-L229","documentation":"assert_series_not_equal asserts that two Series differ; when assert_series_equal succeeds (the series are actually equal) it raises AssertionError 'Series are equal (but are expected not to be)' — a test-helper inversion, not a data error.","triggerScenarios":"Comparing two Series that turn out identical, e.g. timezone conversion that results in the same displayed values, or comparisons where check_names/check_dtype defaults ignore the actual difference.","commonSituations":"Timezone tests where both series render the same instants; order-sensitive tests where data was already sorted; empty-series comparisons where both are empty.","solutions":["Print/compare both series to verify a difference actually exists.","Adjust the code expected to mutate the series so it truly changes values.","Relax/tighten equality options (check_names=False, check_dtype=False) if the intended distinction lies outside the compared aspects — only when semantically correct."],"exampleFix":"# before\ns2 = s.cast(pl.Int64)  # s already Int64 -> equal\nassert_series_not_equal(s, s2)\n\n# after\ns2 = s + 1\nassert_series_not_equal(s, s2)","handlingStrategy":"validation","validationCode":"if s1.equals(s2):\n    pytest.fail(\"series unexpectedly equal; test premise invalid\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify mutations actually change the data (s2[0] != s1[0])","Check names/dtypes explicitly when those are the intended difference","Beware comparing empty or timezone-shifted series that render identically"],"tags":["polars","testing","assertion","series-equality"],"backgroundTag":"unexpected-equal-values","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"}