Skip to content

Commit

Permalink
Add comments to equivalence
Browse files Browse the repository at this point in the history
  • Loading branch information
atuonufure committed Aug 28, 2023
1 parent 1898c4c commit df7cdac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fhirpathpy/engine/invocations/equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ def equivalence(ctx, x, y):
if type(x[0]) in DATETIME_NODES_LIST or type(y[0]) in DATETIME_NODES_LIST:
return datetime_equality(ctx, x, y)

# string: the strings must be the same
# while ignoring case and normalizing whitespace.
if isinstance(x[0], str) and isinstance(y[0], str):
return " ".join(x[0].lower().split()) == " ".join(y[0].lower().split())

# decimal: values must be equal, comparison is done on values rounded
# to the precision of the least precise operand.
# Trailing zeroes are ignored in determining precision.
if isinstance(x[0], Decimal) or isinstance(y[0], Decimal):
precision_x = len(str(x[0]).split(".")[1]) if "." in str(x[0]) else 0
precision_y = len(str(y[0]).split(".")[1]) if "." in str(y[0]) else 0
Expand Down

0 comments on commit df7cdac

Please sign in to comment.