# RuntimeWarning：在 sqrt 中遇到无效值

- **ID:** `python/numpy-invalid-value-encountered`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

对负数应用 np.sqrt，产生 NaN。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   np.sqrt(np.clip(arr, 0, None))
   ```
2. **** (90% 成功率)
   ```
   np.where(arr >= 0, np.sqrt(arr), np.nan)
   ```

## 无效尝试

- **** — Hides NaN; downstream results wrong (80% 失败率)
- **** — Changes math silently; loses sign info (70% 失败率)
