From ab5b54413bc7ee9b6ea699dc74c5a7e4d63c5338 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Thu, 1 Sep 2022 12:54:04 +0800 Subject: [PATCH] it string in tests --- packages/squiggle-lang/__tests__/Stdlib_test.res | 10 +++++++--- .../rescript/Distributions/PointSetDist/Discrete.res | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Stdlib_test.res b/packages/squiggle-lang/__tests__/Stdlib_test.res index 6b571fab..5919f3b4 100644 --- a/packages/squiggle-lang/__tests__/Stdlib_test.res +++ b/packages/squiggle-lang/__tests__/Stdlib_test.res @@ -7,10 +7,14 @@ let makeTest = (~only=false, str, item1, item2) => : test(str, () => expect(item1)->toEqual(item2)) describe("Stdlib", () => { - makeTest("min", Stdlib.Random.sample([1.0, 2.0], {probs: [0.5, 0.5], size: 10}) |> E.A.length, 10) makeTest( - "min", - Stdlib.Random.sample([1.0, 2.0], {probs: [0.5, 0.5], size: 10}) |> E.A.uniq |> E.A.Floats.sort, + "Length of Random.sample", + Stdlib.Random.sample([1.0, 2.0], {probs: [0.5, 0.5], size: 10})->E.A.length, + 10, + ) + makeTest( + "Random.sample returns elements from input array (will fail with very slim probability)", + Stdlib.Random.sample([1.0, 2.0], {probs: [0.5, 0.5], size: 10})->E.A.uniq->E.A.Floats.sort, [1.0, 2.0], ) }) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res index ba708f0b..7142f097 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res @@ -226,6 +226,6 @@ module T = Dist({ }) let sampleN = (t: t, n): array => { - let normalized = t |> T.normalize |> getShape + let normalized = t->T.normalize->getShape Stdlib.Random.sample(normalized.xs, {probs: normalized.ys, size: n}) }