Minor cleanup

This commit is contained in:
Ozzie Gooen 2020-08-07 19:23:18 +01:00
parent 6887da59b3
commit 447215421d
5 changed files with 22 additions and 20 deletions

View File

@ -165,8 +165,8 @@ module DemoDist = {
<DistPlusPlot distPlus={DistPlus.T.normalize(distPlus1)} />
| Ok(`Function(f, a)) =>
let result1 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(5.0))|],);
let result2 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(20.0))|],);
let result3 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(40.0))|],);
let result2 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(10.0))|],);
let result3 = DistPlusRenderer.runFunction(inputs1, (f, a), [|`SymbolicDist(`Float(20.0))|],);
switch (result1, result2, result3) {
| (Ok(`DistPlus(distPlus1)),Ok(`DistPlus(distPlus2)),Ok(`DistPlus(distPlus3))) =>
<>
@ -174,6 +174,7 @@ module DemoDist = {
<DistPlusPlot distPlus={DistPlus.T.normalize(distPlus2)} />
<DistPlusPlot distPlus={DistPlus.T.normalize(distPlus3)} />
</>
| (Error(r), _, _) => r |> R.ste
| _ => "Failure " |> R.ste
};
| Error(r) => r |> R.ste

View File

@ -259,7 +259,6 @@ module DistPlusChart = {
module IntegralChart = {
[@react.component]
let make = (~distPlus: DistTypes.distPlus, ~config: chartConfig, ~onHover) => {
open DistPlus;
let integral = distPlus.integralCache;
let continuous =
integral

View File

@ -9,7 +9,7 @@ let toLeaf = (samplingInputs, environment, node: node) =>
let rec toString: node => string =
fun
| `SymbolicDist(d) => SymbolicDist.T.toString(d)
| `RenderedDist(_) => "[shape]"
| `RenderedDist(_) => "[renderedShape]"
| `AlgebraicCombination(op, t1, t2) =>
Operation.Algebraic.format(op, toString(t1), toString(t2))
| `PointwiseCombination(op, t1, t2) =>

View File

@ -93,5 +93,5 @@ let fnn =
| _ => Error("Needs 3 valid arguments")
}
| ("to", _) => to_(args)
| _ => Error("Function not found")
| _ => Error("Function " ++ name ++ " not found")
};

View File

@ -144,24 +144,31 @@ let run = (inputs: Inputs.inputs) => {
|> E.R.bind(_, r =>
switch (r) {
| `RenderedDist(n) => Ok(n)
| _ => Error("Didn't output renderedDist")
| n =>
Error(
"Didn't output a rendered distribution. Format:"
++ ExpressionTree.toString(n),
)
}
)
|> E.R.fmap(Internals.outputToDistPlus(inputs));
};
let exportDistPlus = inputs =>
fun
| `RenderedDist(n) => Ok(`DistPlus(Internals.outputToDistPlus(inputs, n)))
| `Function(n) => Ok(`Function(n))
| n =>
Error(
"Didn't output a rendered distribution. Format:"
++ ExpressionTree.toString(n),
);
let run2 = (inputs: Inputs.inputs) => {
inputs
|> Internals.distPlusRenderInputsToInputs
|> Internals.inputsToLeaf
|> E.R.bind(_, r =>
switch (r) {
| `RenderedDist(n) =>
Ok(`DistPlus(Internals.outputToDistPlus(inputs, n)))
| `Function(n) => Ok(`Function(n))
| _ => Error("Didn't output renderedDist")
}
);
|> E.R.bind(_, exportDistPlus(inputs));
};
let runFunction =
@ -185,10 +192,5 @@ let runFunction =
fnInputs,
fn,
);
Js.log2("GOt output", output);
switch (output) {
| Ok(`RenderedDist(n)) => Ok(`DistPlus(Internals.outputToDistPlus(ins, n)))
| Ok(`Function(n)) => Ok(`Function(n))
| _ => Error("Didn't output renderedDist")
};
output |> E.R.bind(_, exportDistPlus(ins));
};