{
  "id": "python/numpy-overflow-uint8",
  "signature": "RuntimeWarning: overflow encountered in scalar multiply",
  "signature_zh": "RuntimeWarning: 标量乘法时发生溢出",
  "regex": "RuntimeWarning:\\ overflow\\ encountered\\ in\\ scalar\\ multiply",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Arithmetic on a fixed-width integer dtype (e.g., uint8) that overflows the dtype's range. NumPy wraps around silently and emits a RuntimeWarning.",
  "root_cause_type": "generic",
  "root_cause_zh": "对定宽整数 dtype（如 uint8）进行算术运算时超出其范围。NumPy 会静默回绕并发出 RuntimeWarning。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Silences warning but overflow still wraps to wrong values",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Raises FloatingPointError but doesn't fix the underlying dtype",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "arr = arr.astype(np.int64) before arithmetic",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Use np.multiply(a, b, dtype=np.int64, casting='unsafe')",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}