yarn format

This commit is contained in:
Quinn Dougherty 2022-04-13 19:18:08 -04:00
parent 24fe66c9d3
commit b0ff2c19f5
4 changed files with 43 additions and 34 deletions

View File

@ -37,25 +37,24 @@ module Internals = {
} }
let testOperationMean = ( let testOperationMean = (
distOp: (DistributionTypes.genericDist, DistributionTypes.genericDist) => result<DistributionTypes.genericDist, DistributionTypes.error>, distOp: (
DistributionTypes.genericDist,
DistributionTypes.genericDist,
) => result<DistributionTypes.genericDist, DistributionTypes.error>,
description: string, description: string,
floatOp: (float, float) => float, floatOp: (float, float) => float,
dist1': SymbolicDistTypes.symbolicDist, dist1': SymbolicDistTypes.symbolicDist,
dist2': SymbolicDistTypes.symbolicDist, dist2': SymbolicDistTypes.symbolicDist,
~epsilon: float ~epsilon: float,
) => { ) => {
let dist1 = dist1'->DistributionTypes.Symbolic // ->DistributionTypes.Other let dist1 = dist1'->DistributionTypes.Symbolic // ->DistributionTypes.Other
let dist2 = dist2'->DistributionTypes.Symbolic // ->DistributionTypes.Other let dist2 = dist2'->DistributionTypes.Symbolic // ->DistributionTypes.Other
let received = let received =
distOp(dist1, dist2) distOp(dist1, dist2)->E.R2.fmap(mean)->E.R2.fmap(run)->E.R2.fmap(toFloat)->E.R.toExn
->E.R2.fmap(mean)
->E.R2.fmap(run)
->E.R2.fmap(toFloat)
->E.R.toExn
let expected = floatOp(runMean(dist1), runMean(dist2)) let expected = floatOp(runMean(dist1), runMean(dist2))
switch received { switch received {
| None => expectImpossiblePath(description) | None => expectImpossiblePath(description)
| Some(x) => expectErrorToBeBounded(x, expected, ~epsilon=epsilon) | Some(x) => expectErrorToBeBounded(x, expected, ~epsilon)
} }
} }
} }
@ -79,9 +78,8 @@ let algebraicPower = algebraicPower(~env)
let {testOperationMean, distributions, pairsOfDifferentDistributions, epsilon} = module(Internals) let {testOperationMean, distributions, pairsOfDifferentDistributions, epsilon} = module(Internals)
describe("Means invariant", () => { describe("Means invariant", () => {
describe("for addition", () => { describe("for addition", () => {
let testAdditionMean = testOperationMean(algebraicAdd, "algebraicAdd", \"+.", ~epsilon=epsilon) let testAdditionMean = testOperationMean(algebraicAdd, "algebraicAdd", \"+.", ~epsilon)
testAll("of two of the same distribution", distributions, dist => { testAll("of two of the same distribution", distributions, dist => {
E.R.liftM2(testAdditionMean, dist, dist)->E.R.toExn E.R.liftM2(testAdditionMean, dist, dist)->E.R.toExn
@ -99,7 +97,12 @@ describe("Means invariant", () => {
}) })
describe("for subtraction", () => { describe("for subtraction", () => {
let testSubtractionMean = testOperationMean(algebraicSubtract, "algebraicSubtract", \"-.", ~epsilon=epsilon) let testSubtractionMean = testOperationMean(
algebraicSubtract,
"algebraicSubtract",
\"-.",
~epsilon,
)
testAll("of two of the same distribution", distributions, dist => { testAll("of two of the same distribution", distributions, dist => {
E.R.liftM2(testSubtractionMean, dist, dist)->E.R.toExn E.R.liftM2(testSubtractionMean, dist, dist)->E.R.toExn
@ -117,7 +120,12 @@ describe("Means invariant", () => {
}) })
describe("for multiplication", () => { describe("for multiplication", () => {
let testMultiplicationMean = testOperationMean(algebraicMultiply, "algebraicMultiply", \"*.", ~epsilon=epsilon) let testMultiplicationMean = testOperationMean(
algebraicMultiply,
"algebraicMultiply",
\"*.",
~epsilon,
)
testAll("of two of the same distribution", distributions, dist => { testAll("of two of the same distribution", distributions, dist => {
E.R.liftM2(testMultiplicationMean, dist, dist)->E.R.toExn E.R.liftM2(testMultiplicationMean, dist, dist)->E.R.toExn

View File

@ -117,7 +117,8 @@ module Helpers = {
| Error(err) => GenDistError(ArgumentError(err)) | Error(err) => GenDistError(ArgumentError(err))
} }
} }
| Some(EvDistribution(b)) => switch parseDistributionArray(args) { | Some(EvDistribution(b)) =>
switch parseDistributionArray(args) {
| Ok(distributions) => mixtureWithDefaultWeights(distributions) | Ok(distributions) => mixtureWithDefaultWeights(distributions)
| Error(err) => GenDistError(ArgumentError(err)) | Error(err) => GenDistError(ArgumentError(err))
} }