{
  "id": "python/numpy-axis-out-of-bounds",
  "signature": "numpy.exceptions.AxisError: axis 2 is out of bounds for array of dimension 2",
  "signature_zh": "numpy.exceptions.AxisError: 轴 2 超出维度为 2 的数组范围",
  "regex": "numpy\\.exceptions\\.AxisError:\\ axis\\ 2\\ is\\ out\\ of\\ bounds\\ for\\ array\\ of\\ dimension\\ 2",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Passing an axis argument larger than array.ndim - 1 to functions like np.sum, np.mean, np.concatenate. Often from assuming 3-D input.",
  "root_cause_type": "generic",
  "root_cause_zh": "向 np.sum、np.mean、np.concatenate 等函数传入大于 array.ndim - 1 的 axis 参数。常因假设输入为 3 维。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Same AxisError",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changes semantics, not what you want",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "np.sum(arr, axis=-1)  # last axis regardless of ndim",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "assert arr.ndim >= 3 or use np.sum(arr, axis=tuple(range(arr.ndim)))",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-04",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}