Skip to content

Commit

Permalink
updating the language a little
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Mar 20, 2024
1 parent 22794f7 commit fbd0acc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 39 deletions.
22 changes: 11 additions & 11 deletions public/lang-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ Program:

Description: All colors in a palette should be differentiable by people with deuteranopia (ie can't see green). This is because if they are not, then they will not be differentiable from each other in some contexts.

Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, deuteranopia), cvdSim(b, deuteranopia)) < 9
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, deuteranopia), cvdSim(b, deuteranopia)) < 9

Palettes that will fail this test:

Expand Down Expand Up @@ -455,7 +455,7 @@ Program:

Description: All colors in a palette should be differentiable by people with protanopia (ie can't see red). This is because if they are not, then they will not be differentiable from each other in some contexts.

Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, protanopia), cvdSim(b, protanopia)) < 9
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, protanopia), cvdSim(b, protanopia)) < 9

Palettes that will fail this test:

Expand Down Expand Up @@ -499,7 +499,7 @@ Program:

Description: All colors in a palette should be differentiable by people with tritanopia (ie can't see blue). This is because if they are not, then they will not be differentiable from each other in some contexts.

Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, tritanopia), cvdSim(b, tritanopia)) < 9
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, tritanopia), cvdSim(b, tritanopia)) < 9

Palettes that will fail this test:

Expand Down Expand Up @@ -543,7 +543,7 @@ Program:

Description: All colors in a palette should be differentiable by people with grayscale . This is because if they are not, then they will not be differentiable from each other in some contexts.

Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, grayscale), cvdSim(b, grayscale)) < 9
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, grayscale), cvdSim(b, grayscale)) < 9

Palettes that will fail this test:

Expand Down Expand Up @@ -1001,7 +1001,7 @@ Program:

Description: Use color complements whenever possible

Natural Language: EXIST (a, b) IN colors SUCH THAT similar(hsl.h(a), hsl.h(b) + 180) < 5
Natural Language: EXIST a, b IN colors SUCH THAT similar(hsl.h(a), hsl.h(b) + 180) < 5


Program:
Expand Down Expand Up @@ -1034,7 +1034,7 @@ Program:

Description: Pairs of colors in a palette should be differentiable from each other in Thin marks.

Natural Language: ALL (x, y) IN colors WHERE index(x) != index(y) SUCH THAT (absDiff(lab.l(x), lab.l(y)) > 12.58 OR absDiff(lab.a(x), lab.a(y)) > 20.740000000000002 OR absDiff(lab.b(x), lab.b(y)) > 34.05)
Natural Language: ALL x, y IN colors WHERE index(x) != index(y) SUCH THAT (|lab.l(x) - lab.l(y)| > 12.58 OR |lab.a(x) - lab.a(y)| > 20.740000000000002 OR |lab.b(x) - lab.b(y)| > 34.05)

Palettes that will fail this test:

Expand Down Expand Up @@ -1097,7 +1097,7 @@ Program:

Description: Pairs of colors in a palette should be differentiable from each other in Medium marks.

Natural Language: ALL (x, y) IN colors WHERE index(x) != index(y) SUCH THAT (absDiff(lab.l(x), lab.l(y)) > 6.58 OR absDiff(lab.a(x), lab.a(y)) > 8.42 OR absDiff(lab.b(x), lab.b(y)) > 11.09)
Natural Language: ALL x, y IN colors WHERE index(x) != index(y) SUCH THAT (|lab.l(x) - lab.l(y)| > 6.58 OR |lab.a(x) - lab.a(y)| > 8.42 OR |lab.b(x) - lab.b(y)| > 11.09)

Palettes that will fail this test:

Expand Down Expand Up @@ -1160,7 +1160,7 @@ Program:

Description: Pairs of colors in a palette should be differentiable from each other in Wide marks.

