Minor cleanup, turned errors into results
This commit is contained in:
parent
b72dbab863
commit
8b8d144658
|
@ -142,7 +142,7 @@ module DemoDist = {
|
||||||
},
|
},
|
||||||
~distPlusIngredients,
|
~distPlusIngredients,
|
||||||
~shouldDownsample=options.downsampleTo |> E.O.isSome,
|
~shouldDownsample=options.downsampleTo |> E.O.isSome,
|
||||||
~recommendedLength=options.downsampleTo |> E.O.default(100),
|
~recommendedLength=options.downsampleTo |> E.O.default(1000),
|
||||||
(),
|
(),
|
||||||
);
|
);
|
||||||
let response = DistPlusRenderer.run(inputs);
|
let response = DistPlusRenderer.run(inputs);
|
||||||
|
|
|
@ -395,7 +395,7 @@ module Draw = {
|
||||||
numSamples,
|
numSamples,
|
||||||
{sampleCount: 10000, outputXYPoints: 10000, kernelWidth: None},
|
{sampleCount: 10000, outputXYPoints: 10000, kernelWidth: None},
|
||||||
`SymbolicDist(normal),
|
`SymbolicDist(normal),
|
||||||
);
|
) |> E.R.toExn;
|
||||||
let xyShape: Types.xyShape =
|
let xyShape: Types.xyShape =
|
||||||
switch (normalShape) {
|
switch (normalShape) {
|
||||||
| Mixed(_) => {xs: [||], ys: [||]}
|
| Mixed(_) => {xs: [||], ys: [||]}
|
||||||
|
|
|
@ -10,14 +10,9 @@ let toShape = (intendedShapeLength: int, samplingInputs, node: node) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (renderResult) {
|
switch (renderResult) {
|
||||||
| Ok(`RenderedDist(rs)) =>
|
| Ok(`RenderedDist(shape)) => Ok(shape)
|
||||||
// todo: Why is this here? It converts a mixed shape to a mixed shape.
|
| Ok(_) => Error("Rendering failed.")
|
||||||
let continuous = Shape.T.toContinuous(rs);
|
| Error(e) => Error(e)
|
||||||
let discrete = Shape.T.toDiscrete(rs);
|
|
||||||
let shape = MixedShapeBuilder.buildSimple(~continuous, ~discrete);
|
|
||||||
shape |> E.O.toExt("Could not build final shape.");
|
|
||||||
| Ok(_) => E.O.toExn("Rendering failed.", None)
|
|
||||||
| Error(message) => E.O.toExn("No shape found, error: " ++ message, None)
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,21 +18,19 @@ let runSymbolic = (inputs: RenderTypes.ShapeRenderer.Combined.inputs) => {
|
||||||
let str = formatString(inputs.guesstimatorString);
|
let str = formatString(inputs.guesstimatorString);
|
||||||
let graph = MathJsParser.fromString(str);
|
let graph = MathJsParser.fromString(str);
|
||||||
graph
|
graph
|
||||||
|> E.R.fmap(g =>
|
|> E.R.bind(_, g =>
|
||||||
RenderTypes.ShapeRenderer.Symbolic.make(
|
ExpressionTree.toShape(
|
||||||
|
inputs.symbolicInputs.length,
|
||||||
|
{
|
||||||
|
sampleCount:
|
||||||
|
inputs.samplingInputs.sampleCount |> E.O.default(10000),
|
||||||
|
outputXYPoints:
|
||||||
|
inputs.samplingInputs.outputXYPoints |> E.O.default(10000),
|
||||||
|
kernelWidth: inputs.samplingInputs.kernelWidth,
|
||||||
|
},
|
||||||
g,
|
g,
|
||||||
ExpressionTree.toShape(
|
|
||||||
inputs.symbolicInputs.length,
|
|
||||||
{
|
|
||||||
sampleCount:
|
|
||||||
inputs.samplingInputs.sampleCount |> E.O.default(10000),
|
|
||||||
outputXYPoints:
|
|
||||||
inputs.samplingInputs.outputXYPoints |> E.O.default(10000),
|
|
||||||
kernelWidth: inputs.samplingInputs.kernelWidth,
|
|
||||||
},
|
|
||||||
g,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|> E.R.fmap(RenderTypes.ShapeRenderer.Symbolic.make(g))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@ module R = {
|
||||||
let id = e => e |> result(U.id, U.id);
|
let id = e => e |> result(U.id, U.id);
|
||||||
let fmap = Rationale.Result.fmap;
|
let fmap = Rationale.Result.fmap;
|
||||||
let bind = Rationale.Result.bind;
|
let bind = Rationale.Result.bind;
|
||||||
|
let toExn = Belt.Result.getExn;
|
||||||
let merge = (a, b) =>
|
let merge = (a, b) =>
|
||||||
switch (a, b) {
|
switch (a, b) {
|
||||||
| (Error(e), _) => Error(e)
|
| (Error(e), _) => Error(e)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user