Minor cleanup, turned errors into results
This commit is contained in:
parent
b72dbab863
commit
8b8d144658
|
@ -142,7 +142,7 @@ module DemoDist = {
|
|||
},
|
||||
~distPlusIngredients,
|
||||
~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);
|
||||
|
|
|
@ -395,7 +395,7 @@ module Draw = {
|
|||
numSamples,
|
||||
{sampleCount: 10000, outputXYPoints: 10000, kernelWidth: None},
|
||||
`SymbolicDist(normal),
|
||||
);
|
||||
) |> E.R.toExn;
|
||||
let xyShape: Types.xyShape =
|
||||
switch (normalShape) {
|
||||
| Mixed(_) => {xs: [||], ys: [||]}
|
||||
|
|
|
@ -10,14 +10,9 @@ let toShape = (intendedShapeLength: int, samplingInputs, node: node) => {
|
|||
});
|
||||
|
||||
switch (renderResult) {
|
||||
| Ok(`RenderedDist(rs)) =>
|
||||
// todo: Why is this here? It converts a mixed shape to a mixed shape.
|
||||
let continuous = Shape.T.toContinuous(rs);
|
||||
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)
|
||||
| Ok(`RenderedDist(shape)) => Ok(shape)
|
||||
| Ok(_) => Error("Rendering failed.")
|
||||
| Error(e) => Error(e)
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -18,21 +18,19 @@ let runSymbolic = (inputs: RenderTypes.ShapeRenderer.Combined.inputs) => {
|
|||
let str = formatString(inputs.guesstimatorString);
|
||||
let graph = MathJsParser.fromString(str);
|
||||
graph
|
||||
|> E.R.fmap(g =>
|
||||
RenderTypes.ShapeRenderer.Symbolic.make(
|
||||
|> E.R.bind(_, 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,
|
||||
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 fmap = Rationale.Result.fmap;
|
||||
let bind = Rationale.Result.bind;
|
||||
let toExn = Belt.Result.getExn;
|
||||
let merge = (a, b) =>
|
||||
switch (a, b) {
|
||||
| (Error(e), _) => Error(e)
|
||||
|
|
Loading…
Reference in New Issue
Block a user