Skip to content

Commit d7b398b

Browse files
Fix APIv2 comparison (#2361)
1 parent 328db67 commit d7b398b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: patch
2+
changes:
3+
fixed:
4+
- Comparison to APIv2 correctly compares 0s.

policyengine_api/jobs/calculate_economy_simulation_job.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,7 @@ def is_similar(x, y, parent_name: str = "") -> bool:
484484

485485
# Handle numeric values
486486
if isinstance(x, (int, float)):
487-
if x == 0:
488-
close = y == 0
489-
else:
490-
close = (abs(y - x) / abs(x) < 0.01) or (abs(y - x) < 1e-2)
487+
close = (abs(y - x) < 1e-2) or (abs(y - x) / abs(x) < 0.01)
491488
if not close:
492489
print(f"Not close: {x} vs {y} in {parent_name}")
493490
return close

0 commit comments

Comments
 (0)