Natural Language: ALL (x, y) IN colors WHERE index(x) != index(y) SUCH THAT (absDiff(lab.l(x), lab.l(y)) > 5.83 OR absDiff(lab.a(x), lab.a(y)) > 6.88 OR absDiff(lab.b(x), lab.b(y)) > 8.219999999999999)
Natural Language: ALL x, y IN colors WHERE index(x) != index(y) SUCH THAT (|lab.l(x) - lab.l(y)| > 5.83 OR |lab.a(x) - lab.a(y)| > 6.88 OR |lab.b(x) - lab.b(y)| > 8.219999999999999)

Palettes that will fail this test:

Expand Down Expand Up @@ -1266,7 +1266,7 @@ Program:

Description: Opt for colors that are perceptually distinguishable in a logical sequence when designing visual elements like charts or graphs. This ensures that viewers can easily recognize the order or progression of data points. For categorical this means that when only a small number of colors are used, they should be as different as possible. For sequential and diverging, this means that the colors should be as different as possible in order.

Natural Language: ALL (a, b) IN colors WHERE index(a) == index(b) - 1 SUCH THAT deltaE(a, b, 2000) > 10
Natural Language: ALL a, b IN colors WHERE index(a) == index(b) - 1 SUCH THAT deltaE(a, b, 2000) > 10

Palettes that will fail this test:

Expand Down Expand Up @@ -1445,7 +1445,7 @@ Program:

Description: All colors in a palette should be different from each other. This is because if they are not, then they will not be differentiable from each other in some contexts.

Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT dist(a, b, lab) > 15
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT dist(a, b, lab) > 15

Palettes that will fail this test:

Expand Down Expand Up @@ -1486,7 +1486,7 @@ Program:

Description: Being able to identify colors by name is important for usability and for memorability.

Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT name(a) != name(b)
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT name(a) != name(b)

Palettes that will fail this test:

