{
  "id": "python/numpy-nan-comparison",
  "signature": "AssertionError: Arrays are not equal (mismatch 100.0%) x: array([nan]) y: array([nan])",
  "signature_zh": "AssertionError: 数组不相等（不匹配率 100.0%）x: array([nan]) y: array([nan])",
  "regex": "AssertionError:\\ Arrays\\ are\\ not\\ equal\\ \\(mismatch\\ 100\\.0%\\)\\ x:\\ array\\(\\[nan\\]\\)\\ y:\\ array\\(\\[nan\\]\\)",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "np.testing.assert_array_equal treats NaN == NaN as False by default. Also affects boolean masks built from NaN comparisons.",
  "root_cause_type": "generic",
  "root_cause_zh": "np.testing.assert_array_equal 默认将 NaN == NaN 视为 False。也会影响基于 NaN 比较构建的布尔掩码。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Also returns False for NaN",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "NaN != NaN, returns False",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "np.testing.assert_array_equal(a, b, strict=False) or use np.testing.assert_allclose(a, b, equal_nan=True)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "mask = (a == b) | (np.isnan(a) & np.isnan(b)); assert mask.all()",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}