diff --git a/src/distPlus/renderers/DistPlusRenderer.re b/src/distPlus/renderers/DistPlusRenderer.re index 4e23e73f..36d8c857 100644 --- a/src/distPlus/renderers/DistPlusRenderer.re +++ b/src/distPlus/renderers/DistPlusRenderer.re @@ -1,14 +1,17 @@ let truncateIfShould = ( {recommendedLength, shouldTruncate}: RenderTypes.DistPlusRenderer.inputs, - {sampling:shape}: RenderTypes.ShapeRenderer.Combined.outputs, + outputs: RenderTypes.ShapeRenderer.Combined.outputs, dist, ) => { - (shouldTruncate && (shape |> E.O.isSome)) + shouldTruncate + && RenderTypes.ShapeRenderer.Combined.methodUsed(outputs) == `Sampling ? dist |> Distributions.DistPlus.T.truncate(recommendedLength) : dist; }; -let run = (inputs: RenderTypes.DistPlusRenderer.inputs): RenderTypes.DistPlusRenderer.outputs => { +let run = + (inputs: RenderTypes.DistPlusRenderer.inputs) + : RenderTypes.DistPlusRenderer.outputs => { let toDist = shape => Distributions.DistPlus.make( ~shape, @@ -25,9 +28,9 @@ let run = (inputs: RenderTypes.DistPlusRenderer.inputs): RenderTypes.DistPlusRen symbolicInputs: { length: inputs.recommendedLength, }, - }) - let shape = outputs |> RenderTypes.ShapeRenderer.Combined.getShape + }); + let shape = outputs |> RenderTypes.ShapeRenderer.Combined.getShape; let dist = shape |> E.O.fmap(toDist) |> E.O.fmap(truncateIfShould(inputs, outputs)); - RenderTypes.DistPlusRenderer.Outputs.make(outputs, dist) + RenderTypes.DistPlusRenderer.Outputs.make(outputs, dist); }; \ No newline at end of file diff --git a/src/distPlus/renderers/RenderTypes.re b/src/distPlus/renderers/RenderTypes.re index 9cf613b2..a8c2161d 100644 --- a/src/distPlus/renderers/RenderTypes.re +++ b/src/distPlus/renderers/RenderTypes.re @@ -59,6 +59,11 @@ module ShapeRenderer = { symbolic: option(Belt.Result.t(Symbolic.outputs, string)), sampling: option(Sampling.outputs), }; + let methodUsed = ({symbolic, sampling}:outputs) => switch(symbolic, sampling){ + | (Some(Ok(_)), _) => `Symbolic + | (None, Some({shape: Some(_)})) => `Sampling + | _ => `None + } let getShape = (r: outputs) => switch (r.symbolic, r.sampling) { | (Some(Ok({shape})), _) => Some(shape)