Skip to content

Commit 861684d

Browse files
authored
Merge pull request #1266 from herbie-fp/skip-initial-program-altns
Hide alternatives that are equal to the initial expression
2 parents 17bcf45 + 057a993 commit 861684d

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/reports/make-graph.rkt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
(and (not (null? better)) (apply max better))))
6666

6767
(define end-error (car end-errors))
68+
(define alt-number 0)
6869

6970
`(html
7071
(head (meta ([charset "utf-8"]))
@@ -149,11 +150,13 @@
149150
[expr end-exprs]
150151
[errs end-errors]
151152
[cost end-costs]
152-
[history end-histories])
153+
[history end-histories]
154+
#:unless (equal? start-expr expr))
155+
(set! alt-number (add1 alt-number))
153156
(define-values (dropdown body) (render-program expr ctx #:ident identifier))
154157
`(section ([id ,(format "alternative~a" i)] (class "programs"))
155158
(h2 "Alternative "
156-
,(~a i)
159+
,(~a alt-number)
157160
": "
158161
(span ((class "subhead"))
159162
(data ,(format-accuracy (errors-score errs) repr-bits #:unit "%"))

src/reports/resources/report.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,15 @@ const CostAccuracy = new Component('#cost-accuracy', {
290290
// - We make a broken line to show the real Pareto frontier
291291
let line = []
292292
let last = null;
293-
for (let pt of rest_pts) {
293+
rest_pts.forEach((pt, i) => {
294+
let target = "alternative" + (i + 1);
295+
if (!document.getElementById(target)) return;
294296
if (!last || pt[1] > last[1]) {
295297
if (last) line.push([pt[0], last[1]]);
296298
line.push([pt[0], pt[1]]);
297299
last = pt;
298300
}
299-
}
301+
})
300302

301303
const out = Plot.plot({
302304
marks: [
@@ -336,23 +338,23 @@ const CostAccuracy = new Component('#cost-accuracy', {
336338
const bits = benchmark["bits"];
337339
const initial_accuracy = 100*(1 - initial_pt[1]/bits);
338340

341+
let alt_number = 0;
339342
return Element("tbody", [
340343
Element("tr", [
341344
Element("th", "Initial program"),
342345
Element("td", initial_accuracy.toFixed(1) + "%"),
343346
Element("td", "1.0×")
344347
]),
345348
rest_pts.map((d, i) => {
349+
let target = "alternative" + (i + 1);
350+
if (!document.getElementById(target)) return;
346351
let accuracy = 100*(1 - d[1]/bits);
347352
let speedup = initial_pt[0]/d[0];
353+
alt_number++;
348354
return Element("tr", [
349-
Element("th",
350-
rest_pts.length > 1 ?
351-
Element("a", { href: "#alternative" + (i + 1)},
352-
"Alternative " + (i + 1))
353-
// else
354-
: "Alternative " + (i + 1)
355-
),
355+
Element("th", [
356+
Element("a", { href: "#" + target}, "Alternative " + alt_number)
357+
]),
356358
Element("td", { className: accuracy >= initial_accuracy ? "better" : "" },
357359
accuracy.toFixed(1) + "%"),
358360
Element("td", { className: speedup >= 1 ? "better" : "" },

0 commit comments

Comments
 (0)