# AssertionError: assert nan == 1.0

- **ID:** `python/pytest-approx-nan`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

使用pytest.approx比较时，实际值为NaN，导致比较失败。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.6 | active | — | — |

## Workarounds

1. **** (85% success)
   ```
   import math
if math.isnan(actual):
    pytest.fail('Actual value is NaN')
else:
    assert actual == pytest.approx(expected)
   ```
2. **** (90% success)
   ```
   def assert_float_equal(actual, expected):
    if math.isnan(actual) or math.isnan(expected):
        assert math.isnan(actual) == math.isnan(expected)
    else:
        assert actual == pytest.approx(expected)
   ```

## Dead Ends

- **** — pytest.approx不支持NaN，需单独处理。 (60% fail)
- **** — 可能掩盖计算错误。 (90% fail)
