Skip to content

Commit

Permalink
Add simple hack to fix percent.
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneenders committed Nov 13, 2024
1 parent 6b1f75f commit c160e15
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/herbie/LocalError/LocalError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ function localErrorTreeAsMermaidGraph(tree: types.LocalErrorTree, bits: number,
}
var accuracy_str = ""
if (!(abs_error_difference === "equal")) {
accuracy_str = ` <br /> Percent Accuracy : ${herbiejs.displayNumber(Number(percent))}%${explanation_str}`
accuracy_str = ` <br /> Percent Accuracy : ${displayPercent(percent)}%${explanation_str}`
}
const tooltipContent = `'Correct R : ${displayError(exact_err)} <br /> Approx F : ${displayError(approx_value)}${difference_str}${accuracy_str}'`;
return id + '[<span class=nodeLocalError data-tooltip-id=node-tooltip data-tooltip-html=' + tooltipContent + '>' + name + '</span>]'
}

function displayPercent(value: string) {
if (value == '100.0') { // HACK special case 100% to not be e+2%
return value
} else {
return herbiejs.displayNumber(Number(value))
}
}

function displayError(abs_error: string) {
if (abs_error === "invalid" || abs_error === "unsamplable"
|| abs_error === "+inf.0" || abs_error === "-inf.0"
Expand Down

0 comments on commit c160e15

Please sign in to comment.