Skip to content

Commit

Permalink
specify string formatting in fstring as opposed to using round (#2013)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2013

cleaning up an oss error that squeezed through

Reviewed By: saitcakmak

Differential Revision: D51534667

fbshipit-source-id: 7e329f09073b0b51d16269d907093a90549777ea
  • Loading branch information
Bernie Beckerman authored and facebook-github-bot committed Nov 23, 2023
1 parent f8033bd commit aada4cf
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions ax/service/utils/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,10 +1131,10 @@ def _format_comparison_string(
return (
f"{comparison_arm_name=} "
+ "improves your objective metric "
+ f"{objective_name} by {percent_change}%. "
+ f"{objective_name} by {percent_change:.2f}%. "
+ f" {baseline_arm_name=} was improved "
+ f"from {baseline_value=}"
+ f" to {comparison_value=}"
+ f"from {baseline_value=:.2f}"
+ f" to {comparison_value=:.2f}"
)


Expand Down Expand Up @@ -1163,11 +1163,7 @@ def _construct_comparison_message(
+ f" did not beat baseline arm {baseline_arm_name}. "
)
return None
percent_change = round(
((abs(comparison_value - baseline_value)) / baseline_value) * 100, digits
)
baseline_value = round(baseline_value, digits)
comparison_value = round(comparison_value, digits)
percent_change = ((abs(comparison_value - baseline_value)) / baseline_value) * 100

return _format_comparison_string(
comparison_arm_name,
Expand Down

0 comments on commit aada4cf

Please sign in to comment.