# E   AssertionError: assert {'a': 1.0, 'b': 2.0000000001} == {'a': 1.0, 'b': 2.0}
E     Omitting 1 identical items, use -vv to show
E     Differing items:
E     {'b': 2.0000000001 != 2.0}

- **ID:** `python/assertionerror-dict-approx-ordering`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Float comparison inside nested dict/list structures fails because pytest.approx does not recurse into containers by default when comparing with ==; you must use pytest.approx on the whole structure or per-value.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   from pytest import approx
assert result == approx({'a': 1.0, 'b': 2.0}, rel=1e-6)
# approx recurses into dicts and lists
   ```
2. **** (85% success)
   ```
   def approx_dict(d, rel=1e-6):
    return {k: approx(v, rel=rel) if isinstance(v, float) else v for k, v in d.items()}
assert result == approx_dict({'a': 1.0, 'b': 2.0})
   ```

## Dead Ends

- **** — Rounding both sides may still differ if the underlying computation drifts beyond the rounding boundary; it hides but does not fix the comparison semantics. (60% fail)
- **** — String formatting is locale- and precision-sensitive; dict ordering and repr differences cause flaky failures. (90% fail)
