Skip to content

Commit 7cecd61

Browse files
committed
Add help bubbles to local error table
1 parent 613ab9b commit 7cecd61

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

src/herbie/LocalError/newLocalError.tsx

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import * as herbiejs from '../lib/herbiejs';
44
import { LocalErrorTree } from "../HerbieTypes";
55
import "./newLocalError.css";
66

7+
import { Tooltip } from "react-tooltip";
8+
79
const opMap: Record<string,string> = {
810
"+": "add (+)",
911
"-": "subtract (-)",
@@ -260,19 +262,44 @@ function NewLocalError({ expressionId }: { expressionId: number }) {
260262

261263
const hasNoExplanations = explanationPaths.length === 0
262264

265+
// InfoIcon component for consistent tooltips
266+
const InfoIcon = ({ tooltipId, tooltipContent }: { tooltipId: string, tooltipContent: string }) => (
267+
<>
268+
<span
269+
data-tooltip-id={tooltipId}
270+
data-tooltip-content={tooltipContent}
271+
style={{ marginLeft: '4px', cursor: 'help', color: 'var(--action-color)' }}
272+
>
273+
<svg width="10" height="10" viewBox="0 0 24 24" fill="currentColor">
274+
<circle cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="2" fill="none"/>
275+
<text x="12" y="16" textAnchor="middle" fontSize="12" fontWeight="bold">?</text>
276+
</svg>
277+
</span>
278+
<Tooltip id={tooltipId} />
279+
</>
280+
);
281+
263282
return (
264283
<div className={`local-error ${hasNoExplanations ? ' no-explanations' : ''}`}>
265284
<table>
266285
<thead>
267286
<tr>
268287
<th className="program-col">Program</th>
269-
<th>R Value</th>
270-
<th>FP Value</th>
271-
<th title="Difference between R and FP values" >
272-
Difference
288+
<th>R Value
289+
<InfoIcon tooltipId="r-value-tooltip" tooltipContent="The exact value computed using infinite precision arithmetic" />
290+
</th>
291+
<th>FP Value
292+
<InfoIcon tooltipId="fp-value-tooltip" tooltipContent="The actual computed value using floating-point arithmetic" />
293+
</th>
294+
<th>Difference
295+
<InfoIcon tooltipId="difference-tooltip" tooltipContent="The absolute difference between the exact (R) and floating-point (FP) values" />
296+
</th>
297+
<th>Accuracy
298+
<InfoIcon tooltipId="accuracy-tooltip" tooltipContent="Percentage accuracy of the floating-point computation compared to the exact result" />
299+
</th>
300+
<th className="explanation">Explanation
301+
<InfoIcon tooltipId="explanation-tooltip" tooltipContent="An explanation code, if there is significant error" />
273302
</th>
274-
<th>Accuracy</th>
275-
<th className="explanation">Explanation</th>
276303
</tr>
277304
</thead>
278305
<tbody>

0 commit comments

Comments
 (0)