Run prettier + add missing pointWiseAdd signature

This commit is contained in:
Sam Nolan 2022-04-11 11:08:34 +10:00
parent 8f49b64083
commit d6c541036f
2 changed files with 9 additions and 11 deletions

View File

@ -1,8 +1,4 @@
import { import { run, Distribution, resultMap } from "../src/js/index";
run,
Distribution,
resultMap,
} from "../src/js/index";
let testRun = (x: string) => { let testRun = (x: string) => {
let result = run(x); let result = run(x);
@ -14,7 +10,7 @@ let testRun = (x: string) => {
}; };
function Ok<b>(x: b) { function Ok<b>(x: b) {
return { tag: "Ok", value: x} return { tag: "Ok", value: x };
} }
describe("Simple calculations and results", () => { describe("Simple calculations and results", () => {
@ -81,14 +77,16 @@ describe("Distribution", () => {
}); });
test("algebraicAdd", () => { test("algebraicAdd", () => {
expect( expect(
resultMap(dist.algebraicAdd(dist2), (r: Distribution) => r.toSparkline(20)) resultMap(dist.algebraicAdd(dist2), (r: Distribution) =>
.value r.toSparkline(20)
).value
).toEqual(Ok("▁▁▂▄▆████▇▆▄▄▃▃▃▂▁▁▁")); ).toEqual(Ok("▁▁▂▄▆████▇▆▄▄▃▃▃▂▁▁▁"));
}); });
test("pointwiseAdd", () => { test("pointwiseAdd", () => {
expect( expect(
resultMap(dist.pointwiseAdd(dist2), (r: Distribution) => r.toSparkline(20)) resultMap(dist.pointwiseAdd(dist2), (r: Distribution) =>
.value r.toSparkline(20)
).value
).toEqual(Ok("▁▂▅██▅▅▅▆▇█▆▅▃▃▂▂▁▁▁")); ).toEqual(Ok("▁▂▅██▅▅▅▆▇█▆▅▃▃▂▂▁▁▁"));
}); });
}); });

View File

@ -185,7 +185,7 @@ export class Distribution {
); );
} }
pointwiseAdd(d2: Distribution) { pointwiseAdd(d2: Distribution): result<Distribution, error> {
return this.mapResultDist( return this.mapResultDist(
Constructors_pointwiseAdd({ env: this.env }, this.t, d2.t) Constructors_pointwiseAdd({ env: this.env }, this.t, d2.t)
); );