Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Dan D'Avella <[email protected]>
  • Loading branch information
clavedeluna and drdavella committed Apr 8, 2024
1 parent 0676f0c commit b47b0d6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core_codemods/docs/pixee_python_fix-float-equality.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
In most programming languages, floating point arithmetic is imprecise due to the way floating point numbers are stored as binary representations. Moreover, the result of calculations with floats can vary based on when rounding happens. Using equality or inequality to compare floats or their operations will almost always be imprecise and lead to bugs.

For these reasons, this codemod changes any operations involving equality or inequality with floats to the recommended `math.isclose` function. We have explicitly defined the default parameters `rel_tol=1e-09` and `abs_tol=0.0` as a starting point for you to consider depending on your calculation needs.
For these reasons, this codemod changes any operations involving equality or inequality with floats to the recommended `math.isclose` function. This codemod uses the default parameter values `rel_tol=1e-09` and `abs_tol=0.0` but makes them explicit as a starting point for you to consider depending on your calculation needs.

Our changes look like the following:
```diff
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/fix_float_equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def at_least_one_float(self, left, right) -> bool:
FixFloatEquality = CoreCodemod(
metadata=Metadata(
name="fix-float-equality",
summary="Replace `==` or `!=` with `math.isclose` Call for Floats or Arithmetic Operations with Floats",
summary="Use `math.isclose` Instead of Direct Equality for Floats",
review_guidance=ReviewGuidance.MERGE_AFTER_REVIEW,
references=[
Reference(
Expand Down

0 comments on commit b47b0d6

Please sign in to comment.