From 7ceae186119273add26586322342a17df4295c1e Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Tue, 14 Jun 2022 16:54:59 -0700 Subject: [PATCH 1/2] Normalize after trunctae --- .../ReducerInterface/ReducerInterface_Distribution_test.res | 1 + .../squiggle-lang/src/rescript/Distributions/GenericDist.res | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res index a2fa37df..ecc07bfa 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res @@ -80,6 +80,7 @@ describe("eval on distribution functions", () => { testEval("truncateLeft(normal(5,2), 3)", "Ok(Point Set Distribution)") testEval("truncateRight(normal(5,2), 3)", "Ok(Point Set Distribution)") testEval("truncate(normal(5,2), 3, 8)", "Ok(Point Set Distribution)") + testEval("isNormalized(truncate(normal(5,2), 3, 8))", "Ok(true)") }) describe("exp", () => { diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res index f7d1e4f5..01532e2a 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res @@ -214,7 +214,7 @@ module Truncate = { | Some(r) => Ok(r) | None => toPointSetFn(t)->E.R2.fmap(t => { - DistributionTypes.PointSet(PointSetDist.T.truncate(leftCutoff, rightCutoff, t)) + DistributionTypes.PointSet(PointSetDist.T.truncate(leftCutoff, rightCutoff, t)->PointSetDist.T.normalize) }) } } From 6278dff81834f7e2e5f6fe1220ba4ccd6ce713a1 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Tue, 14 Jun 2022 17:00:09 -0700 Subject: [PATCH 2/2] Ran formatting --- .../squiggle-lang/src/rescript/Distributions/GenericDist.res | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res index 01532e2a..addbdaa1 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res @@ -214,7 +214,9 @@ module Truncate = { | Some(r) => Ok(r) | None => toPointSetFn(t)->E.R2.fmap(t => { - DistributionTypes.PointSet(PointSetDist.T.truncate(leftCutoff, rightCutoff, t)->PointSetDist.T.normalize) + DistributionTypes.PointSet( + PointSetDist.T.truncate(leftCutoff, rightCutoff, t)->PointSetDist.T.normalize, + ) }) } }