{"record":{"id":"3ca10c35cef7500f","repo":"pandas-dev/pandas","slug":"check-like-must-be-false-if-check-index-is-false","errorCode":null,"errorMessage":"check_like must be False if check_index is False","messagePattern":"check_like must be False if check_index is False","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/_testing/asserters.py","lineNumber":1116,"sourceCode":"        right_index_dtypes = (\n            [right.index.dtype]\n            if right.index.nlevels == 1\n            else cast(\"MultiIndex\", right.index).dtypes\n        )\n        check_exact_index = all(\n            dtype.kind in \"iu\" for dtype in left_index_dtypes\n        ) or all(dtype.kind in \"iu\" for dtype in right_index_dtypes)\n    elif check_exact is lib.no_default:\n        check_exact = False\n        check_exact_index = False\n    else:\n        check_exact_index = check_exact\n\n    rtol = rtol if rtol is not lib.no_default else 1.0e-5\n    atol = atol if atol is not lib.no_default else 1.0e-8\n\n    if not check_index and check_like:\n        raise ValueError(\"check_like must be False if check_index is False\")\n\n    # instance validation\n    _check_isinstance(left, right, Series)\n\n    if check_series_type:\n        assert_class_equal(left, right, obj=obj)\n\n    # length comparison\n    if len(left) != len(right):\n        msg1 = f\"{len(left)}, {left.index}\"\n        msg2 = f\"{len(right)}, {right.index}\"\n        raise_assert_detail(obj, \"Series length are different\", msg1, msg2)\n\n    if check_flags:\n        assert left.flags == right.flags, f\"{left.flags!r} != {right.flags!r}\"\n\n    if check_index:\n        # GH #38183","sourceCodeStart":1098,"sourceCodeEnd":1134,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/_testing/asserters.py#L1098-L1134","documentation":"Raised by assert_series_equal (asserters.py:1115-1116) when the caller passes check_like=True together with check_index=False. check_like instructs the assertion to reindex/reorder before comparing (which requires reading the index), so disabling index checking makes check_like meaningless and contradictory — hence the explicit ValueError.","triggerScenarios":"Calling assert_series_equal(left, right, check_index=False, check_like=True). check_like=True normally means 'ignore index order by reindexing right onto left', which is nonsensical when the index is not being checked at all.","commonSituations":"Layering multiple check_* flags from different test helpers without reconciling them; copy-pasting an assert call and toggling check_index=False to silence an index mismatch, while check_like=True was already set.","solutions":["If you want to compare values ignoring index order, keep check_index=True (default) and set check_like=True.","If you truly want to skip the index entirely, set check_like=False (or omit it).","Re-read the assert_series_equal docstring for the precise meaning of each flag combination."],"exampleFix":"# before\nassert_series_equal(s1, s2, check_index=False, check_like=True)\n\n# after — compare values ignoring index order\nassert_series_equal(s1, s2, check_like=True)\n# or — skip index entirely\nassert_series_equal(s1, s2, check_index=False, check_like=False)","handlingStrategy":"validation","validationCode":"check_index = True  # or False\ncheck_like = True   # or False\nif not check_index and check_like:\n    raise ValueError('check_like=True requires check_index=True')\nassert_series_equal(left, right, check_index=check_index, check_like=check_like)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep check_like and check_index consistent in shared test helpers.","Document the intended flag combination at each assert call.","Treat the two flags as coupled: check_like implies the index matters."],"tags":["testing","assertion","assert-series-equal","argument-validation","valueerror"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}