Expand Down
22 changes: 11 additions & 11 deletions src/lib/__snapshots__/LintDocs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ Program:
Description: All colors in a palette should be differentiable by people with deuteranopia (ie can't see green). This is because if they are not, then they will not be differentiable from each other in some contexts.
Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, deuteranopia), cvdSim(b, deuteranopia)) < 9
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, deuteranopia), cvdSim(b, deuteranopia)) < 9
Palettes that will fail this test:
Expand Down Expand Up @@ -458,7 +458,7 @@ Program:
Description: All colors in a palette should be differentiable by people with protanopia (ie can't see red). This is because if they are not, then they will not be differentiable from each other in some contexts.
Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, protanopia), cvdSim(b, protanopia)) < 9
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, protanopia), cvdSim(b, protanopia)) < 9
Palettes that will fail this test:
Expand Down Expand Up @@ -502,7 +502,7 @@ Program:
Description: All colors in a palette should be differentiable by people with tritanopia (ie can't see blue). This is because if they are not, then they will not be differentiable from each other in some contexts.
Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, tritanopia), cvdSim(b, tritanopia)) < 9
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, tritanopia), cvdSim(b, tritanopia)) < 9
Palettes that will fail this test:
Expand Down Expand Up @@ -546,7 +546,7 @@ Program:
Description: All colors in a palette should be differentiable by people with grayscale . This is because if they are not, then they will not be differentiable from each other in some contexts.
Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, grayscale), cvdSim(b, grayscale)) < 9
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(cvdSim(a, grayscale), cvdSim(b, grayscale)) < 9
Palettes that will fail this test:
Expand Down Expand Up @@ -1004,7 +1004,7 @@ Program:
Description: Use color complements whenever possible
Natural Language: EXIST (a, b) IN colors SUCH THAT similar(hsl.h(a), hsl.h(b) + 180) < 5
Natural Language: EXIST a, b IN colors SUCH THAT similar(hsl.h(a), hsl.h(b) + 180) < 5
Program:
Expand Down Expand Up @@ -1037,7 +1037,7 @@ Program:
Description: Pairs of colors in a palette should be differentiable from each other in Thin marks.
Natural Language: ALL (x, y) IN colors WHERE index(x) != index(y) SUCH THAT (absDiff(lab.l(x), lab.l(y)) > 12.58 OR absDiff(lab.a(x), lab.a(y)) > 20.740000000000002 OR absDiff(lab.b(x), lab.b(y)) > 34.05)
Natural Language: ALL x, y IN colors WHERE index(x) != index(y) SUCH THAT (|lab.l(x) - lab.l(y)| > 12.58 OR |lab.a(x) - lab.a(y)| > 20.740000000000002 OR |lab.b(x) - lab.b(y)| > 34.05)
Palettes that will fail this test:
Expand Down Expand Up @@ -1100,7 +1100,7 @@ Program:
Description: Pairs of colors in a palette should be differentiable from each other in Medium marks.
Natural Language: ALL (x, y) IN colors WHERE index(x) != index(y) SUCH THAT (absDiff(lab.l(x), lab.l(y)) > 6.58 OR absDiff(lab.a(x), lab.a(y)) > 8.42 OR absDiff(lab.b(x), lab.b(y)) > 11.09)
Natural Language: ALL x, y IN colors WHERE index(x) != index(y) SUCH THAT (|lab.l(x) - lab.l(y)| > 6.58 OR |lab.a(x) - lab.a(y)| > 8.42 OR |lab.b(x) - lab.b(y)| > 11.09)
Palettes that will fail this test:
Expand Down Expand Up @@ -1163,7 +1163,7 @@ Program:
Description: Pairs of colors in a palette should be differentiable from each other in Wide marks.
Natural Language: ALL (x, y) IN colors WHERE index(x) != index(y) SUCH THAT (absDiff(lab.l(x), lab.l(y)) > 5.83 OR absDiff(lab.a(x), lab.a(y)) > 6.88 OR absDiff(lab.b(x), lab.b(y)) > 8.219999999999999)
Natural Language: ALL x, y IN colors WHERE index(x) != index(y) SUCH THAT (|lab.l(x) - lab.l(y)| > 5.83 OR |lab.a(x) - lab.a(y)| > 6.88 OR |lab.b(x) - lab.b(y)| > 8.219999999999999)
Palettes that will fail this test:
Expand Down Expand Up @@ -1269,7 +1269,7 @@ Program:
Description: Opt for colors that are perceptually distinguishable in a logical sequence when designing visual elements like charts or graphs. This ensures that viewers can easily recognize the order or progression of data points. For categorical this means that when only a small number of colors are used, they should be as different as possible. For sequential and diverging, this means that the colors should be as different as possible in order.
Natural Language: ALL (a, b) IN colors WHERE index(a) == index(b) - 1 SUCH THAT deltaE(a, b, 2000) > 10
Natural Language: ALL a, b IN colors WHERE index(a) == index(b) - 1 SUCH THAT deltaE(a, b, 2000) > 10
Palettes that will fail this test:
Expand Down Expand Up @@ -1448,7 +1448,7 @@ Program:
Description: All colors in a palette should be different from each other. This is because if they are not, then they will not be differentiable from each other in some contexts.
Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT dist(a, b, lab) > 15
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT dist(a, b, lab) > 15
Palettes that will fail this test:
Expand Down Expand Up @@ -1489,7 +1489,7 @@ Program:
Description: Being able to identify colors by name is important for usability and for memorability.
Natural Language: ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT name(a) != name(b)
Natural Language: ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT name(a) != name(b)
Palettes that will fail this test:
Expand Down
12 changes: 6 additions & 6 deletions src/lib/lint-language/LintLanguage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ test("LintLanguage Quantifiers Exist - DENSE", () => {
},
};
expect(prettyPrintLL(cvdExists)).toBe(
"NOT EXIST (a, b) IN colors SUCH THAT cvdSim(a, deuteranopia) != cvdSim(b, deuteranopia)"
"NOT EXIST a, b IN colors SUCH THAT cvdSim(a, deuteranopia) != cvdSim(b, deuteranopia)"
);
expect(LLEval(cvdExists, exampleColors).result).toBe(false);
});
Expand All @@ -303,7 +303,7 @@ test("LintLanguage Quantifiers All - DENSE", () => {
},
};
expect(prettyPrintLL(cvdExists)).toBe(
"ALL (a, b) IN colors SUCH THAT NOT similar(cvdSim(a, deuteranopia), cvdSim(b, deuteranopia)) < 9"
"ALL a, b IN colors SUCH THAT NOT similar(cvdSim(a, deuteranopia), cvdSim(b, deuteranopia)) < 9"
);
expect(LLEval(cvdExists, exampleColors).result).toBe(false);
});
Expand Down Expand Up @@ -475,7 +475,7 @@ test("LintLanguage Name discrimination", () => {
},
};
expect(prettyPrintLL(program)).toBe(
"ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT name(a) != name(b)"
"ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT name(a) != name(b)"
);
const greenResult = LLEval(program, greens);
expect(greenResult.result).toBe(false);
Expand All @@ -496,7 +496,7 @@ test("LintLanguage Name discrimination - dense notation", () => {
},
};
expect(prettyPrintLL(program)).toBe(
"ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT name(a) != name(b)"
"ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT name(a) != name(b)"
);
expect(LLEval(program, greens).result).toBe(false);
expect(LLEval(program, reds).result).toBe(true);
Expand Down Expand Up @@ -677,7 +677,7 @@ test("LintLanguage Sequential Colors", () => {
const inOrder = toPal(["#d4a8ff", "#7bb9ff", "#008694"]);
expect(LLEval(program, inOrder).result).toBe(true);
expect(prettyPrintLL(program)).toBe(
"(ALL (a, b) IN colors WHERE index(a) - 1 == index(b) SUCH THAT lab.l(a) > lab.l(b) OR ALL (a, b) IN colors WHERE index(a) - 1 == index(b) SUCH THAT lab.l(a) < lab.l(b))"
"(ALL a, b IN colors WHERE index(a) - 1 == index(b) SUCH THAT lab.l(a) > lab.l(b) OR ALL a, b IN colors WHERE index(a) - 1 == index(b) SUCH THAT lab.l(a) < lab.l(b))"
);
});

