Skip to content

Commit

Permalink
cleanup; correct reason string for inequalities
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-ephemera committed Jan 17, 2024
1 parent 0b8f40d commit aa1b228
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pymatgen/io/validation/check_incar.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,15 +742,20 @@ def check_parameter(
tolerance = tolerance or 1.0e-4
valid_value = isclose(current_value, reference_value, rel_tol=tolerance, abs_tol=0.0)
else:
if operation == "approx" and not isinstance(current_value, float):
print(current_value, input_tag)
valid_value = reference_value.__getattribute__(self.operations[operation])(current_value)

if not valid_value:
msg = (
# reverse the inequality sign because of ordering of input and expected
# values in reason string
flipped_operation = operation
if ">" in operation:
flipped_operation.replace(">", "<")
elif "<" in operation:
flipped_operation.replace("<", ">")

reasons.append(
"INPUT SETTINGS --> "
f"{self.input_tag_translation.get(input_tag,input_tag)}: "
f"set to {current_value}, but should be {operation} "
f"set to {current_value}, but should be {flipped_operation} "
f"{reference_value}. {extra_comments_upon_failure}"
)
reasons.append(msg)

0 comments on commit aa1b228

Please sign in to comment.