{"record":{"id":"7fcab3ba1940ad9c","repo":"roboflow/supervision","slug":"both-elements-in-resolution-must-be-i","errorCode":null,"errorMessage":"\n            Both elements in resolution must be integers.\n            Got types ({type(w)}, {type(h)})\n            ","messagePattern":"\n            Both elements in resolution must be integers\\.\n            Got types \\((.+?), (.+?)\\)\n            ","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/validators/__init__.py","lineNumber":344,"sourceCode":"    remove_in=\"0.31.0\",\n)\ndef validate_keypoints_fields(\n    xy: Any, class_id: Any, confidence: Any, data: dict[str, Any]\n) -> None:\n    void(xy, class_id, confidence, data)\n\n\ndef _validate_resolution(resolution: Any) -> tuple[int, int]:\n    if not (isinstance(resolution, tuple) and len(resolution) == 2):\n        raise ValueError(\n            f\"\"\"\n            resolution must be a tuple of two integers, got\n            {type(resolution)} with value {resolution}\n            \"\"\"\n        )\n    w, h = resolution\n    if not (isinstance(w, int) and isinstance(h, int)):\n        raise ValueError(\n            f\"\"\"\n            Both elements in resolution must be integers.\n            Got types ({type(w)}, {type(h)})\n            \"\"\"\n        )\n    if w <= 0 or h <= 0:\n        raise ValueError(\n            f\"Both dimensions in resolution must be positive. Got ({w}, {h}).\"\n        )\n    return w, h\n\n\n@deprecated(  # type: ignore[untyped-decorator]\n    target=_validate_resolution,\n    deprecated_in=\"0.29.0\",\n    remove_in=\"0.32.0\",\n)\ndef validate_resolution(resolution: Any) -> tuple[int, int]:","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/validators/__init__.py#L326-L362","documentation":"Raised by supervision.validators._validate_resolution when resolution is a 2-tuple but one or both elements are not Python ints (e.g. floats, numpy scalars, or strings). The library requires exact int types because downstream indexing/geometry assumes integer pixel dimensions.","triggerScenarios":"Passing resolution=(1920.0, 1080.0) after float math; passing np.int64 scalars from array operations like frame.shape-derived values wrapped in numpy types; passing ('1920', 1080).","commonSituations":"Computing scaled resolutions with float arithmetic (w * 0.5) and forgetting round(); values coming out of numpy arrays or config parsers (yaml/json give ints usually, but computed configs give floats).","solutions":["Coerce to int: resolution=(int(w), int(h)).","Use integer division or round when scaling: resolution=(w // 2, h // 2).","Validate config values at load time if resolution comes from user-supplied YAML/JSON."],"exampleFix":"# before\nresolution = (w * scale, h * scale)  # floats -> ValueError\n\n# after\nresolution = (round(w * scale), round(h * scale))","handlingStrategy":"validation","validationCode":"resolution = (int(resolution[0]), int(resolution[1]))\nobj = SomeAPI(resolution=resolution)","typeGuard":"def is_int_resolution(resolution: tuple[Any, Any]) -> bool:\n    return all(isinstance(v, int) for v in resolution)","tryCatchPattern":null,"preventionTips":["Coerce with int()/round() after any float math.","Validate resolution at config-load time when it comes from user input.","Watch for numpy scalar types leaking from array operations."],"tags":["resolution","validation","type","configuration"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}