Expand Down Expand Up @@ -795,7 +795,7 @@ test("LintLanguage Sequential Similarity", () => {
};
const astString = prettyPrintLL(program);
expect(astString).toBe(
"ALL (a, b) IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(a, b) < 10"
"ALL a, b IN colors WHERE index(a) != index(b) SUCH THAT NOT similar(a, b) < 10"
);
const result = LLEval(program, toPal(["#fff", "#eee", "#000", "#ddd"]));
expect(result.result).toBe(false);
Expand Down
19 changes: 8 additions & 11 deletions src/lib/lint-language/lint-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ export class LLNumberOp extends LLNode {
const left = this.left.toString();
const right = this.right.toString();
if (this.type === "absDiff") {
return `absDiff(${left}, ${right})`;
// return `absDiff(${left}, ${right})`;
return `|${left} - ${right}|`;
}
return `${left} ${this.type} ${right}`;
}
Expand Down Expand Up @@ -891,23 +892,19 @@ export class LLQuantifier extends LLNode {
);
}
toString(): string {
let varbs = "";
if (this.varbs.length > 1) {
varbs = `(${this.varbs.join(", ")})`;
} else {
varbs = this.varbs.join(", ");
}
let targ = this.input.toString();
if (targ !== "colors") {
targ = `(${targ})`;
const varbs = this.varbs.join(", ");
let target = this.input.toString();
if (target !== "colors") {
target = `(${target})`;
}
let where = "";
if (this.where) {
where = ` WHERE ${this.where.toString()}`;
}
// const type = this.type === "exist" ? "∃" : "∀";
const type = this.type.toUpperCase();
return `${type} ${varbs} IN ${targ}${where} SUCH THAT ${this.predicate.toString()}`;
const pred = this.predicate.toString();
return `${type} ${varbs} IN ${target}${where} SUCH THAT ${pred}`;
}
}

Expand Down

0 comments on commit fbd0acc

Please sign in to comment.