From 9090c442846e65c4647c0079da44e56c80bff9e7 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Sat, 23 Apr 2022 15:58:42 -0400 Subject: [PATCH 01/62] Fix subtraction not commuting under pointsets --- .../PointSetDist/AlgebraicShapeCombination.res | 4 +++- .../Distributions/PointSetDist/Continuous.res | 2 ++ .../rescript/Distributions/PointSetDist/Mixed.res | 14 ++++++++++++-- .../Distributions/PointSetDist/PointSetDist.res | 7 ++++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index fd7871cd..d68a9623 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -191,12 +191,14 @@ let combineShapesContinuousDiscrete = ( op: Operation.convolutionOperation, continuousShape: PointSetTypes.xyShape, discreteShape: PointSetTypes.xyShape, + flip: bool, ): PointSetTypes.xyShape => { let t1n = continuousShape |> XYShape.T.length let t2n = discreteShape |> XYShape.T.length // each x pair is added/subtracted - let fn = Operation.Convolution.toFn(op) + let opFunc = Operation.Convolution.toFn(op) + let fn = flip ? (a, b) => opFunc(b, a) : opFunc let outXYShapes: array> = Belt.Array.makeUninitializedUnsafe(t2n) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res index a8542bae..de5d65ed 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res @@ -278,6 +278,7 @@ let combineAlgebraicallyWithDiscrete = ( op: Operation.convolutionOperation, t1: t, t2: PointSetTypes.discreteShape, + flip: bool, ) => { let t1s = t1 |> getShape let t2s = t2.xyShape // TODO would like to use Discrete.getShape here, but current file structure doesn't allow for that @@ -294,6 +295,7 @@ let combineAlgebraicallyWithDiscrete = ( op, continuousAsLinear |> getShape, t2s, + flip, ) let combinedIntegralSum = switch op { diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res index 9961b51d..da604262 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res @@ -277,8 +277,18 @@ let combineAlgebraically = (op: Operation.convolutionOperation, t1: t, t2: t): t // continuous (*) continuous => continuous, but also // discrete (*) continuous => continuous (and vice versa). We have to take care of all combos and then combine them: let ccConvResult = Continuous.combineAlgebraically(op, t1.continuous, t2.continuous) - let dcConvResult = Continuous.combineAlgebraicallyWithDiscrete(op, t2.continuous, t1.discrete) - let cdConvResult = Continuous.combineAlgebraicallyWithDiscrete(op, t1.continuous, t2.discrete) + let dcConvResult = Continuous.combineAlgebraicallyWithDiscrete( + op, + t2.continuous, + t1.discrete, + true, + ) + let cdConvResult = Continuous.combineAlgebraicallyWithDiscrete( + op, + t1.continuous, + t2.discrete, + false, + ) let continuousConvResult = Continuous.sum([ccConvResult, dcConvResult, cdConvResult]) // ... finally, discrete (*) discrete => discrete, obviously: diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res index 6dacc40f..641532d6 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res @@ -46,9 +46,10 @@ let combineAlgebraically = (op: Operation.convolutionOperation, t1: t, t2: t): t switch (t1, t2) { | (Continuous(m1), Continuous(m2)) => Continuous.combineAlgebraically(op, m1, m2) |> Continuous.T.toPointSetDist - | (Continuous(m1), Discrete(m2)) - | (Discrete(m2), Continuous(m1)) => - Continuous.combineAlgebraicallyWithDiscrete(op, m1, m2) |> Continuous.T.toPointSetDist + | (Discrete(m1), Continuous(m2)) => + Continuous.combineAlgebraicallyWithDiscrete(op, m2, m1, true) |> Continuous.T.toPointSetDist + | (Continuous(m1), Discrete(m2)) => + Continuous.combineAlgebraicallyWithDiscrete(op, m1, m2, false) |> Continuous.T.toPointSetDist | (Discrete(m1), Discrete(m2)) => Discrete.combineAlgebraically(op, m1, m2) |> Discrete.T.toPointSetDist | (m1, m2) => Mixed.combineAlgebraically(op, toMixed(m1), toMixed(m2)) |> Mixed.T.toPointSetDist From 1102ceb4ec5441ade3c11b02ef94cfb977d6cf87 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 23 Apr 2022 17:51:41 -0400 Subject: [PATCH 02/62] Show correct errors early on when log(distribution) has bad arguments --- .../ReducerInterface_Distribution_test.res | 6 +- .../__tests__/TS/Symbolic_test.ts | 2 +- .../Distributions/GenericDist/GenericDist.res | 56 +++++++++++++++++-- .../rescript/Reducer/Reducer_ErrorValue.res | 2 +- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res index d4199f89..7b1e9653 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res @@ -22,7 +22,7 @@ describe("eval on distribution functions", () => { testEval("mean(-normal(5,2))", "Ok(-5)") }) describe("to", () => { - testEval("5 to 2", "Error(Math Error: Low value must be less than high value.)") + testEval("5 to 2", "Error(Distribution Math Error: Low value must be less than high value.)") testEval("to(2,5)", "Ok(Lognormal(1.1512925464970227,0.27853260523016377))") testEval("to(-2,2)", "Ok(Normal(0,1.2159136638235384))") }) @@ -88,10 +88,10 @@ describe("eval on distribution functions", () => { describe("log", () => { testEval("log(2, uniform(5,8))", "Ok(Sample Set Distribution)") - testEval("log(normal(5,2), 3)", "Error(Math Error: Operation returned complex result)") + testEval("log(normal(5,2), 3)", "Error(Distribution Math Error: Argument Error First input of logarithm must be fully greater than 0)") testEval( "log(normal(5,2), normal(10,1))", - "Error(Math Error: Operation returned complex result)", + "Error(Distribution Math Error: Argument Error First input of logarithm must be fully greater than 0)", ) testEval("log(uniform(5,8))", "Ok(Sample Set Distribution)") testEval("log10(uniform(5,8))", "Ok(Sample Set Distribution)") diff --git a/packages/squiggle-lang/__tests__/TS/Symbolic_test.ts b/packages/squiggle-lang/__tests__/TS/Symbolic_test.ts index 1bcb1e2e..b949a513 100644 --- a/packages/squiggle-lang/__tests__/TS/Symbolic_test.ts +++ b/packages/squiggle-lang/__tests__/TS/Symbolic_test.ts @@ -12,7 +12,7 @@ describe("Symbolic mean", () => { expect(squiggleResult.value).toBeCloseTo((x + y + z) / 3); } catch (err) { expect((err as Error).message).toEqual( - "Expected squiggle expression to evaluate but got error: Math Error: Triangular values must be increasing order." + "Expected squiggle expression to evaluate but got error: Distribution Math Error: Triangular values must be increasing order." ); } } diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index 47fb2c01..cdb0b7ed 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -186,6 +186,48 @@ module AlgebraicCombination = { ->E.R2.fmap(r => DistributionTypes.SampleSet(r)) } + /* + It would be good to also do a check to make sure that probability mass for the second + operand, at value 1.0, is 0 (or approximately 0). However, we'd ideally want to check + that both the probability mass and the probability density are greater than zero. + Right now we don't yet have a way of getting probability mass, so I'll leave this for later. + */ + let getLogarithmInputError = (t1: t, t2: t, ~toPointSetFn: toPointSetFn): option => { + let firstOperandIsGreaterThanZero = + toFloatOperation(t1, ~toPointSetFn, ~distToFloatOperation=#Cdf(1e-10)) |> E.R.fmap(r => + r > 0. + ) + let secondOperandIsGreaterThanZero = + toFloatOperation(t2, ~toPointSetFn, ~distToFloatOperation=#Cdf(1e-10)) |> E.R.fmap(r => + r > 0. + ) + let items = E.A.R.firstErrorOrOpen([ + firstOperandIsGreaterThanZero, + secondOperandIsGreaterThanZero, + ]) + switch items { + | Error(r) => Some(r) + | Ok([true, _]) => Some(ArgumentError("First input of logarithm must be fully greater than 0")) + | Ok([false, true]) => + Some(ArgumentError("Second input of logarithm must be fully greater than 0")) + | Ok([false, false]) => None + | Ok(_) => Some(Unreachable) + } + } + + let getInvalidOperationError = ( + t1: t, + t2: t, + ~toPointSetFn: toPointSetFn, + ~arithmeticOperation, + ): option => { + if arithmeticOperation == #Logarithm { + getLogarithmInputError(t1, t2, ~toPointSetFn) + } else { + None + } + } + //I'm (Ozzie) really just guessing here, very little idea what's best let expectedConvolutionCost: t => int = x => switch x { @@ -226,10 +268,16 @@ module AlgebraicCombination = { | Some(Ok(symbolicDist)) => Ok(Symbolic(symbolicDist)) | Some(Error(e)) => Error(OperationError(e)) | None => - switch chooseConvolutionOrMonteCarlo(arithmeticOperation, t1, t2) { - | MonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) - | Convolution(convOp) => - runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet(r)) + switch getInvalidOperationError(t1, t2, ~toPointSetFn, ~arithmeticOperation) { + | Some(e) => Error(e) + | None => + switch chooseConvolutionOrMonteCarlo(arithmeticOperation, t1, t2) { + | MonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) + | Convolution(convOp) => + runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet( + r, + )) + } } } } diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res index 48fae58c..96b73fd2 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res @@ -21,7 +21,7 @@ let errorToString = err => | REAssignmentExpected => "Assignment expected" | REExpressionExpected => "Expression expected" | REFunctionExpected(msg) => `Function expected: ${msg}` - | REDistributionError(err) => `Math Error: ${DistributionTypes.Error.toString(err)}` + | REDistributionError(err) => `Distribution Math Error: ${DistributionTypes.Error.toString(err)}` | REJavaScriptExn(omsg, oname) => { let answer = "JS Exception:" let answer = switch oname { From 51e2cf167cf0d843d191d4a72b85fece6302bb3a Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 23 Apr 2022 18:07:26 -0400 Subject: [PATCH 03/62] Turned error into actual error --- .../ReducerInterface_Distribution_test.res | 7 +++++-- .../src/rescript/Distributions/DistributionTypes.res | 2 ++ .../src/rescript/Distributions/GenericDist/GenericDist.res | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res index 7b1e9653..ac4dd790 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res @@ -88,10 +88,13 @@ describe("eval on distribution functions", () => { describe("log", () => { testEval("log(2, uniform(5,8))", "Ok(Sample Set Distribution)") - testEval("log(normal(5,2), 3)", "Error(Distribution Math Error: Argument Error First input of logarithm must be fully greater than 0)") + testEval( + "log(normal(5,2), 3)", + "Error(Distribution Math Error: Logarithm of input error: First input must completely greater than 0)", + ) testEval( "log(normal(5,2), normal(10,1))", - "Error(Distribution Math Error: Argument Error First input of logarithm must be fully greater than 0)", + "Error(Distribution Math Error: Logarithm of input error: First input must completely greater than 0)", ) testEval("log(uniform(5,8))", "Ok(Sample Set Distribution)") testEval("log10(uniform(5,8))", "Ok(Sample Set Distribution)") diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res index 98c49a21..f2c37540 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res @@ -14,6 +14,7 @@ type error = | OperationError(Operation.Error.t) | PointSetConversionError(SampleSetDist.pointsetConversionError) | SparklineError(PointSetTypes.sparklineError) // This type of error is for when we find a sparkline of a discrete distribution. This should probably at some point be actually implemented + | LogarithmOfDistributionError(string) | OtherError(string) @genType @@ -29,6 +30,7 @@ module Error = { | Unreachable => "Unreachable" | DistributionVerticalShiftIsInvalid => "Distribution Vertical Shift is Invalid" | ArgumentError(s) => `Argument Error ${s}` + | LogarithmOfDistributionError(s) => `Logarithm of input error: ${s}` | TooFewSamples => "Too Few Samples" | OperationError(err) => Operation.Error.toString(err) | PointSetConversionError(err) => SampleSetDist.pointsetConversionErrorToString(err) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index cdb0b7ed..4d4427cf 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -207,9 +207,10 @@ module AlgebraicCombination = { ]) switch items { | Error(r) => Some(r) - | Ok([true, _]) => Some(ArgumentError("First input of logarithm must be fully greater than 0")) + | Ok([true, _]) => + Some(LogarithmOfDistributionError("First input must completely greater than 0")) | Ok([false, true]) => - Some(ArgumentError("Second input of logarithm must be fully greater than 0")) + Some(LogarithmOfDistributionError("Second input must completely greater than 0")) | Ok([false, false]) => None | Ok(_) => Some(Unreachable) } From 260d159500543bd7c8b7770aecb820c84338fce0 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 23 Apr 2022 18:29:58 -0400 Subject: [PATCH 04/62] Make sure pointSetDist toPointSet is normalized --- .../SampleSetDist/SampleSetDist_ToPointSet.res | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist_ToPointSet.res b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist_ToPointSet.res index 3916e6fe..90537a12 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist_ToPointSet.res +++ b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist_ToPointSet.res @@ -133,9 +133,17 @@ let toPointSetDist = ( ~discrete=Some(discrete), ) + /* + I'm surprised that this doesn't come out normalized. My guess is that the KDE library + we're using is standardizing on something else. If we ever change that library, we should + check to see if we still need to do this. + */ + + let normalizedPointSet = pointSetDist->E.O2.fmap(PointSetDist.T.normalize) + let samplesParse: Internals.Types.outputs = { continuousParseParams: pdf |> E.O.fmap(snd), - pointSetDist: pointSetDist, + pointSetDist: normalizedPointSet, } samplesParse From 217361b843f52e213dec4dfb12c1a8b1cf8c4261 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 23 Apr 2022 19:07:32 -0400 Subject: [PATCH 05/62] Tried to fix tests of math issues --- .../Invariants/AlgebraicCombination_test.res | 18 ++++++++++-------- packages/squiggle-lang/__tests__/TS/JS_test.ts | 8 ++++---- .../__tests__/TS/SampleSet_test.ts | 10 ++-------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res index a0f492a1..83bcb668 100644 --- a/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res @@ -51,6 +51,7 @@ describe("(Algebraic) addition of distributions", () => { ->toBe(Some(2.5e1)) }) + test("uniform(low=9, high=10) + beta(alpha=2, beta=5)", () => { // let uniformMean = (9.0 +. 10.0) /. 2.0 // let betaMean = 1.0 /. (1.0 +. 5.0 /. 2.0) @@ -65,7 +66,8 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(0.01927225696028752, ~digits=1) // (uniformMean +. betaMean) + // Answer found from WolframAlpha: ``mean(uniform(9,10)) + mean(betaDistribution(2,5))`` + | Some(x) => x->expect->toBeSoCloseTo(9.786, ~digits=1) // (uniformMean +. betaMean) } }) test("beta(alpha=2, beta=5) + uniform(low=9, high=10)", () => { @@ -82,7 +84,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(0.019275414920485248, ~digits=1) // (uniformMean +. betaMean) + | Some(x) => x->expect->toBeSoCloseTo(9.786, ~digits=1) // (uniformMean +. betaMean) } }) }) @@ -163,7 +165,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(0.001978994877226945, ~digits=3) + | Some(x) => x->expect->toBeSoCloseTo(1.025, ~digits=1) } }) test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).pdf(10)", () => { @@ -178,7 +180,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(0.001978994877226945, ~digits=3) + | Some(x) => x->expect->toBeSoCloseTo(0.98, ~digits=1) } }) }) @@ -254,7 +256,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(0.0013961779932477507, ~digits=3) + | Some(x) => x->expect->toBeSoCloseTo(0.70, ~digits=1) } }) test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).cdf(10)", () => { @@ -269,7 +271,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(0.001388898111625753, ~digits=3) + | Some(x) => x->expect->toBeSoCloseTo(0.71, ~digits=1) } }) }) @@ -346,7 +348,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(10.927078217530806, ~digits=0) + | Some(x) => x->expect->toBeSoCloseTo(9.174960348568693, ~digits=0) } }) test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).inv(2e-2)", () => { @@ -361,7 +363,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(10.915396627014363, ~digits=0) + | Some(x) => x->expect->toBeSoCloseTo(9.168291999681523, ~digits=0) } }) }) diff --git a/packages/squiggle-lang/__tests__/TS/JS_test.ts b/packages/squiggle-lang/__tests__/TS/JS_test.ts index 8e6db265..7a68160c 100644 --- a/packages/squiggle-lang/__tests__/TS/JS_test.ts +++ b/packages/squiggle-lang/__tests__/TS/JS_test.ts @@ -56,16 +56,16 @@ describe("Distribution", () => { ); test("mean", () => { - expect(dist.mean().value).toBeCloseTo(3.737); + expect(dist.mean().value).toBeCloseTo(5.3913); }); test("pdf", () => { expect(dist.pdf(5.0).value).toBeCloseTo(0.0431); }); test("cdf", () => { - expect(dist.cdf(5.0).value).toBeCloseTo(0.155); + expect(dist.cdf(5.0).value).toBeCloseTo(0.224); }); test("inv", () => { - expect(dist.inv(0.5).value).toBeCloseTo(9.458); + expect(dist.inv(0.5).value).toBeCloseTo(6.0); }); test("toPointSet", () => { expect( @@ -87,6 +87,6 @@ describe("Distribution", () => { resultMap(dist.pointwiseAdd(dist2), (r: Distribution) => r.toSparkline(20) ).value - ).toEqual(Ok("▁▂▅██▅▅▅▆▇█▆▅▃▃▂▂▁▁▁")); + ).toEqual(Ok("▁▂▅█▇▅▅▆▇██▇▅▄▃▃▃▂▁▁")); }); }); diff --git a/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts b/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts index c4599f7c..677dc44a 100644 --- a/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts +++ b/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts @@ -46,7 +46,7 @@ describe("cumulative density function", () => { ); }); - test("at the highest number in the sample is close to 1", () => { + test("at the highest number in the sample to be approximately 1", () => { fc.assert( fc.property(arrayGen(), (xs_) => { let xs = Array.from(xs_); @@ -57,13 +57,7 @@ describe("cumulative density function", () => { { sampleCount: n, xyPointLength: 100 } ); let cdfValue = dist.cdf(max).value; - let min = Math.min(...xs); - let epsilon = 5e-3; - if (max - min < epsilon) { - expect(cdfValue).toBeLessThan(1 - epsilon); - } else { - expect(dist.cdf(max).value).toBeGreaterThan(1 - epsilon); - } + expect(cdfValue).toBeCloseTo(1.0, 2) }) ); }); From 5563a5dc40ea0a299ee407af234396600b6ff7be Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 23 Apr 2022 19:18:02 -0400 Subject: [PATCH 06/62] Prettier --- .../Distributions/Invariants/AlgebraicCombination_test.res | 1 - packages/squiggle-lang/__tests__/TS/SampleSet_test.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res index 83bcb668..430bc900 100644 --- a/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res @@ -51,7 +51,6 @@ describe("(Algebraic) addition of distributions", () => { ->toBe(Some(2.5e1)) }) - test("uniform(low=9, high=10) + beta(alpha=2, beta=5)", () => { // let uniformMean = (9.0 +. 10.0) /. 2.0 // let betaMean = 1.0 /. (1.0 +. 5.0 /. 2.0) diff --git a/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts b/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts index 677dc44a..9891839a 100644 --- a/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts +++ b/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts @@ -57,7 +57,7 @@ describe("cumulative density function", () => { { sampleCount: n, xyPointLength: 100 } ); let cdfValue = dist.cdf(max).value; - expect(cdfValue).toBeCloseTo(1.0, 2) + expect(cdfValue).toBeCloseTo(1.0, 2); }) ); }); From 666aef13dd79e0e8d8d316853ab4e819bc4186d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 14:41:12 +0000 Subject: [PATCH 07/62] :arrow_up: Bump antd from 4.19.5 to 4.20.0 Bumps [antd](https://github.com/ant-design/ant-design) from 4.19.5 to 4.20.0. - [Release notes](https://github.com/ant-design/ant-design/releases) - [Changelog](https://github.com/ant-design/ant-design/blob/master/CHANGELOG.en-US.md) - [Commits](https://github.com/ant-design/ant-design/compare/4.19.5...4.20.0) --- updated-dependencies: - dependency-name: antd dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- packages/components/package.json | 2 +- yarn.lock | 215 ++++++++++++++++--------------- 2 files changed, 109 insertions(+), 108 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index 809e0596..f6e8e474 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -12,7 +12,7 @@ "@types/node": "^17.0.25", "@types/react": "^18.0.3", "@types/react-dom": "^18.0.2", - "antd": "^4.19.3", + "antd": "^4.20.0", "cross-env": "^7.0.3", "lodash": "^4.17.21", "react": "^18.0.0", diff --git a/yarn.lock b/yarn.lock index d646d829..89449825 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4887,10 +4887,10 @@ ansi-to-html@^0.6.11: dependencies: entities "^2.0.0" -antd@^4.19.3: - version "4.19.5" - resolved "https://registry.yarnpkg.com/antd/-/antd-4.19.5.tgz#38d08f3e1391a7a69c2ca76f50968bb12ec2ac93" - integrity sha512-C4H/VJqlVO5iMvHZyiV27R8SbPs4jsOKCGPhDXIHUry/RnUCbMmVeQaPRfUIxSI1NbqDflsuQfevPtz1svyIlg== +antd@^4.20.0: + version "4.20.0" + resolved "https://registry.yarnpkg.com/antd/-/antd-4.20.0.tgz#5f5fa4fccb90dd3e091c8d6e9d503114d98d862f" + integrity sha512-Msowfvabsn/yJIo3qYU0vMqGb31OUylMeFRDilosBViG2AS8R2VB2IX53kbw4kFV3vr7fr2HXcuQkf/FMLU+Dg== dependencies: "@ant-design/colors" "^6.0.0" "@ant-design/icons" "^4.7.0" @@ -4901,39 +4901,40 @@ antd@^4.19.3: copy-to-clipboard "^3.2.0" lodash "^4.17.21" memoize-one "^6.0.0" - moment "^2.25.3" - rc-cascader "~3.2.1" + moment "^2.29.2" + rc-cascader "~3.5.0" rc-checkbox "~2.3.0" rc-collapse "~3.1.0" - rc-dialog "~8.6.0" + rc-dialog "~8.8.1" rc-drawer "~4.4.2" - rc-dropdown "~3.3.2" - rc-field-form "~1.25.0" - rc-image "~5.2.5" + rc-dropdown "~3.5.0" + rc-field-form "~1.26.1" + rc-image "~5.6.0" rc-input "~0.0.1-alpha.5" rc-input-number "~7.3.0" - rc-mentions "~1.6.1" - rc-menu "~9.3.2" - rc-motion "^2.4.4" - rc-notification "~4.5.7" + rc-mentions "~1.7.0" + rc-menu "~9.5.5" + rc-motion "^2.5.1" + rc-notification "~4.6.0" rc-pagination "~3.1.9" rc-picker "~2.6.4" rc-progress "~3.2.1" rc-rate "~2.9.0" rc-resize-observer "^1.2.0" - rc-select "~14.0.2" - rc-slider "~10.0.0-alpha.4" + rc-segmented "~2.0.0" + rc-select "~14.1.1" + rc-slider "~10.0.0" rc-steps "~4.1.0" rc-switch "~3.2.0" - rc-table "~7.23.0" - rc-tabs "~11.10.0" + rc-table "~7.24.0" + rc-tabs "~11.13.0" rc-textarea "~0.3.0" rc-tooltip "~5.1.1" - rc-tree "~5.4.3" - rc-tree-select "~5.1.1" + rc-tree "~5.5.0" + rc-tree-select "~5.3.0" rc-trigger "^5.2.10" rc-upload "~4.3.0" - rc-util "^5.19.3" + rc-util "^5.20.0" scroll-into-view-if-needed "^2.2.25" anymatch@^2.0.0: @@ -11925,10 +11926,10 @@ moduleserve@0.9.1: send "^0.17.1" serve-static "^1.14.1" -moment@^2.24.0, moment@^2.25.3: - version "2.29.2" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.2.tgz#00910c60b20843bcba52d37d58c628b47b1f20e4" - integrity sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg== +moment@^2.24.0, moment@^2.29.2: + version "2.29.3" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3" + integrity sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw== move-concurrently@^1.0.1: version "1.0.1" @@ -13855,16 +13856,16 @@ rc-align@^4.0.0: rc-util "^5.3.0" resize-observer-polyfill "^1.5.1" -rc-cascader@~3.2.1: - version "3.2.9" - resolved "https://registry.yarnpkg.com/rc-cascader/-/rc-cascader-3.2.9.tgz#b993fa2829d77e9cb98cf4b7711e13a1b1812db6" - integrity sha512-Mvkegzf506PD7qc38kg2tGllIBXs5dio3DPg+NER7SiOfCXBCATWYEs0CbUp8JDQgYHoHF0vPvFMYtxFTJuWaw== +rc-cascader@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/rc-cascader/-/rc-cascader-3.5.0.tgz#a49b632bc2d0c8ef31b212c8ddd0bea346e64877" + integrity sha512-rpXnWCfvk7Frh2dBzMoA0c7i0nn6aJU7L2NZo8R8pNkrT0sKgytQSpdtPWP+Pq8IkvwbEd8BU8Z8OnOljcqgZg== dependencies: "@babel/runtime" "^7.12.5" array-tree-filter "^2.1.0" classnames "^2.3.1" - rc-select "~14.0.0-alpha.23" - rc-tree "~5.4.3" + rc-select "~14.1.0" + rc-tree "~5.5.0" rc-util "^5.6.1" rc-checkbox@~2.3.0: @@ -13886,15 +13887,15 @@ rc-collapse@~3.1.0: rc-util "^5.2.1" shallowequal "^1.1.0" -rc-dialog@~8.6.0: - version "8.6.0" - resolved "https://registry.yarnpkg.com/rc-dialog/-/rc-dialog-8.6.0.tgz#3b228dac085de5eed8c6237f31162104687442e7" - integrity sha512-GSbkfqjqxpZC5/zc+8H332+q5l/DKUhpQr0vdX2uDsxo5K0PhvaMEVjyoJUTkZ3+JstEADQji1PVLVb/2bJeOQ== +rc-dialog@~8.8.0, rc-dialog@~8.8.1: + version "8.8.1" + resolved "https://registry.yarnpkg.com/rc-dialog/-/rc-dialog-8.8.1.tgz#cd8897fbee1de0eab6d237a6abe1e4db8d09dd72" + integrity sha512-7M1WKZCjfIABKEaJVskdYvb80z+RX7I11PeSjPVfLOOaJAmIepvDEd0alBtOZvOL3fZFWlMs4JVZtp9LZgONxA== dependencies: "@babel/runtime" "^7.10.1" classnames "^2.2.6" rc-motion "^2.3.0" - rc-util "^5.6.1" + rc-util "^5.21.0" rc-drawer@~4.4.2: version "4.4.3" @@ -13905,43 +13906,33 @@ rc-drawer@~4.4.2: classnames "^2.2.6" rc-util "^5.7.0" -rc-dropdown@^3.2.0: - version "3.4.1" - resolved "https://registry.yarnpkg.com/rc-dropdown/-/rc-dropdown-3.4.1.tgz#909e8c666a9f994bd804147aaf7f8f5859dae0db" - integrity sha512-Q+1s64b21H5Ye1/1MVY9hKrdsv2MJhrtrnZ4R2O3TqeHoJTddvkDp9VmjMYFEKLdkKzYZ7BIA+9bvNB5dAILXg== +rc-dropdown@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/rc-dropdown/-/rc-dropdown-3.5.0.tgz#6ff2e6aaacd3641aa4040cfa941ab9634ad5f1ed" + integrity sha512-HHMpzO6AJt3I2jBG8fFK9LqFMQhHn/V09AzQnqCCV8Fp22tNCS98Obelcc4C8T6ZlZR+/w01im0BQVP3o1Y+Cw== dependencies: "@babel/runtime" "^7.10.1" classnames "^2.2.6" rc-trigger "^5.0.4" rc-util "^5.17.0" -rc-dropdown@~3.3.2: - version "3.3.3" - resolved "https://registry.yarnpkg.com/rc-dropdown/-/rc-dropdown-3.3.3.tgz#17ba32ebd066ae397b00e9e4d570c7c21daed88f" - integrity sha512-UNe68VpvtrpU0CS4jh5hD4iGqzi4Pdp7uOya6+H3QIEZxe7K+Xs11BNjZm6W4MaL0jTmzUj+bxvnq5bP3rRoVQ== - dependencies: - "@babel/runtime" "^7.10.1" - classnames "^2.2.6" - rc-trigger "^5.0.4" - rc-util "^5.17.0" - -rc-field-form@~1.25.0: - version "1.25.2" - resolved "https://registry.yarnpkg.com/rc-field-form/-/rc-field-form-1.25.2.tgz#de418194b7aca2f1b6e0e059edd97b5cf624f68a" - integrity sha512-FXGScWibDlwIlKY15T1YOA7VTtMJwqxxXdDjHB56ZNx7wGbE4vK+Fe2zcymyakGZD0ej8NUP5LGr7qBVWaVpUQ== +rc-field-form@~1.26.1: + version "1.26.2" + resolved "https://registry.yarnpkg.com/rc-field-form/-/rc-field-form-1.26.2.tgz#69d92811eed09f9e1f74704695b13253bb2ae534" + integrity sha512-Q1QdpLAt/kxd119kJwGfFvn/ZIzjzTBJsCscy5k0z3g+eRMHkI0Exij6SE2D42N7FAzVkvuXTvzqWSiFGeer7g== dependencies: "@babel/runtime" "^7.8.4" async-validator "^4.0.2" rc-util "^5.8.0" -rc-image@~5.2.5: - version "5.2.5" - resolved "https://registry.yarnpkg.com/rc-image/-/rc-image-5.2.5.tgz#44e6ffc842626827960e7ab72e1c0d6f3a8ce440" - integrity sha512-qUfZjYIODxO0c8a8P5GeuclYXZjzW4hV/5hyo27XqSFo1DmTCs2HkVeQObkcIk5kNsJtgsj1KoPThVsSc/PXOw== +rc-image@~5.6.0: + version "5.6.1" + resolved "https://registry.yarnpkg.com/rc-image/-/rc-image-5.6.1.tgz#60662a8fc0fe91d7ebd7fd5ee972d5b6226850e2" + integrity sha512-nmcobNCfmeevsep6eL7KNHVwFdLz4As4Vx0o90nnUFNzZ9Pqost1s10gOf4Wl6XW2iMR9LU6ztm5EazM7yA4Gg== dependencies: "@babel/runtime" "^7.11.2" classnames "^2.2.6" - rc-dialog "~8.6.0" + rc-dialog "~8.8.0" rc-util "^5.0.6" rc-input-number@~7.3.0: @@ -13962,22 +13953,22 @@ rc-input@~0.0.1-alpha.5: classnames "^2.2.1" rc-util "^5.18.1" -rc-mentions@~1.6.1: - version "1.6.5" - resolved "https://registry.yarnpkg.com/rc-mentions/-/rc-mentions-1.6.5.tgz#d9516abd19a757c674df1c88a3459628fe95a149" - integrity sha512-CUU4+q+awG2pA0l/tG2kPB2ytWbKQUkFxVeKwacr63w7crE/yjfzrFXxs/1fxhyEbQUWdAZt/L25QBieukYQ5w== +rc-mentions@~1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/rc-mentions/-/rc-mentions-1.7.0.tgz#717be883e92b9085df900ab5a3ffab7379247bfa" + integrity sha512-d3tZWCQIseQrn5ZpnUuaeKTQctgGwVzcEUVpVswxvnsLB1/e2H12xHzVqH87AvPkHMs9m3oFZINbuC5Qxevv6g== dependencies: "@babel/runtime" "^7.10.1" classnames "^2.2.6" - rc-menu "~9.3.2" + rc-menu "~9.5.1" rc-textarea "^0.3.0" rc-trigger "^5.0.4" rc-util "^5.0.1" -rc-menu@~9.3.2: - version "9.3.2" - resolved "https://registry.yarnpkg.com/rc-menu/-/rc-menu-9.3.2.tgz#bb842d37ebf71da912bea201cf7ef0a27267ad49" - integrity sha512-h3m45oY1INZyqphGELkdT0uiPnFzxkML8m0VMhJnk2fowtqfiT7F5tJLT3znEVaPIY80vMy1bClCkgq8U91CzQ== +rc-menu@~9.5.1, rc-menu@~9.5.5: + version "9.5.5" + resolved "https://registry.yarnpkg.com/rc-menu/-/rc-menu-9.5.5.tgz#aa2f151d4191ed089dc1a8141fe365c9b77d61a9" + integrity sha512-wj2y2BAKwSMyWXO3RBf9sNN5V+DFWxFl45Ma6qQEHA5nwwh7p07bNgc6AAJc+L1+LAz+rWz3AU8PYyT17hMHCw== dependencies: "@babel/runtime" "^7.10.1" classnames "2.x" @@ -13987,24 +13978,24 @@ rc-menu@~9.3.2: rc-util "^5.12.0" shallowequal "^1.1.0" -rc-motion@^2.0.0, rc-motion@^2.0.1, rc-motion@^2.2.0, rc-motion@^2.3.0, rc-motion@^2.3.4, rc-motion@^2.4.3, rc-motion@^2.4.4: - version "2.4.9" - resolved "https://registry.yarnpkg.com/rc-motion/-/rc-motion-2.4.9.tgz#fa6e4b044b971845ffb83696e1c4d11b81bf132f" - integrity sha512-lrIpBQQ5gIDVedaubnhXuTjC3zpW7HvC/34KyvcHlf6fBjuBlwv45PbonFhmk4Rgu7gLQYrKoMGgFVXqxxyLCw== +rc-motion@^2.0.0, rc-motion@^2.0.1, rc-motion@^2.2.0, rc-motion@^2.3.0, rc-motion@^2.3.4, rc-motion@^2.4.3, rc-motion@^2.4.4, rc-motion@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/rc-motion/-/rc-motion-2.5.1.tgz#3eceb7d891079c0f67a72639d30e168b91839e03" + integrity sha512-h3GKMjFJkK+4z6fNfVlIMrb7WFCZsreivVvHOBb38cKcpKDx5g3kpHwn5Ekbo1+g0nnC02Dtap2trfCAPGxllw== dependencies: "@babel/runtime" "^7.11.1" classnames "^2.2.1" - rc-util "^5.19.2" + rc-util "^5.21.0" -rc-notification@~4.5.7: - version "4.5.7" - resolved "https://registry.yarnpkg.com/rc-notification/-/rc-notification-4.5.7.tgz#265e6e6a0c1a0fac63d6abd4d832eb8ff31522f1" - integrity sha512-zhTGUjBIItbx96SiRu3KVURcLOydLUHZCPpYEn1zvh+re//Tnq/wSxN4FKgp38n4HOgHSVxcLEeSxBMTeBBDdw== +rc-notification@~4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/rc-notification/-/rc-notification-4.6.0.tgz#4e76fc2d0568f03cc93ac18c9e20763ebe29fa46" + integrity sha512-xF3MKgIoynzjQAO4lqsoraiFo3UXNYlBfpHs0VWvwF+4pimen9/H1DYLN2mfRWhHovW6gRpla73m2nmyIqAMZQ== dependencies: "@babel/runtime" "^7.10.1" classnames "2.x" rc-motion "^2.2.0" - rc-util "^5.0.1" + rc-util "^5.20.1" rc-overflow@^1.0.0, rc-overflow@^1.2.0: version "1.2.4" @@ -14066,10 +14057,20 @@ rc-resize-observer@^1.0.0, rc-resize-observer@^1.1.0, rc-resize-observer@^1.2.0: rc-util "^5.15.0" resize-observer-polyfill "^1.5.1" -rc-select@~14.0.0-alpha.23, rc-select@~14.0.0-alpha.8, rc-select@~14.0.2: - version "14.0.6" - resolved "https://registry.yarnpkg.com/rc-select/-/rc-select-14.0.6.tgz#93be0b185a9d66dc84795e079121f0f65310d8bf" - integrity sha512-HMb2BwfTvBxMmIWTR/afP4bcRJLbVKFSBW/VFfL5Z+kdV2XlrYdlliK2uHY7pRRvW16PPGwmOwGfV+eoulPINw== +rc-segmented@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/rc-segmented/-/rc-segmented-2.0.0.tgz#209b55bec85c1a8b1821c30e62d3ebef4da04b52" + integrity sha512-YsdS+aP7E6ZMEY35WSlewJIsrjPbBSP4X/7RvZtzLExKDZwFvXdCPCbWFVDNks4jOYY9TUPYt7qlVifEu9/zXA== + dependencies: + "@babel/runtime" "^7.11.1" + classnames "^2.2.1" + rc-motion "^2.4.4" + rc-util "^5.17.0" + +rc-select@~14.1.0, rc-select@~14.1.1: + version "14.1.1" + resolved "https://registry.yarnpkg.com/rc-select/-/rc-select-14.1.1.tgz#87a51ce515aba5cfa083ae0f5be15e7c550ad93f" + integrity sha512-l2TSSy/rwvfob0SmQ0sPQ1pUMUq65u6U4Y9lc9dvQOMSMzDSga4b3tEgIgzN1YKzakV65wGXMOBVecjixPEZ4Q== dependencies: "@babel/runtime" "^7.10.1" classnames "2.x" @@ -14079,7 +14080,7 @@ rc-select@~14.0.0-alpha.23, rc-select@~14.0.0-alpha.8, rc-select@~14.0.2: rc-util "^5.16.1" rc-virtual-list "^3.2.0" -rc-slider@~10.0.0-alpha.4: +rc-slider@~10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/rc-slider/-/rc-slider-10.0.0.tgz#8ffe1dd3c8799c9d1f81ac808976f18af3dca206" integrity sha512-Bk54UIKWW4wyhHcL8ehAxt+wX+n69dscnHTX6Uv0FMxSke/TGrlkZz1LSIWblCpfE2zr/dwR2Ca8nZGk3U+Tbg== @@ -14108,10 +14109,10 @@ rc-switch@~3.2.0: classnames "^2.2.1" rc-util "^5.0.1" -rc-table@~7.23.0: - version "7.23.2" - resolved "https://registry.yarnpkg.com/rc-table/-/rc-table-7.23.2.tgz#f6f906e8fafb05ddbfdd69d450feb875ce260a7b" - integrity sha512-opc2IBJOetsPSdNI+u1Lh9yY4Ks+EMgo1oJzZN+yIV4fRcgP81tHtxdPOVvXPFI4rUMO8CKnmHbGPU7jxMRAeg== +rc-table@~7.24.0: + version "7.24.1" + resolved "https://registry.yarnpkg.com/rc-table/-/rc-table-7.24.1.tgz#15ecabc9d69f8300b988caa52986e3b215150f2b" + integrity sha512-DRWpv5z5pmOaTmy5GqWoskeV1thaOu5HuD+2f61b/CkbBqlgJR3cygc5R/Qvd2uVW6pHU0lYulhmz0VLVFm+rw== dependencies: "@babel/runtime" "^7.10.1" classnames "^2.2.5" @@ -14119,15 +14120,15 @@ rc-table@~7.23.0: rc-util "^5.14.0" shallowequal "^1.1.0" -rc-tabs@~11.10.0: - version "11.10.8" - resolved "https://registry.yarnpkg.com/rc-tabs/-/rc-tabs-11.10.8.tgz#832d3425bde232b9c4447075b5deef3e2fefa48f" - integrity sha512-uK+x+eJ8WM4jiXoqGa+P+JUQX2Wlkj9f0o/5dyOw42B6YLnHJN80uTVcCeAmtA1N0xjPW0GNSZvUm4SU3jAYpw== +rc-tabs@~11.13.0: + version "11.13.0" + resolved "https://registry.yarnpkg.com/rc-tabs/-/rc-tabs-11.13.0.tgz#083eed578f8ad02dc0d462d73da487fe32e3a573" + integrity sha512-aUw1Pq0B1a2zGX4o/m3yrQycZcCLgDp6gKwn8IAU07q148RRONsVGxi0oLVVe5SE51kOB+j0bk1RX43ZBdZNgA== dependencies: "@babel/runtime" "^7.11.2" classnames "2.x" - rc-dropdown "^3.2.0" - rc-menu "~9.3.2" + rc-dropdown "~3.5.0" + rc-menu "~9.5.1" rc-resize-observer "^1.0.0" rc-util "^5.5.0" @@ -14150,21 +14151,21 @@ rc-tooltip@^5.0.1, rc-tooltip@~5.1.1: "@babel/runtime" "^7.11.2" rc-trigger "^5.0.0" -rc-tree-select@~5.1.1: - version "5.1.5" - resolved "https://registry.yarnpkg.com/rc-tree-select/-/rc-tree-select-5.1.5.tgz#ed51cc45eb490d18d67eba6864e9c7321199fcc0" - integrity sha512-OXAwCFO0pQmb48NcjUJtiX6rp4FroCXMfzqPmuVVoBGBV/uwO1TPyb+uBZ2/972zkCA8u4je5M5Qx51sL8y7jg== +rc-tree-select@~5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/rc-tree-select/-/rc-tree-select-5.3.0.tgz#6edd19d1066ad2bfa212f043c3ff701b93828026" + integrity sha512-UN6CUBulmch+CsihnJ73+DtWijEB1hVTC8sdVxq6E0teVAkHQZUvDj+cwZShtShAKvWwXy73PZ1hIHEUrmVcKw== dependencies: "@babel/runtime" "^7.10.1" classnames "2.x" - rc-select "~14.0.0-alpha.8" - rc-tree "~5.4.3" + rc-select "~14.1.0" + rc-tree "~5.5.0" rc-util "^5.16.1" -rc-tree@~5.4.3: - version "5.4.4" - resolved "https://registry.yarnpkg.com/rc-tree/-/rc-tree-5.4.4.tgz#2ea3663ad3c566aef79a46ba6a1e050d24323e01" - integrity sha512-2qoObRgp31DBXmVzMJmo4qmwP20XEa4hR3imWQtRPcgN3pmljW3WKFmZRrYdOFHz7CyTnRsFZR065bBkIoUpiA== +rc-tree@~5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/rc-tree/-/rc-tree-5.5.0.tgz#ba7c8aea2ad29f40a9c7168e490300f7a50c0f22" + integrity sha512-vpKeFsDyj7weik8UPseCTaSNAPt939qn1dQd8goSbRDajbjJEja0v/WFXyRhOiF1HLemNTfqMz4MYc9qlqyNXg== dependencies: "@babel/runtime" "^7.10.1" classnames "2.x" @@ -14192,10 +14193,10 @@ rc-upload@~4.3.0: classnames "^2.2.5" rc-util "^5.2.0" -rc-util@^5.0.1, rc-util@^5.0.6, rc-util@^5.12.0, rc-util@^5.14.0, rc-util@^5.15.0, rc-util@^5.16.1, rc-util@^5.17.0, rc-util@^5.18.1, rc-util@^5.19.2, rc-util@^5.19.3, rc-util@^5.2.0, rc-util@^5.2.1, rc-util@^5.3.0, rc-util@^5.4.0, rc-util@^5.5.0, rc-util@^5.6.1, rc-util@^5.7.0, rc-util@^5.8.0, rc-util@^5.9.4, rc-util@^5.9.8: - version "5.20.1" - resolved "https://registry.yarnpkg.com/rc-util/-/rc-util-5.20.1.tgz#323590df56175f60b1a67d2ba76f04c3c2cb84cd" - integrity sha512-2IEyErPAYl0Up5gBu71e8IkOs+/SL9XRUvnGhtsr7IHlXLx2OsbQKTDpWacJbzLCmNcgJylDGj1kiklx+zagRA== +rc-util@^5.0.1, rc-util@^5.0.6, rc-util@^5.12.0, rc-util@^5.14.0, rc-util@^5.15.0, rc-util@^5.16.1, rc-util@^5.17.0, rc-util@^5.18.1, rc-util@^5.19.2, rc-util@^5.2.0, rc-util@^5.2.1, rc-util@^5.20.0, rc-util@^5.20.1, rc-util@^5.21.0, rc-util@^5.3.0, rc-util@^5.4.0, rc-util@^5.5.0, rc-util@^5.6.1, rc-util@^5.7.0, rc-util@^5.8.0, rc-util@^5.9.4, rc-util@^5.9.8: + version "5.21.2" + resolved "https://registry.yarnpkg.com/rc-util/-/rc-util-5.21.2.tgz#fa23277ba84e5561af2febdca64de3fc2b3e1528" + integrity sha512-QuuZ2tKMScGtxSx3rLzgPGGDZm/np7phMqA7OcDidSf44abvSk+AdtdD7ZvQPvCEtdC6nCSI5tEVnUaYjjD9/w== dependencies: "@babel/runtime" "^7.12.5" react-is "^16.12.0" From 9137581ce078e8153891e86dbd56ba5bfc653e93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 14:49:28 +0000 Subject: [PATCH 08/62] :arrow_up: Bump @types/node from 17.0.25 to 17.0.26 Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 17.0.25 to 17.0.26. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- packages/components/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index f6e8e474..f64b23ac 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -9,7 +9,7 @@ "@testing-library/user-event": "^14.1.1", "@types/jest": "^27.4.0", "@types/lodash": "^4.14.182", - "@types/node": "^17.0.25", + "@types/node": "^17.0.26", "@types/react": "^18.0.3", "@types/react-dom": "^18.0.2", "antd": "^4.20.0", diff --git a/yarn.lock b/yarn.lock index 89449825..575fa6fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3966,10 +3966,10 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@^17.0.25", "@types/node@^17.0.5": - version "17.0.25" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.25.tgz#527051f3c2f77aa52e5dc74e45a3da5fb2301448" - integrity sha512-wANk6fBrUwdpY4isjWrKTufkrXdu1D2YHCot2fD/DfWxF5sMrVSA+KN7ydckvaTCh0HiqX9IVl0L5/ZoXg5M7w== +"@types/node@*", "@types/node@^17.0.26", "@types/node@^17.0.5": + version "17.0.26" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.26.tgz#1bbff9b23ee5a64f87b4f30c0c854b112ee2e635" + integrity sha512-z/FG/6DUO7pnze3AE3TBGIjGGKkvCcGcWINe1C7cADY8hKLJPDYpzsNE37uExQ4md5RFtTCvg+M8Mu1Enyeg2A== "@types/node@^14.0.10": version "14.18.13" From d7151907d3c3c6133bcced2eda89fec8b47eecf2 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 25 Apr 2022 11:44:50 -0400 Subject: [PATCH 09/62] Ensure xyShape is ordered by x coordinates when multiplying by negatives Value: [0.00001 to 0.0005] --- .../AlgebraicShapeCombination_test.res | 16 ++++++++++++++++ packages/squiggle-lang/jest.config.js | 1 - .../PointSetDist/AlgebraicShapeCombination.res | 9 +++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res diff --git a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res new file mode 100644 index 00000000..74a378c5 --- /dev/null +++ b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res @@ -0,0 +1,16 @@ +open Jest +open TestHelpers + +describe("combine with discrete", () => { + makeTest( + "keep order when multiplying by negative number", + AlgebraicShapeCombination.checkOrdered( + AlgebraicShapeCombination.combineShapesContinuousDiscrete( + #Multiply, + {xs: [0., 1.], ys: [1., 1.]}, + {xs: [-1.], ys: [1.]}, + ), + ), // Multiply distribution by -1 + true, + ) +}) diff --git a/packages/squiggle-lang/jest.config.js b/packages/squiggle-lang/jest.config.js index 520f4693..71babb3c 100644 --- a/packages/squiggle-lang/jest.config.js +++ b/packages/squiggle-lang/jest.config.js @@ -2,7 +2,6 @@ module.exports = { preset: "ts-jest", testEnvironment: "node", - bail: true, setupFilesAfterEnv: [ "/../../node_modules/bisect_ppx/src/runtime/js/jest.bs.js", ], diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index d6ff1d31..d4060cb8 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -215,7 +215,6 @@ let combineShapesContinuousDiscrete = ( continuousShape.ys[i] *. discreteShape.ys[j], ), ) |> ignore - () } Belt.Array.set(outXYShapes, j, dxyShape) |> ignore () @@ -225,9 +224,13 @@ let combineShapesContinuousDiscrete = ( // creates a new continuous shape for each one of the discrete points, and collects them in outXYShapes. let dxyShape: array<(float, float)> = Belt.Array.makeUninitializedUnsafe(t1n) for i in 0 to t1n - 1 { + // If this operation would flip the x axis (such as -1 * normal(5, 2)), + // then we want to fill the shape in backwards to ensure all the points + // are still in the right order + let index = discreteShape.xs[j] > 0.0 ? i : t1n - 1 - i Belt.Array.set( dxyShape, - i, + index, ( fn(continuousShape.xs[i], discreteShape.xs[j]), continuousShape.ys[i] *. discreteShape.ys[j] /. Js.Math.abs_float(discreteShape.xs[j]), @@ -251,3 +254,5 @@ let combineShapesContinuousDiscrete = ( XYShape.T.empty, ) } + +let checkOrdered = (a: XYShape.T.t): bool => a.xs[0] < a.xs[1] From 331e14b752bdbd58523c693f21802333270b39f4 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 25 Apr 2022 12:27:34 -0400 Subject: [PATCH 10/62] Move dependencies to devDependencies Value: [0.5 to 10] --- packages/components/package.json | 6 +- packages/squiggle-lang/package.json | 6 +- yarn.lock | 244 +++++++++++----------------- 3 files changed, 103 insertions(+), 153 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index 809e0596..980f3b84 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,8 +1,8 @@ { "name": "@quri/squiggle-components", - "version": "0.1.8", - "dependencies": { - "@quri/squiggle-lang": "0.2.2", + "version": "0.2.6", + "devDependencies": { + "@quri/squiggle-lang": "0.2.5", "@react-hook/size": "^2.1.2", "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.1.1", diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 4ced6085..ee8b550c 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -29,16 +29,14 @@ ], "author": "Quantified Uncertainty Research Institute", "license": "MIT", - "dependencies": { + "devDependencies": { "bisect_ppx": "^2.7.1", "jstat": "^1.9.5", "lodash": "4.17.21", "mathjs": "10.5.0", "pdfast": "^0.2.0", "rationale": "0.2.0", - "rescript": "^9.1.4" - }, - "devDependencies": { + "rescript": "^9.1.4", "@glennsl/rescript-jest": "^0.9.0", "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/jest": "^27.4.0", diff --git a/yarn.lock b/yarn.lock index d646d829..fe6d8ecd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -253,7 +253,7 @@ jsesc "^2.5.1" source-map "^0.5.0" -"@babel/helper-annotate-as-pure@^7.16.0", "@babel/helper-annotate-as-pure@^7.16.7": +"@babel/helper-annotate-as-pure@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862" integrity sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw== @@ -363,7 +363,7 @@ dependencies: "@babel/types" "^7.17.0" -"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.16.0", "@babel/helper-module-imports@^7.16.7": +"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz#25612a8091a999704461c8a222d0efec5d091437" integrity sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg== @@ -1287,7 +1287,7 @@ "@babel/parser" "^7.16.7" "@babel/types" "^7.16.7" -"@babel/traverse@^7.1.6", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.4.5", "@babel/traverse@^7.7.2": +"@babel/traverse@^7.1.6", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.7.2": version "7.17.9" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.9.tgz#1f9b207435d9ae4a8ed6998b2b82300d83c37a0d" integrity sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw== @@ -1837,23 +1837,11 @@ dependencies: "@emotion/memoize" "0.7.4" -"@emotion/is-prop-valid@^1.1.0": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.1.2.tgz#34ad6e98e871aa6f7a20469b602911b8b11b3a95" - integrity sha512-3QnhqeL+WW88YjYbQL5gUIkthuMw7a0NGbZ7wfFVk2kg/CK5w8w5FFa0RzWjyY1+sujN0NWbtSHH6OJmWHtJpQ== - dependencies: - "@emotion/memoize" "^0.7.4" - "@emotion/memoize@0.7.4": version "0.7.4" resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.4.tgz#19bf0f5af19149111c40d98bb0cf82119f5d9eeb" integrity sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw== -"@emotion/memoize@^0.7.4": - version "0.7.5" - resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.5.tgz#2c40f81449a4e554e9fc6396910ed4843ec2be50" - integrity sha512-igX9a37DR2ZPGYtV6suZ6whr8pTFtyHL3K/oLUotxpSVO2ASaprmAe2Dkq7tBo7CRY7MMDrAa9nuQP9/YG8FxQ== - "@emotion/serialize@^0.11.15", "@emotion/serialize@^0.11.16": version "0.11.16" resolved "https://registry.yarnpkg.com/@emotion/serialize/-/serialize-0.11.16.tgz#dee05f9e96ad2fb25a5206b6d759b2d1ed3379ad" @@ -1888,12 +1876,12 @@ "@emotion/styled-base" "^10.3.0" babel-plugin-emotion "^10.0.27" -"@emotion/stylis@0.8.5", "@emotion/stylis@^0.8.4": +"@emotion/stylis@0.8.5": version "0.8.5" resolved "https://registry.yarnpkg.com/@emotion/stylis/-/stylis-0.8.5.tgz#deacb389bd6ee77d1e7fcaccce9e16c5c7e78e04" integrity sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ== -"@emotion/unitless@0.7.5", "@emotion/unitless@^0.7.4": +"@emotion/unitless@0.7.5": version "0.7.5" resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed" integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg== @@ -2204,11 +2192,6 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" -"@juggle/resize-observer@^3.3.1": - version "3.3.1" - resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.3.1.tgz#b50a781709c81e10701004214340f25475a171a0" - integrity sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw== - "@leichtgewicht/ip-codec@^2.0.1": version "2.0.3" resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.3.tgz#0300943770e04231041a51bd39f0439b5c7ab4f0" @@ -2333,34 +2316,35 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.5.tgz#db5a11bf66bdab39569719555b0f76e138d7bd64" integrity sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw== -"@react-hook/latest@^1.0.2": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@react-hook/latest/-/latest-1.0.3.tgz#c2d1d0b0af8b69ec6e2b3a2412ba0768ac82db80" - integrity sha512-dy6duzl+JnAZcDbNTfmaP3xHiKtbXYOaz3G51MGVljh548Y8MWzTr+PHLOfvpypEVW9zwvl+VyKjbWKEVbV1Rg== - -"@react-hook/passive-layout-effect@^1.2.0": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@react-hook/passive-layout-effect/-/passive-layout-effect-1.2.1.tgz#c06dac2d011f36d61259aa1c6df4f0d5e28bc55e" - integrity sha512-IwEphTD75liO8g+6taS+4oqz+nnroocNfWVHWz7j+N+ZO2vYrc6PV1q7GQhuahL0IOR7JccFTsFKQ/mb6iZWAg== - -"@react-hook/resize-observer@^1.2.1": - version "1.2.5" - resolved "https://registry.yarnpkg.com/@react-hook/resize-observer/-/resize-observer-1.2.5.tgz#b59e2300de98bc6ddc6946942f21243cde10f984" - integrity sha512-qa0pPvRxq5VbdI8mMK2apPFsZOckhQ6D3Jc9yLuyHMNhui8yEih4qyFCZBDzzK3ymZS6LAltVSVg3l1Dg9vA0w== +"@quri/squiggle-components@0.1.8": + version "0.1.8" + resolved "https://registry.yarnpkg.com/@quri/squiggle-components/-/squiggle-components-0.1.8.tgz#a77d93ef670cc22e463fdb313aa27b3f7eebfbb5" + integrity sha512-pjO5LH/r7h9OiKtNd89QB88g+0qDY7TNqYUADlFhgeZEk/FNeApzSZlgJ+teLobFHkGgG05Kwz81gDa9MMoKHQ== dependencies: - "@juggle/resize-observer" "^3.3.1" - "@react-hook/latest" "^1.0.2" - "@react-hook/passive-layout-effect" "^1.2.0" - "@types/raf-schd" "^4.0.0" - raf-schd "^4.0.2" - -"@react-hook/size@^2.1.2": - version "2.1.2" - resolved "https://registry.yarnpkg.com/@react-hook/size/-/size-2.1.2.tgz#87ed634ffb200f65d3e823501e5559aa3d584451" - integrity sha512-BmE5asyRDxSuQ9p14FUKJ0iBRgV9cROjqNG9jT/EjCM+xHha1HVqbPoT+14FQg1K7xIydabClCibUY4+1tw/iw== - dependencies: - "@react-hook/passive-layout-effect" "^1.2.0" - "@react-hook/resize-observer" "^1.2.1" + "@quri/squiggle-lang" "0.2.2" + "@testing-library/jest-dom" "^5.16.3" + "@testing-library/react" "^12.1.2" + "@testing-library/user-event" "^13.5.0" + "@types/jest" "^27.4.0" + "@types/lodash" "^4.14.178" + "@types/node" "^17.0.16" + "@types/react" "^17.0.43" + "@types/react-dom" "^17.0.14" + antd "^4.19.3" + cross-env "^7.0.3" + lodash "^4.17.21" + react "^17.0.2" + react-ace "^9.5.0" + react-dom "^17.0.2" + react-scripts "5.0.0" + react-vega "^7.4.4" + tsconfig-paths-webpack-plugin "^3.5.2" + typescript "^4.6.3" + vega "^5.21.0" + vega-embed "^6.20.6" + vega-lite "^5.2.0" + web-vitals "^2.1.4" + webpack-cli "^4.9.2" "@rollup/plugin-babel@^5.2.0": version "5.3.1" @@ -3641,7 +3625,7 @@ dependencies: defer-to-connect "^1.0.1" -"@testing-library/dom@^8.5.0": +"@testing-library/dom@^8.0.0": version "8.13.0" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.13.0.tgz#bc00bdd64c7d8b40841e27a70211399ad3af46f5" integrity sha512-9VHgfIatKNXQNaZTtLnalIy0jNZzY35a4S3oi08YAt9Hv1VsfZ/DfA45lM8D/UhtHBGJ4/lGwp0PZkVndRkoOQ== @@ -3655,7 +3639,7 @@ lz-string "^1.4.4" pretty-format "^27.0.2" -"@testing-library/jest-dom@^5.16.4": +"@testing-library/jest-dom@^5.16.3": version "5.16.4" resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.4.tgz#938302d7b8b483963a3ae821f1c0808f872245cd" integrity sha512-Gy+IoFutbMQcky0k+bqqumXZ1cTGswLsFqmNLzNdSKkU9KGV2u9oXhukCbbJ9/LRPKiqwxEE8VpV/+YZlfkPUA== @@ -3670,19 +3654,21 @@ lodash "^4.17.15" redent "^3.0.0" -"@testing-library/react@^13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.1.1.tgz#6c1635e25acca8ca5be8ee3b19ad1391681c5846" - integrity sha512-8mirlAa0OKaUvnqnZF6MdAh2tReYA2KtWVw1PKvaF5EcCZqgK5pl8iF+3uW90JdG5Ua2c2c2E2wtLdaug3dsVg== +"@testing-library/react@^12.1.2": + version "12.1.5" + resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-12.1.5.tgz#bb248f72f02a5ac9d949dea07279095fa577963b" + integrity sha512-OfTXCJUFgjd/digLUuPxa0+/3ZxsQmE7ub9kcbW/wi96Bh3o/p5vrETcBGfP17NWPGqeYYl5LTRpwyGoMC4ysg== dependencies: "@babel/runtime" "^7.12.5" - "@testing-library/dom" "^8.5.0" - "@types/react-dom" "^18.0.0" + "@testing-library/dom" "^8.0.0" + "@types/react-dom" "<18.0.0" -"@testing-library/user-event@^14.1.1": - version "14.1.1" - resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.1.1.tgz#e1ff6118896e4b22af31e5ea2f9da956adde23d8" - integrity sha512-XrjH/iEUqNl9lF2HX9YhPNV7Amntkcnpw0Bo1KkRzowNDcgSN9i0nm4Q8Oi5wupgdfPaJNMAWa61A+voD6Kmwg== +"@testing-library/user-event@^13.5.0": + version "13.5.0" + resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-13.5.0.tgz#69d77007f1e124d55314a2b73fd204b333b13295" + integrity sha512-5Kwtbo3Y/NowpkbRuSepbyMFkZmHgD+vPzYB/RJ4oxt5Gj/avFFBYjhw27cqSVPVw/3a67NK1PbiIr9k4Gwmdg== + dependencies: + "@babel/runtime" "^7.12.5" "@tootallnate/once@1": version "1.1.2" @@ -3936,7 +3922,7 @@ resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.11.1.tgz#34de04477dcf79e2ef6c8d23b41a3d81f9ebeaf5" integrity sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg== -"@types/lodash@^4.14.182": +"@types/lodash@^4.14.178": version "4.14.182" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2" integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q== @@ -3966,7 +3952,7 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@^17.0.25", "@types/node@^17.0.5": +"@types/node@*", "@types/node@^17.0.5": version "17.0.25" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.25.tgz#527051f3c2f77aa52e5dc74e45a3da5fb2301448" integrity sha512-wANk6fBrUwdpY4isjWrKTufkrXdu1D2YHCot2fD/DfWxF5sMrVSA+KN7ydckvaTCh0HiqX9IVl0L5/ZoXg5M7w== @@ -3976,6 +3962,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.13.tgz#6ad4d9db59e6b3faf98dcfe4ca9d2aec84443277" integrity sha512-Z6/KzgyWOga3pJNS42A+zayjhPbf2zM3hegRQaOPnLOzEi86VV++6FLDWgR1LGrVCRufP/ph2daa3tEa5br1zA== +"@types/node@^17.0.16": + version "17.0.27" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.27.tgz#f4df3981ae8268c066e8f49995639f855469081e" + integrity sha512-4/Ke7bbWOasuT3kceBZFGakP1dYN2XFd8v2l9bqF2LNWrmeU07JLpp56aEeG6+Q3olqO5TvXpW0yaiYnZJ5CXg== + "@types/normalize-package-data@^2.4.0": version "2.4.1" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" @@ -4026,22 +4017,17 @@ resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== -"@types/raf-schd@^4.0.0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/raf-schd/-/raf-schd-4.0.1.tgz#1f9e03736f277fe9c7b82102bf18570a6ee19f82" - integrity sha512-Ha+EnKHFIh9EKW0/XZJPUd3EGDFisEvauaBd4VVCRPKeOqUxNEc9TodiY2Zhk33XCgzJucoFEcaoNcBAPHTQ2A== - "@types/range-parser@*": version "1.2.4" resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== -"@types/react-dom@^18.0.0", "@types/react-dom@^18.0.2": - version "18.0.2" - resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.2.tgz#2d6b46557aa30257e87e67a6d952146d15979d79" - integrity sha512-UxeS+Wtj5bvLRREz9tIgsK4ntCuLDo0EcAcACgw3E+9wE8ePDr9uQpq53MfcyxyIS55xJ+0B6mDS8c4qkkHLBg== +"@types/react-dom@<18.0.0", "@types/react-dom@^17.0.14": + version "17.0.15" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.15.tgz#f2c8efde11521a4b7991e076cb9c70ba3bb0d156" + integrity sha512-Tr9VU9DvNoHDWlmecmcsE5ZZiUkYx+nKBzum4Oxe1K0yJVyBlfbq7H3eXjxXqJczBKqPGq3EgfTru4MgKb9+Yw== dependencies: - "@types/react" "*" + "@types/react" "^17" "@types/react-router-config@*": version "5.0.6" @@ -4076,7 +4062,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": +"@types/react@*", "@types/react@^16.9.19", "@types/react@^17", "@types/react@^17.0.43", "@types/react@^18.0.1": version "18.0.6" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.6.tgz#30206c3830af6ce8639b91ace5868bc2d3d1d96c" integrity sha512-bPqwzJRzKtfI0mVYr5R+1o9BOE8UEXefwc1LwcBtfnaAn6OoqMhLa/91VA8aeWfDPJt1kHvYKI8RHcQybZLHHA== @@ -4633,7 +4619,7 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" -ace-builds@^1.4.14: +ace-builds@^1.4.13: version "1.4.14" resolved "https://registry.yarnpkg.com/ace-builds/-/ace-builds-1.4.14.tgz#2c41ccbccdd09e665d3489f161a20baeb3a3c852" integrity sha512-NBOQlm9+7RBqRqZwimpgquaLeTJFayqb9UEPtTkpC3TkkwDnlsT/TwsCC0svjt9kEZ6G9mH5AEOHSz6Q/HrzQQ== @@ -5425,17 +5411,6 @@ babel-plugin-react-docgen@^4.1.0, babel-plugin-react-docgen@^4.2.1: lodash "^4.17.15" react-docgen "^5.0.0" -"babel-plugin-styled-components@>= 1.12.0": - version "2.0.7" - resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.7.tgz#c81ef34b713f9da2b7d3f5550df0d1e19e798086" - integrity sha512-i7YhvPgVqRKfoQ66toiZ06jPNA3p6ierpfUuEWxNF+fV27Uv5gxBkf8KZLHUCc1nFA9j6+80pYoIpqCeyW3/bA== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.0" - "@babel/helper-module-imports" "^7.16.0" - babel-plugin-syntax-jsx "^6.18.0" - lodash "^4.17.11" - picomatch "^2.3.0" - babel-plugin-syntax-jsx@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946" @@ -6030,11 +6005,6 @@ camelcase@^6.2.0, camelcase@^6.2.1: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -camelize@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b" - integrity sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs= - caniuse-api@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0" @@ -6843,11 +6813,6 @@ css-blank-pseudo@^3.0.3: dependencies: postcss-selector-parser "^6.0.9" -css-color-keywords@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05" - integrity sha1-/qJhbcZ2spYmhrOvjb2+GAskTgU= - css-declaration-sorter@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.2.2.tgz#bfd2f6f50002d6a3ae779a87d3a0c5d5b10e0f02" @@ -6962,15 +6927,6 @@ css-select@~1.2.0: domutils "1.5.1" nth-check "~1.0.1" -css-to-react-native@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-3.0.0.tgz#62dbe678072a824a689bcfee011fc96e02a7d756" - integrity sha512-Ro1yETZA813eoyUp2GDBhG2j+YggidUmzO1/v9eYBKR2EHVEniE2MI/NqpTQ954BMpTPZFsGNPm46qFB9dpaPQ== - dependencies: - camelize "^1.0.0" - css-color-keywords "^1.0.0" - postcss-value-parser "^4.0.2" - css-tree@1.0.0-alpha.37: version "1.0.0-alpha.37" resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.0.0-alpha.37.tgz#98bebd62c4c1d9f960ec340cf9f7522e30709a22" @@ -8027,7 +7983,7 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" -eslint-config-react-app@^7.0.1: +eslint-config-react-app@^7.0.0: version "7.0.1" resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-7.0.1.tgz#73ba3929978001c5c86274c017ea57eb5fa644b4" integrity sha512-K6rNzvkIeHaTd8m/QEh1Zko0KI7BACWkkneSs6s9cKZC/J27X3eZR6Upt1jkmZ/4FK+XUOPPxMEN7+lbUXfSlA== @@ -9509,7 +9465,7 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: +hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== @@ -11431,7 +11387,7 @@ lodash.uniq@4.5.0, lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@4.17.21, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.7.0: +lodash@4.17.21, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -13459,7 +13415,7 @@ postcss-unique-selectors@^5.1.1: dependencies: postcss-selector-parser "^6.0.5" -postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: +postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== @@ -13778,11 +13734,6 @@ quick-lru@^5.1.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== -raf-schd@^4.0.2: - version "4.0.3" - resolved "https://registry.yarnpkg.com/raf-schd/-/raf-schd-4.0.3.tgz#5d6c34ef46f8b2a0e880a8fcdb743efc5bfdbc1a" - integrity sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ== - raf@^3.4.1: version "3.4.1" resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39" @@ -14220,12 +14171,12 @@ rc@^1.2.8: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-ace@10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-10.0.0.tgz#1760e302604cff35ba40963db43eb027513b6572" - integrity sha512-AUoA2OsKOCv8fXLqcFM232dF/Z8w14bwPUZ9z5I2zjBfqfZOZLqxnhXN+qKL6VrQXs1DLUvalGOuM5TABAFOCA== +react-ace@^9.5.0: + version "9.5.0" + resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-9.5.0.tgz#b6c32b70d404dd821a7e01accc2d76da667ff1f7" + integrity sha512-4l5FgwGh6K7A0yWVMQlPIXDItM4Q9zzXRqOae8KkCl6MkOob7sC1CzHxZdOGvV+QioKWbX2p5HcdOVUv6cAdSg== dependencies: - ace-builds "^1.4.14" + ace-builds "^1.4.13" diff-match-patch "^1.0.5" lodash.get "^4.4.2" lodash.isequal "^4.5.0" @@ -14265,7 +14216,7 @@ react-colorful@^5.1.2: resolved "https://registry.yarnpkg.com/react-colorful/-/react-colorful-5.5.1.tgz#29d9c4e496f2ca784dd2bb5053a3a4340cfaf784" integrity sha512-M1TJH2X3RXEt12sWkpa6hLc/bbYS0H6F4rIqjQZ+RxNBstpY67d9TrFXtqdZwhpmBXcCwEi7stKqFue3ZRkiOg== -react-dev-utils@^12.0.0, react-dev-utils@^12.0.1: +react-dev-utils@^12.0.0: version "12.0.1" resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-12.0.1.tgz#ba92edb4a1f379bd46ccd6bcd4e7bc398df33e73" integrity sha512-84Ivxmr17KjUupyqzFode6xKhjwuEJDROWKJy/BthkL7Wn6NJ8h4WE6k/exAv6ImS+0oZLRRW5j/aINMHyeGeQ== @@ -14316,6 +14267,15 @@ react-docgen@^5.0.0: node-dir "^0.1.10" strip-indent "^3.0.0" +react-dom@^17.0.2: + version "17.0.2" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23" + integrity sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA== + dependencies: + loose-envify "^1.1.0" + object-assign "^4.1.1" + scheduler "^0.20.2" + react-dom@^18.0.0: version "18.0.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.0.0.tgz#26b88534f8f1dbb80853e1eabe752f24100d8023" @@ -14476,10 +14436,10 @@ react-router@6.3.0, react-router@^6.0.0: dependencies: history "^5.2.0" -react-scripts@5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-5.0.1.tgz#6285dbd65a8ba6e49ca8d651ce30645a6d980003" - integrity sha512-8VAmEm/ZAwQzJ+GOMLbBsTdDKOpuZh7RPs0UymvBR2vRk4iZWCskjbFnxqjrzoIvlNNRZ3QJFx6/qDSi6zSnaQ== +react-scripts@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-5.0.0.tgz#6547a6d7f8b64364ef95273767466cc577cb4b60" + integrity sha512-3i0L2CyIlROz7mxETEdfif6Sfhh9Lfpzi10CtcGs1emDQStmZfWjJbAIMtRD0opVUjQuFWqHZyRZ9PPzKCFxWg== dependencies: "@babel/core" "^7.16.0" "@pmmmwh/react-refresh-webpack-plugin" "^0.5.3" @@ -14497,7 +14457,7 @@ react-scripts@5.0.1: dotenv "^10.0.0" dotenv-expand "^5.1.0" eslint "^8.3.0" - eslint-config-react-app "^7.0.1" + eslint-config-react-app "^7.0.0" eslint-webpack-plugin "^3.1.1" file-loader "^6.2.0" fs-extra "^10.0.0" @@ -14514,7 +14474,7 @@ react-scripts@5.0.1: postcss-preset-env "^7.0.1" prompts "^2.4.2" react-app-polyfill "^3.0.0" - react-dev-utils "^12.0.1" + react-dev-utils "^12.0.0" react-refresh "^0.11.0" resolve "^1.20.0" resolve-url-loader "^4.0.0" @@ -14561,7 +14521,7 @@ react-textarea-autosize@^8.3.0, react-textarea-autosize@^8.3.2: use-composed-ref "^1.0.0" use-latest "^1.0.0" -react-vega@^7.5.0: +react-vega@^7.4.4: version "7.5.0" resolved "https://registry.yarnpkg.com/react-vega/-/react-vega-7.5.0.tgz#b9726d4fd7f35299d417d340935e093bf4bed558" integrity sha512-JysyZ0PdihfSztkbxOd7DcYBrCVotRbkKiGNYWKkLP1D4Mt2Dq0uMwNtBEBGjoWdmrE3Qwd+uz7ekklP6MqxDw== @@ -14570,7 +14530,7 @@ react-vega@^7.5.0: fast-deep-equal "^3.1.1" vega-embed "^6.5.1" -react@^18.0.0: +react@^17.0.2, react@^18.0.0: version "18.0.0" resolved "https://registry.yarnpkg.com/react/-/react-18.0.0.tgz#b468736d1f4a5891f38585ba8e8fb29f91c3cb96" integrity sha512-x+VL6wbT4JRVPm7EGxXhZ8w8LTROaxPXOqhlGyVSrv0sB1jkyFGgXxJ8LVoPRLvPR6/CIZGFmfzqUa2NYeMr2A== @@ -15218,6 +15178,14 @@ saxes@^5.0.1: dependencies: xmlchars "^2.2.0" +scheduler@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91" + integrity sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ== + dependencies: + loose-envify "^1.1.0" + object-assign "^4.1.1" + scheduler@^0.21.0: version "0.21.0" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0.tgz#6fd2532ff5a6d877b6edb12f00d8ab7e8f308820" @@ -16109,22 +16077,6 @@ style-to-object@0.3.0, style-to-object@^0.3.0: dependencies: inline-style-parser "0.1.1" -styled-components@^5.3.5: - version "5.3.5" - resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-5.3.5.tgz#a750a398d01f1ca73af16a241dec3da6deae5ec4" - integrity sha512-ndETJ9RKaaL6q41B69WudeqLzOpY1A/ET/glXkNZ2T7dPjPqpPCXXQjDFYZWwNnE5co0wX+gTCqx9mfxTmSIPg== - dependencies: - "@babel/helper-module-imports" "^7.0.0" - "@babel/traverse" "^7.4.5" - "@emotion/is-prop-valid" "^1.1.0" - "@emotion/stylis" "^0.8.4" - "@emotion/unitless" "^0.7.4" - babel-plugin-styled-components ">= 1.12.0" - css-to-react-native "^3.0.0" - hoist-non-react-statics "^3.0.0" - shallowequal "^1.1.0" - supports-color "^5.5.0" - stylehacks@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-5.1.0.tgz#a40066490ca0caca04e96c6b02153ddc39913520" @@ -16138,7 +16090,7 @@ supports-color@^2.0.0: resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= -supports-color@^5.3.0, supports-color@^5.5.0: +supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== @@ -17464,7 +17416,7 @@ vega-wordcloud@~4.1.3: vega-statistics "^1.7.9" vega-util "^1.15.2" -vega@^5.22.1: +vega@^5.21.0: version "5.22.1" resolved "https://registry.yarnpkg.com/vega/-/vega-5.22.1.tgz#e028f3645de18e0070317bc04410282975549e1e" integrity sha512-KJBI7OWSzpfCPbmWl3GQCqBqbf2TIdpWS0mzO6MmWbvdMhWHf74P9IVnx1B1mhg0ZTqWFualx9ZYhWzMMwudaQ== From b1c79aba2801003e30c6d1ad97fbd0118eb55bdd Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 25 Apr 2022 12:55:15 -0400 Subject: [PATCH 11/62] Fix build issues in components Value: [0.5 to 5] --- packages/components/package.json | 12 +-- yarn.lock | 135 ++++++++++++++++++++++++++++--- 2 files changed, 131 insertions(+), 16 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index 38b29eef..8f296f6e 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,9 +1,15 @@ { "name": "@quri/squiggle-components", "version": "0.2.6", + "dependencies": { + "antd": "^4.20.0", + "react-ace": "10.0.0", + "react-dom": "^18.0.0", + "styled-components": "^5.3.5", + "@react-hook/size": "^2.1.2" + }, "devDependencies": { "@quri/squiggle-lang": "0.2.5", - "@react-hook/size": "^2.1.2", "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.1.1", "@testing-library/user-event": "^14.1.1", @@ -12,15 +18,11 @@ "@types/node": "^17.0.26", "@types/react": "^18.0.3", "@types/react-dom": "^18.0.2", - "antd": "^4.20.0", "cross-env": "^7.0.3", "lodash": "^4.17.21", "react": "^18.0.0", - "react-ace": "10.0.0", - "react-dom": "^18.0.0", "react-scripts": "5.0.1", "react-vega": "^7.5.0", - "styled-components": "^5.3.5", "tsconfig-paths-webpack-plugin": "^3.5.2", "typescript": "^4.6.3", "vega": "^5.22.1", diff --git a/yarn.lock b/yarn.lock index 15bf97ad..5786ba5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -253,7 +253,7 @@ jsesc "^2.5.1" source-map "^0.5.0" -"@babel/helper-annotate-as-pure@^7.16.7": +"@babel/helper-annotate-as-pure@^7.16.0", "@babel/helper-annotate-as-pure@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862" integrity sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw== @@ -363,7 +363,7 @@ dependencies: "@babel/types" "^7.17.0" -"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.16.7": +"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.16.0", "@babel/helper-module-imports@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz#25612a8091a999704461c8a222d0efec5d091437" integrity sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg== @@ -1287,7 +1287,7 @@ "@babel/parser" "^7.16.7" "@babel/types" "^7.16.7" -"@babel/traverse@^7.1.6", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.7.2": +"@babel/traverse@^7.1.6", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.4.5", "@babel/traverse@^7.7.2": version "7.17.9" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.9.tgz#1f9b207435d9ae4a8ed6998b2b82300d83c37a0d" integrity sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw== @@ -1837,11 +1837,23 @@ dependencies: "@emotion/memoize" "0.7.4" +"@emotion/is-prop-valid@^1.1.0": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.1.2.tgz#34ad6e98e871aa6f7a20469b602911b8b11b3a95" + integrity sha512-3QnhqeL+WW88YjYbQL5gUIkthuMw7a0NGbZ7wfFVk2kg/CK5w8w5FFa0RzWjyY1+sujN0NWbtSHH6OJmWHtJpQ== + dependencies: + "@emotion/memoize" "^0.7.4" + "@emotion/memoize@0.7.4": version "0.7.4" resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.4.tgz#19bf0f5af19149111c40d98bb0cf82119f5d9eeb" integrity sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw== +"@emotion/memoize@^0.7.4": + version "0.7.5" + resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.5.tgz#2c40f81449a4e554e9fc6396910ed4843ec2be50" + integrity sha512-igX9a37DR2ZPGYtV6suZ6whr8pTFtyHL3K/oLUotxpSVO2ASaprmAe2Dkq7tBo7CRY7MMDrAa9nuQP9/YG8FxQ== + "@emotion/serialize@^0.11.15", "@emotion/serialize@^0.11.16": version "0.11.16" resolved "https://registry.yarnpkg.com/@emotion/serialize/-/serialize-0.11.16.tgz#dee05f9e96ad2fb25a5206b6d759b2d1ed3379ad" @@ -1876,12 +1888,12 @@ "@emotion/styled-base" "^10.3.0" babel-plugin-emotion "^10.0.27" -"@emotion/stylis@0.8.5": +"@emotion/stylis@0.8.5", "@emotion/stylis@^0.8.4": version "0.8.5" resolved "https://registry.yarnpkg.com/@emotion/stylis/-/stylis-0.8.5.tgz#deacb389bd6ee77d1e7fcaccce9e16c5c7e78e04" integrity sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ== -"@emotion/unitless@0.7.5": +"@emotion/unitless@0.7.5", "@emotion/unitless@^0.7.4": version "0.7.5" resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed" integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg== @@ -2192,6 +2204,11 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" +"@juggle/resize-observer@^3.3.1": + version "3.3.1" + resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.3.1.tgz#b50a781709c81e10701004214340f25475a171a0" + integrity sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw== + "@leichtgewicht/ip-codec@^2.0.1": version "2.0.3" resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.3.tgz#0300943770e04231041a51bd39f0439b5c7ab4f0" @@ -2346,6 +2363,35 @@ web-vitals "^2.1.4" webpack-cli "^4.9.2" +"@react-hook/latest@^1.0.2": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@react-hook/latest/-/latest-1.0.3.tgz#c2d1d0b0af8b69ec6e2b3a2412ba0768ac82db80" + integrity sha512-dy6duzl+JnAZcDbNTfmaP3xHiKtbXYOaz3G51MGVljh548Y8MWzTr+PHLOfvpypEVW9zwvl+VyKjbWKEVbV1Rg== + +"@react-hook/passive-layout-effect@^1.2.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@react-hook/passive-layout-effect/-/passive-layout-effect-1.2.1.tgz#c06dac2d011f36d61259aa1c6df4f0d5e28bc55e" + integrity sha512-IwEphTD75liO8g+6taS+4oqz+nnroocNfWVHWz7j+N+ZO2vYrc6PV1q7GQhuahL0IOR7JccFTsFKQ/mb6iZWAg== + +"@react-hook/resize-observer@^1.2.1": + version "1.2.5" + resolved "https://registry.yarnpkg.com/@react-hook/resize-observer/-/resize-observer-1.2.5.tgz#b59e2300de98bc6ddc6946942f21243cde10f984" + integrity sha512-qa0pPvRxq5VbdI8mMK2apPFsZOckhQ6D3Jc9yLuyHMNhui8yEih4qyFCZBDzzK3ymZS6LAltVSVg3l1Dg9vA0w== + dependencies: + "@juggle/resize-observer" "^3.3.1" + "@react-hook/latest" "^1.0.2" + "@react-hook/passive-layout-effect" "^1.2.0" + "@types/raf-schd" "^4.0.0" + raf-schd "^4.0.2" + +"@react-hook/size@^2.1.2": + version "2.1.2" + resolved "https://registry.yarnpkg.com/@react-hook/size/-/size-2.1.2.tgz#87ed634ffb200f65d3e823501e5559aa3d584451" + integrity sha512-BmE5asyRDxSuQ9p14FUKJ0iBRgV9cROjqNG9jT/EjCM+xHha1HVqbPoT+14FQg1K7xIydabClCibUY4+1tw/iw== + dependencies: + "@react-hook/passive-layout-effect" "^1.2.0" + "@react-hook/resize-observer" "^1.2.1" + "@rollup/plugin-babel@^5.2.0": version "5.3.1" resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283" @@ -4017,6 +4063,11 @@ resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== +"@types/raf-schd@^4.0.0": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@types/raf-schd/-/raf-schd-4.0.1.tgz#1f9e03736f277fe9c7b82102bf18570a6ee19f82" + integrity sha512-Ha+EnKHFIh9EKW0/XZJPUd3EGDFisEvauaBd4VVCRPKeOqUxNEc9TodiY2Zhk33XCgzJucoFEcaoNcBAPHTQ2A== + "@types/range-parser@*": version "1.2.4" resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" @@ -4619,7 +4670,7 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" -ace-builds@^1.4.13: +ace-builds@^1.4.13, ace-builds@^1.4.14: version "1.4.14" resolved "https://registry.yarnpkg.com/ace-builds/-/ace-builds-1.4.14.tgz#2c41ccbccdd09e665d3489f161a20baeb3a3c852" integrity sha512-NBOQlm9+7RBqRqZwimpgquaLeTJFayqb9UEPtTkpC3TkkwDnlsT/TwsCC0svjt9kEZ6G9mH5AEOHSz6Q/HrzQQ== @@ -4873,7 +4924,7 @@ ansi-to-html@^0.6.11: dependencies: entities "^2.0.0" -antd@^4.19.3: +antd@^4.19.3, antd@^4.20.0: version "4.20.0" resolved "https://registry.yarnpkg.com/antd/-/antd-4.20.0.tgz#5f5fa4fccb90dd3e091c8d6e9d503114d98d862f" integrity sha512-Msowfvabsn/yJIo3qYU0vMqGb31OUylMeFRDilosBViG2AS8R2VB2IX53kbw4kFV3vr7fr2HXcuQkf/FMLU+Dg== @@ -5412,6 +5463,17 @@ babel-plugin-react-docgen@^4.1.0, babel-plugin-react-docgen@^4.2.1: lodash "^4.17.15" react-docgen "^5.0.0" +"babel-plugin-styled-components@>= 1.12.0": + version "2.0.7" + resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.7.tgz#c81ef34b713f9da2b7d3f5550df0d1e19e798086" + integrity sha512-i7YhvPgVqRKfoQ66toiZ06jPNA3p6ierpfUuEWxNF+fV27Uv5gxBkf8KZLHUCc1nFA9j6+80pYoIpqCeyW3/bA== + dependencies: + "@babel/helper-annotate-as-pure" "^7.16.0" + "@babel/helper-module-imports" "^7.16.0" + babel-plugin-syntax-jsx "^6.18.0" + lodash "^4.17.11" + picomatch "^2.3.0" + babel-plugin-syntax-jsx@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946" @@ -6006,6 +6068,11 @@ camelcase@^6.2.0, camelcase@^6.2.1: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== +camelize@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b" + integrity sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs= + caniuse-api@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0" @@ -6814,6 +6881,11 @@ css-blank-pseudo@^3.0.3: dependencies: postcss-selector-parser "^6.0.9" +css-color-keywords@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05" + integrity sha1-/qJhbcZ2spYmhrOvjb2+GAskTgU= + css-declaration-sorter@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.2.2.tgz#bfd2f6f50002d6a3ae779a87d3a0c5d5b10e0f02" @@ -6928,6 +7000,15 @@ css-select@~1.2.0: domutils "1.5.1" nth-check "~1.0.1" +css-to-react-native@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-3.0.0.tgz#62dbe678072a824a689bcfee011fc96e02a7d756" + integrity sha512-Ro1yETZA813eoyUp2GDBhG2j+YggidUmzO1/v9eYBKR2EHVEniE2MI/NqpTQ954BMpTPZFsGNPm46qFB9dpaPQ== + dependencies: + camelize "^1.0.0" + css-color-keywords "^1.0.0" + postcss-value-parser "^4.0.2" + css-tree@1.0.0-alpha.37: version "1.0.0-alpha.37" resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.0.0-alpha.37.tgz#98bebd62c4c1d9f960ec340cf9f7522e30709a22" @@ -9466,7 +9547,7 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: +hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== @@ -11388,7 +11469,7 @@ lodash.uniq@4.5.0, lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@4.17.21, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.7.0: +lodash@4.17.21, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -13416,7 +13497,7 @@ postcss-unique-selectors@^5.1.1: dependencies: postcss-selector-parser "^6.0.5" -postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: +postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== @@ -13735,6 +13816,11 @@ quick-lru@^5.1.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== +raf-schd@^4.0.2: + version "4.0.3" + resolved "https://registry.yarnpkg.com/raf-schd/-/raf-schd-4.0.3.tgz#5d6c34ef46f8b2a0e880a8fcdb743efc5bfdbc1a" + integrity sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ== + raf@^3.4.1: version "3.4.1" resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39" @@ -14172,6 +14258,17 @@ rc@^1.2.8: minimist "^1.2.0" strip-json-comments "~2.0.1" +react-ace@10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-10.0.0.tgz#1760e302604cff35ba40963db43eb027513b6572" + integrity sha512-AUoA2OsKOCv8fXLqcFM232dF/Z8w14bwPUZ9z5I2zjBfqfZOZLqxnhXN+qKL6VrQXs1DLUvalGOuM5TABAFOCA== + dependencies: + ace-builds "^1.4.14" + diff-match-patch "^1.0.5" + lodash.get "^4.4.2" + lodash.isequal "^4.5.0" + prop-types "^15.7.2" + react-ace@^9.5.0: version "9.5.0" resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-9.5.0.tgz#b6c32b70d404dd821a7e01accc2d76da667ff1f7" @@ -16078,6 +16175,22 @@ style-to-object@0.3.0, style-to-object@^0.3.0: dependencies: inline-style-parser "0.1.1" +styled-components@^5.3.5: + version "5.3.5" + resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-5.3.5.tgz#a750a398d01f1ca73af16a241dec3da6deae5ec4" + integrity sha512-ndETJ9RKaaL6q41B69WudeqLzOpY1A/ET/glXkNZ2T7dPjPqpPCXXQjDFYZWwNnE5co0wX+gTCqx9mfxTmSIPg== + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/traverse" "^7.4.5" + "@emotion/is-prop-valid" "^1.1.0" + "@emotion/stylis" "^0.8.4" + "@emotion/unitless" "^0.7.4" + babel-plugin-styled-components ">= 1.12.0" + css-to-react-native "^3.0.0" + hoist-non-react-statics "^3.0.0" + shallowequal "^1.1.0" + supports-color "^5.5.0" + stylehacks@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-5.1.0.tgz#a40066490ca0caca04e96c6b02153ddc39913520" @@ -16091,7 +16204,7 @@ supports-color@^2.0.0: resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= -supports-color@^5.3.0: +supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== From c6f6ff4c7327c020ad1c8aae2c472bd25fe7f280 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 25 Apr 2022 14:35:45 -0400 Subject: [PATCH 12/62] Mistake in #371 Value: [0.12 to 0.8] --- packages/components/package.json | 54 ++++++++-------- yarn.lock | 103 ++++++++++++++++++++++++++++--- 2 files changed, 119 insertions(+), 38 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index 8f296f6e..0477b407 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -2,27 +2,25 @@ "name": "@quri/squiggle-components", "version": "0.2.6", "dependencies": { - "antd": "^4.20.0", - "react-ace": "10.0.0", - "react-dom": "^18.0.0", - "styled-components": "^5.3.5", - "@react-hook/size": "^2.1.2" - }, - "devDependencies": { - "@quri/squiggle-lang": "0.2.5", + "@quri/squiggle-lang": "0.2.2", + "@react-hook/size": "^2.1.2", "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.1.1", "@testing-library/user-event": "^14.1.1", "@types/jest": "^27.4.0", "@types/lodash": "^4.14.182", - "@types/node": "^17.0.26", + "@types/node": "^17.0.25", "@types/react": "^18.0.3", "@types/react-dom": "^18.0.2", + "antd": "^4.19.3", "cross-env": "^7.0.3", "lodash": "^4.17.21", "react": "^18.0.0", + "react-ace": "10.0.0", + "react-dom": "^18.0.0", "react-scripts": "5.0.1", "react-vega": "^7.5.0", + "styled-components": "^5.3.5", "tsconfig-paths-webpack-plugin": "^3.5.2", "typescript": "^4.6.3", "vega": "^5.22.1", @@ -31,6 +29,25 @@ "web-vitals": "^2.1.4", "webpack-cli": "^4.9.2" }, + "devDependencies": { + "@babel/plugin-proposal-private-property-in-object": "^7.16.7", + "@storybook/addon-actions": "^6.4.22", + "@storybook/addon-essentials": "^6.4.22", + "@storybook/addon-links": "^6.4.22", + "@storybook/builder-webpack5": "^6.4.22", + "@storybook/manager-webpack5": "^6.4.22", + "@storybook/node-logger": "^6.4.22", + "@storybook/preset-create-react-app": "^4.1.0", + "@storybook/react": "^6.4.22", + "@types/styled-components": "^5.1.24", + "@types/webpack": "^5.28.0", + "react-codejar": "^1.1.2", + "style-loader": "^3.3.1", + "ts-loader": "^9.2.8", + "webpack": "^5.72.0", + "webpack-cli": "^4.9.2", + "webpack-dev-server": "^4.8.1" + }, "scripts": { "start": "cross-env REACT_APP_FAST_REFRESH=false && start-storybook -p 6006 -s public", "build": "tsc -b && build-storybook -s public", @@ -67,25 +84,6 @@ "last 1 safari version" ] }, - "devDependencies": { - "@babel/plugin-proposal-private-property-in-object": "^7.16.7", - "@storybook/addon-actions": "^6.4.22", - "@storybook/addon-essentials": "^6.4.22", - "@storybook/addon-links": "^6.4.22", - "@storybook/builder-webpack5": "^6.4.22", - "@storybook/manager-webpack5": "^6.4.22", - "@storybook/node-logger": "^6.4.22", - "@storybook/preset-create-react-app": "^4.1.0", - "@storybook/react": "^6.4.22", - "@types/styled-components": "^5.1.24", - "@types/webpack": "^5.28.0", - "react-codejar": "^1.1.2", - "style-loader": "^3.3.1", - "ts-loader": "^9.2.8", - "webpack": "^5.72.0", - "webpack-cli": "^4.9.2", - "webpack-dev-server": "^4.8.1" - }, "resolutions": { "@types/react": "17.0.43" }, diff --git a/yarn.lock b/yarn.lock index 5786ba5d..58168315 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3671,7 +3671,7 @@ dependencies: defer-to-connect "^1.0.1" -"@testing-library/dom@^8.0.0": +"@testing-library/dom@^8.0.0", "@testing-library/dom@^8.5.0": version "8.13.0" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.13.0.tgz#bc00bdd64c7d8b40841e27a70211399ad3af46f5" integrity sha512-9VHgfIatKNXQNaZTtLnalIy0jNZzY35a4S3oi08YAt9Hv1VsfZ/DfA45lM8D/UhtHBGJ4/lGwp0PZkVndRkoOQ== @@ -3685,7 +3685,7 @@ lz-string "^1.4.4" pretty-format "^27.0.2" -"@testing-library/jest-dom@^5.16.3": +"@testing-library/jest-dom@^5.16.3", "@testing-library/jest-dom@^5.16.4": version "5.16.4" resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.4.tgz#938302d7b8b483963a3ae821f1c0808f872245cd" integrity sha512-Gy+IoFutbMQcky0k+bqqumXZ1cTGswLsFqmNLzNdSKkU9KGV2u9oXhukCbbJ9/LRPKiqwxEE8VpV/+YZlfkPUA== @@ -3709,6 +3709,15 @@ "@testing-library/dom" "^8.0.0" "@types/react-dom" "<18.0.0" +"@testing-library/react@^13.1.1": + version "13.1.1" + resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.1.1.tgz#6c1635e25acca8ca5be8ee3b19ad1391681c5846" + integrity sha512-8mirlAa0OKaUvnqnZF6MdAh2tReYA2KtWVw1PKvaF5EcCZqgK5pl8iF+3uW90JdG5Ua2c2c2E2wtLdaug3dsVg== + dependencies: + "@babel/runtime" "^7.12.5" + "@testing-library/dom" "^8.5.0" + "@types/react-dom" "^18.0.0" + "@testing-library/user-event@^13.5.0": version "13.5.0" resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-13.5.0.tgz#69d77007f1e124d55314a2b73fd204b333b13295" @@ -3716,6 +3725,11 @@ dependencies: "@babel/runtime" "^7.12.5" +"@testing-library/user-event@^14.1.1": + version "14.1.1" + resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.1.1.tgz#e1ff6118896e4b22af31e5ea2f9da956adde23d8" + integrity sha512-XrjH/iEUqNl9lF2HX9YhPNV7Amntkcnpw0Bo1KkRzowNDcgSN9i0nm4Q8Oi5wupgdfPaJNMAWa61A+voD6Kmwg== + "@tootallnate/once@1": version "1.1.2" resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" @@ -3968,7 +3982,7 @@ resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.11.1.tgz#34de04477dcf79e2ef6c8d23b41a3d81f9ebeaf5" integrity sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg== -"@types/lodash@^4.14.178": +"@types/lodash@^4.14.178", "@types/lodash@^4.14.182": version "4.14.182" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2" integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q== @@ -4008,7 +4022,7 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.13.tgz#6ad4d9db59e6b3faf98dcfe4ca9d2aec84443277" integrity sha512-Z6/KzgyWOga3pJNS42A+zayjhPbf2zM3hegRQaOPnLOzEi86VV++6FLDWgR1LGrVCRufP/ph2daa3tEa5br1zA== -"@types/node@^17.0.16": +"@types/node@^17.0.16", "@types/node@^17.0.25": version "17.0.27" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.27.tgz#f4df3981ae8268c066e8f49995639f855469081e" integrity sha512-4/Ke7bbWOasuT3kceBZFGakP1dYN2XFd8v2l9bqF2LNWrmeU07JLpp56aEeG6+Q3olqO5TvXpW0yaiYnZJ5CXg== @@ -4080,6 +4094,20 @@ dependencies: "@types/react" "^17" +"@types/react-dom@^18.0.0": + version "18.0.0" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.0.tgz#b13f8d098e4b0c45df4f1ed123833143b0c71141" + integrity sha512-49897Y0UiCGmxZqpC8Blrf6meL8QUla6eb+BBhn69dTXlmuOlzkfr7HHY/O8J25e1lTUMs+YYxSlVDAaGHCOLg== + dependencies: + "@types/react" "*" + +"@types/react-dom@^18.0.2": + version "18.0.2" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.2.tgz#2d6b46557aa30257e87e67a6d952146d15979d79" + integrity sha512-UxeS+Wtj5bvLRREz9tIgsK4ntCuLDo0EcAcACgw3E+9wE8ePDr9uQpq53MfcyxyIS55xJ+0B6mDS8c4qkkHLBg== + dependencies: + "@types/react" "*" + "@types/react-router-config@*": version "5.0.6" resolved "https://registry.yarnpkg.com/@types/react-router-config/-/react-router-config-5.0.6.tgz#87c5c57e72d241db900d9734512c50ccec062451" @@ -4113,7 +4141,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^16.9.19", "@types/react@^17", "@types/react@^17.0.43", "@types/react@^18.0.1": +"@types/react@*", "@types/react@^16.9.19", "@types/react@^17", "@types/react@^17.0.43", "@types/react@^18.0.1", "@types/react@^18.0.3": version "18.0.6" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.6.tgz#30206c3830af6ce8639b91ace5868bc2d3d1d96c" integrity sha512-bPqwzJRzKtfI0mVYr5R+1o9BOE8UEXefwc1LwcBtfnaAn6OoqMhLa/91VA8aeWfDPJt1kHvYKI8RHcQybZLHHA== @@ -4924,7 +4952,7 @@ ansi-to-html@^0.6.11: dependencies: entities "^2.0.0" -antd@^4.19.3, antd@^4.20.0: +antd@^4.19.3: version "4.20.0" resolved "https://registry.yarnpkg.com/antd/-/antd-4.20.0.tgz#5f5fa4fccb90dd3e091c8d6e9d503114d98d862f" integrity sha512-Msowfvabsn/yJIo3qYU0vMqGb31OUylMeFRDilosBViG2AS8R2VB2IX53kbw4kFV3vr7fr2HXcuQkf/FMLU+Dg== @@ -8065,7 +8093,7 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" -eslint-config-react-app@^7.0.0: +eslint-config-react-app@^7.0.0, eslint-config-react-app@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-7.0.1.tgz#73ba3929978001c5c86274c017ea57eb5fa644b4" integrity sha512-K6rNzvkIeHaTd8m/QEh1Zko0KI7BACWkkneSs6s9cKZC/J27X3eZR6Upt1jkmZ/4FK+XUOPPxMEN7+lbUXfSlA== @@ -14314,7 +14342,7 @@ react-colorful@^5.1.2: resolved "https://registry.yarnpkg.com/react-colorful/-/react-colorful-5.5.1.tgz#29d9c4e496f2ca784dd2bb5053a3a4340cfaf784" integrity sha512-M1TJH2X3RXEt12sWkpa6hLc/bbYS0H6F4rIqjQZ+RxNBstpY67d9TrFXtqdZwhpmBXcCwEi7stKqFue3ZRkiOg== -react-dev-utils@^12.0.0: +react-dev-utils@^12.0.0, react-dev-utils@^12.0.1: version "12.0.1" resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-12.0.1.tgz#ba92edb4a1f379bd46ccd6bcd4e7bc398df33e73" integrity sha512-84Ivxmr17KjUupyqzFode6xKhjwuEJDROWKJy/BthkL7Wn6NJ8h4WE6k/exAv6ImS+0oZLRRW5j/aINMHyeGeQ== @@ -14589,6 +14617,61 @@ react-scripts@5.0.0: optionalDependencies: fsevents "^2.3.2" +react-scripts@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-5.0.1.tgz#6285dbd65a8ba6e49ca8d651ce30645a6d980003" + integrity sha512-8VAmEm/ZAwQzJ+GOMLbBsTdDKOpuZh7RPs0UymvBR2vRk4iZWCskjbFnxqjrzoIvlNNRZ3QJFx6/qDSi6zSnaQ== + dependencies: + "@babel/core" "^7.16.0" + "@pmmmwh/react-refresh-webpack-plugin" "^0.5.3" + "@svgr/webpack" "^5.5.0" + babel-jest "^27.4.2" + babel-loader "^8.2.3" + babel-plugin-named-asset-import "^0.3.8" + babel-preset-react-app "^10.0.1" + bfj "^7.0.2" + browserslist "^4.18.1" + camelcase "^6.2.1" + case-sensitive-paths-webpack-plugin "^2.4.0" + css-loader "^6.5.1" + css-minimizer-webpack-plugin "^3.2.0" + dotenv "^10.0.0" + dotenv-expand "^5.1.0" + eslint "^8.3.0" + eslint-config-react-app "^7.0.1" + eslint-webpack-plugin "^3.1.1" + file-loader "^6.2.0" + fs-extra "^10.0.0" + html-webpack-plugin "^5.5.0" + identity-obj-proxy "^3.0.0" + jest "^27.4.3" + jest-resolve "^27.4.2" + jest-watch-typeahead "^1.0.0" + mini-css-extract-plugin "^2.4.5" + postcss "^8.4.4" + postcss-flexbugs-fixes "^5.0.2" + postcss-loader "^6.2.1" + postcss-normalize "^10.0.1" + postcss-preset-env "^7.0.1" + prompts "^2.4.2" + react-app-polyfill "^3.0.0" + react-dev-utils "^12.0.1" + react-refresh "^0.11.0" + resolve "^1.20.0" + resolve-url-loader "^4.0.0" + sass-loader "^12.3.0" + semver "^7.3.5" + source-map-loader "^3.0.0" + style-loader "^3.3.1" + tailwindcss "^3.0.2" + terser-webpack-plugin "^5.2.5" + webpack "^5.64.4" + webpack-dev-server "^4.6.0" + webpack-manifest-plugin "^4.0.2" + workbox-webpack-plugin "^6.4.1" + optionalDependencies: + fsevents "^2.3.2" + react-sizeme@^3.0.1: version "3.0.2" resolved "https://registry.yarnpkg.com/react-sizeme/-/react-sizeme-3.0.2.tgz#4a2f167905ba8f8b8d932a9e35164e459f9020e4" @@ -14619,7 +14702,7 @@ react-textarea-autosize@^8.3.0, react-textarea-autosize@^8.3.2: use-composed-ref "^1.0.0" use-latest "^1.0.0" -react-vega@^7.4.4: +react-vega@^7.4.4, react-vega@^7.5.0: version "7.5.0" resolved "https://registry.yarnpkg.com/react-vega/-/react-vega-7.5.0.tgz#b9726d4fd7f35299d417d340935e093bf4bed558" integrity sha512-JysyZ0PdihfSztkbxOd7DcYBrCVotRbkKiGNYWKkLP1D4Mt2Dq0uMwNtBEBGjoWdmrE3Qwd+uz7ekklP6MqxDw== @@ -17530,7 +17613,7 @@ vega-wordcloud@~4.1.3: vega-statistics "^1.7.9" vega-util "^1.15.2" -vega@^5.21.0: +vega@^5.21.0, vega@^5.22.1: version "5.22.1" resolved "https://registry.yarnpkg.com/vega/-/vega-5.22.1.tgz#e028f3645de18e0070317bc04410282975549e1e" integrity sha512-KJBI7OWSzpfCPbmWl3GQCqBqbf2TIdpWS0mzO6MmWbvdMhWHf74P9IVnx1B1mhg0ZTqWFualx9ZYhWzMMwudaQ== From 5a00942018bb11a06d2118467317538cf3ac9658 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 25 Apr 2022 14:38:13 -0400 Subject: [PATCH 13/62] rm react-codejar --- packages/components/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/components/package.json b/packages/components/package.json index 0477b407..1a66f2c9 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -41,7 +41,6 @@ "@storybook/react": "^6.4.22", "@types/styled-components": "^5.1.24", "@types/webpack": "^5.28.0", - "react-codejar": "^1.1.2", "style-loader": "^3.3.1", "ts-loader": "^9.2.8", "webpack": "^5.72.0", From e4ad5425c9423217ed95163b92ef52aed56bd39c Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 25 Apr 2022 14:44:10 -0400 Subject: [PATCH 14/62] Moved dependencies to devDependencies; updated versions Value: [0.1 to 0.67] --- packages/components/package.json | 50 ++++++++++++++--------------- packages/squiggle-lang/package.json | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index 1a66f2c9..def2be7f 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,33 +1,12 @@ { "name": "@quri/squiggle-components", - "version": "0.2.6", + "version": "0.2.9", "dependencies": { - "@quri/squiggle-lang": "0.2.2", - "@react-hook/size": "^2.1.2", - "@testing-library/jest-dom": "^5.16.4", - "@testing-library/react": "^13.1.1", - "@testing-library/user-event": "^14.1.1", - "@types/jest": "^27.4.0", - "@types/lodash": "^4.14.182", - "@types/node": "^17.0.25", - "@types/react": "^18.0.3", - "@types/react-dom": "^18.0.2", "antd": "^4.19.3", - "cross-env": "^7.0.3", - "lodash": "^4.17.21", - "react": "^18.0.0", "react-ace": "10.0.0", "react-dom": "^18.0.0", - "react-scripts": "5.0.1", - "react-vega": "^7.5.0", - "styled-components": "^5.3.5", - "tsconfig-paths-webpack-plugin": "^3.5.2", - "typescript": "^4.6.3", - "vega": "^5.22.1", - "vega-embed": "^6.20.6", - "vega-lite": "^5.2.0", - "web-vitals": "^2.1.4", - "webpack-cli": "^4.9.2" + "@react-hook/size": "^2.1.2", + "styled-components": "^5.3.5" }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.16.7", @@ -45,7 +24,28 @@ "ts-loader": "^9.2.8", "webpack": "^5.72.0", "webpack-cli": "^4.9.2", - "webpack-dev-server": "^4.8.1" + "webpack-dev-server": "^4.8.1", + "@quri/squiggle-lang": "0.2.5", + "@testing-library/jest-dom": "^5.16.4", + "@testing-library/react": "^13.1.1", + "@testing-library/user-event": "^14.1.1", + "@types/jest": "^27.4.0", + "@types/lodash": "^4.14.182", + "@types/node": "^17.0.25", + "@types/react": "^18.0.3", + "@types/react-dom": "^18.0.2", + "cross-env": "^7.0.3", + "lodash": "^4.17.21", + "react": "^18.0.0", + "react-scripts": "5.0.1", + "react-vega": "^7.5.0", + "tsconfig-paths-webpack-plugin": "^3.5.2", + "typescript": "^4.6.3", + "vega": "^5.22.1", + "vega-embed": "^6.20.6", + "vega-lite": "^5.2.0", + "web-vitals": "^2.1.4", + "webpack-cli": "^4.9.2" }, "scripts": { "start": "cross-env REACT_APP_FAST_REFRESH=false && start-storybook -p 6006 -s public", diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index ee8b550c..2ba09ab6 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -1,6 +1,6 @@ { "name": "@quri/squiggle-lang", - "version": "0.2.2", + "version": "0.2.5", "homepage": "https://squiggle-language.com", "scripts": { "build": "rescript build -with-deps", From f9c02ba6264fd58e6d8eeeb99df3773975398ff2 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 25 Apr 2022 14:50:45 -0400 Subject: [PATCH 15/62] Refactor and rename checkOrdered --- .../Distributions/AlgebraicShapeCombination_test.res | 2 +- .../PointSetDist/AlgebraicShapeCombination.res | 2 +- packages/squiggle-lang/src/rescript/Utility/E.res | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res index 74a378c5..21e029db 100644 --- a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res @@ -4,7 +4,7 @@ open TestHelpers describe("combine with discrete", () => { makeTest( "keep order when multiplying by negative number", - AlgebraicShapeCombination.checkOrdered( + AlgebraicShapeCombination.isOrdered( AlgebraicShapeCombination.combineShapesContinuousDiscrete( #Multiply, {xs: [0., 1.], ys: [1., 1.]}, diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index d4060cb8..b544fb33 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -255,4 +255,4 @@ let combineShapesContinuousDiscrete = ( ) } -let checkOrdered = (a: XYShape.T.t): bool => a.xs[0] < a.xs[1] +let isOrdered = (a: XYShape.T.t): bool => E.A.Sorted.Floats.isSorted(a.xs) diff --git a/packages/squiggle-lang/src/rescript/Utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res index 78c872ff..c3ba48a2 100644 --- a/packages/squiggle-lang/src/rescript/Utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -363,6 +363,9 @@ module A = { |> Rationale.Result.return } + let tail = Belt.Array.sliceToEnd(_, 1) + + let zip = Belt.Array.zip // This zips while taking the longest elements of each array. let zipMaxLength = (array1, array2) => { let maxLength = Int.max(length(array1), length(array2)) @@ -506,6 +509,9 @@ module A = { } module Floats = { + let isSorted = (ar: array): bool => + reduce(zip(ar, tail(ar)), true, (acc, (first, second)) => acc && first < second) + let makeIncrementalUp = (a, b) => Array.make(b - a + 1, a) |> Array.mapi((i, c) => c + i) |> Belt.Array.map(_, float_of_int) From a9d1c6b5e0d6b23525680860116576c49eff7e2d Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 25 Apr 2022 14:50:56 -0400 Subject: [PATCH 16/62] Fixed package versions in `website/package.json` Value: [0.1 to 0.3] --- packages/website/package.json | 2 +- yarn.lock | 168 ++-------------------------------- 2 files changed, 11 insertions(+), 159 deletions(-) diff --git a/packages/website/package.json b/packages/website/package.json index 986dfb22..a0e5fd33 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -13,7 +13,7 @@ "dependencies": { "@docusaurus/core": "2.0.0-beta.18", "@docusaurus/preset-classic": "2.0.0-beta.18", - "@quri/squiggle-components": "0.1.8", + "@quri/squiggle-components": "0.2.9", "clsx": "^1.1.1", "prism-react-renderer": "^1.2.1", "react": "^18.0.0", diff --git a/yarn.lock b/yarn.lock index 58168315..9ed487a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2333,36 +2333,6 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.5.tgz#db5a11bf66bdab39569719555b0f76e138d7bd64" integrity sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw== -"@quri/squiggle-components@0.1.8": - version "0.1.8" - resolved "https://registry.yarnpkg.com/@quri/squiggle-components/-/squiggle-components-0.1.8.tgz#a77d93ef670cc22e463fdb313aa27b3f7eebfbb5" - integrity sha512-pjO5LH/r7h9OiKtNd89QB88g+0qDY7TNqYUADlFhgeZEk/FNeApzSZlgJ+teLobFHkGgG05Kwz81gDa9MMoKHQ== - dependencies: - "@quri/squiggle-lang" "0.2.2" - "@testing-library/jest-dom" "^5.16.3" - "@testing-library/react" "^12.1.2" - "@testing-library/user-event" "^13.5.0" - "@types/jest" "^27.4.0" - "@types/lodash" "^4.14.178" - "@types/node" "^17.0.16" - "@types/react" "^17.0.43" - "@types/react-dom" "^17.0.14" - antd "^4.19.3" - cross-env "^7.0.3" - lodash "^4.17.21" - react "^17.0.2" - react-ace "^9.5.0" - react-dom "^17.0.2" - react-scripts "5.0.0" - react-vega "^7.4.4" - tsconfig-paths-webpack-plugin "^3.5.2" - typescript "^4.6.3" - vega "^5.21.0" - vega-embed "^6.20.6" - vega-lite "^5.2.0" - web-vitals "^2.1.4" - webpack-cli "^4.9.2" - "@react-hook/latest@^1.0.2": version "1.0.3" resolved "https://registry.yarnpkg.com/@react-hook/latest/-/latest-1.0.3.tgz#c2d1d0b0af8b69ec6e2b3a2412ba0768ac82db80" @@ -3671,7 +3641,7 @@ dependencies: defer-to-connect "^1.0.1" -"@testing-library/dom@^8.0.0", "@testing-library/dom@^8.5.0": +"@testing-library/dom@^8.5.0": version "8.13.0" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.13.0.tgz#bc00bdd64c7d8b40841e27a70211399ad3af46f5" integrity sha512-9VHgfIatKNXQNaZTtLnalIy0jNZzY35a4S3oi08YAt9Hv1VsfZ/DfA45lM8D/UhtHBGJ4/lGwp0PZkVndRkoOQ== @@ -3685,7 +3655,7 @@ lz-string "^1.4.4" pretty-format "^27.0.2" -"@testing-library/jest-dom@^5.16.3", "@testing-library/jest-dom@^5.16.4": +"@testing-library/jest-dom@^5.16.4": version "5.16.4" resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.4.tgz#938302d7b8b483963a3ae821f1c0808f872245cd" integrity sha512-Gy+IoFutbMQcky0k+bqqumXZ1cTGswLsFqmNLzNdSKkU9KGV2u9oXhukCbbJ9/LRPKiqwxEE8VpV/+YZlfkPUA== @@ -3700,15 +3670,6 @@ lodash "^4.17.15" redent "^3.0.0" -"@testing-library/react@^12.1.2": - version "12.1.5" - resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-12.1.5.tgz#bb248f72f02a5ac9d949dea07279095fa577963b" - integrity sha512-OfTXCJUFgjd/digLUuPxa0+/3ZxsQmE7ub9kcbW/wi96Bh3o/p5vrETcBGfP17NWPGqeYYl5LTRpwyGoMC4ysg== - dependencies: - "@babel/runtime" "^7.12.5" - "@testing-library/dom" "^8.0.0" - "@types/react-dom" "<18.0.0" - "@testing-library/react@^13.1.1": version "13.1.1" resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.1.1.tgz#6c1635e25acca8ca5be8ee3b19ad1391681c5846" @@ -3718,13 +3679,6 @@ "@testing-library/dom" "^8.5.0" "@types/react-dom" "^18.0.0" -"@testing-library/user-event@^13.5.0": - version "13.5.0" - resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-13.5.0.tgz#69d77007f1e124d55314a2b73fd204b333b13295" - integrity sha512-5Kwtbo3Y/NowpkbRuSepbyMFkZmHgD+vPzYB/RJ4oxt5Gj/avFFBYjhw27cqSVPVw/3a67NK1PbiIr9k4Gwmdg== - dependencies: - "@babel/runtime" "^7.12.5" - "@testing-library/user-event@^14.1.1": version "14.1.1" resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.1.1.tgz#e1ff6118896e4b22af31e5ea2f9da956adde23d8" @@ -3982,7 +3936,7 @@ resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.11.1.tgz#34de04477dcf79e2ef6c8d23b41a3d81f9ebeaf5" integrity sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg== -"@types/lodash@^4.14.178", "@types/lodash@^4.14.182": +"@types/lodash@^4.14.182": version "4.14.182" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2" integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q== @@ -4022,7 +3976,7 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.13.tgz#6ad4d9db59e6b3faf98dcfe4ca9d2aec84443277" integrity sha512-Z6/KzgyWOga3pJNS42A+zayjhPbf2zM3hegRQaOPnLOzEi86VV++6FLDWgR1LGrVCRufP/ph2daa3tEa5br1zA== -"@types/node@^17.0.16", "@types/node@^17.0.25": +"@types/node@^17.0.25": version "17.0.27" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.27.tgz#f4df3981ae8268c066e8f49995639f855469081e" integrity sha512-4/Ke7bbWOasuT3kceBZFGakP1dYN2XFd8v2l9bqF2LNWrmeU07JLpp56aEeG6+Q3olqO5TvXpW0yaiYnZJ5CXg== @@ -4087,13 +4041,6 @@ resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== -"@types/react-dom@<18.0.0", "@types/react-dom@^17.0.14": - version "17.0.15" - resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.15.tgz#f2c8efde11521a4b7991e076cb9c70ba3bb0d156" - integrity sha512-Tr9VU9DvNoHDWlmecmcsE5ZZiUkYx+nKBzum4Oxe1K0yJVyBlfbq7H3eXjxXqJczBKqPGq3EgfTru4MgKb9+Yw== - dependencies: - "@types/react" "^17" - "@types/react-dom@^18.0.0": version "18.0.0" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.0.tgz#b13f8d098e4b0c45df4f1ed123833143b0c71141" @@ -4141,7 +4088,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^16.9.19", "@types/react@^17", "@types/react@^17.0.43", "@types/react@^18.0.1", "@types/react@^18.0.3": +"@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": version "18.0.6" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.6.tgz#30206c3830af6ce8639b91ace5868bc2d3d1d96c" integrity sha512-bPqwzJRzKtfI0mVYr5R+1o9BOE8UEXefwc1LwcBtfnaAn6OoqMhLa/91VA8aeWfDPJt1kHvYKI8RHcQybZLHHA== @@ -4698,7 +4645,7 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" -ace-builds@^1.4.13, ace-builds@^1.4.14: +ace-builds@^1.4.14: version "1.4.14" resolved "https://registry.yarnpkg.com/ace-builds/-/ace-builds-1.4.14.tgz#2c41ccbccdd09e665d3489f161a20baeb3a3c852" integrity sha512-NBOQlm9+7RBqRqZwimpgquaLeTJFayqb9UEPtTkpC3TkkwDnlsT/TwsCC0svjt9kEZ6G9mH5AEOHSz6Q/HrzQQ== @@ -6444,11 +6391,6 @@ codecov@3.8.3: teeny-request "7.1.1" urlgrey "1.0.0" -codejar@^3.2.3: - version "3.6.0" - resolved "https://registry.yarnpkg.com/codejar/-/codejar-3.6.0.tgz#be491d4db4d723da24f1bcd735ecad09e0f6c36d" - integrity sha512-30iPkdz4Y3d2qVMpMKsvEREtfUBH6JHvW2aWeoCBR67DUoZqSQLIvcAlLWZuTG7i7DonJkbCqkBnJPPhbj+J6w== - collapse-white-space@^1.0.2: version "1.0.6" resolved "https://registry.yarnpkg.com/collapse-white-space/-/collapse-white-space-1.0.6.tgz#e63629c0016665792060dbbeb79c42239d2c5287" @@ -8093,7 +8035,7 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" -eslint-config-react-app@^7.0.0, eslint-config-react-app@^7.0.1: +eslint-config-react-app@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-7.0.1.tgz#73ba3929978001c5c86274c017ea57eb5fa644b4" integrity sha512-K6rNzvkIeHaTd8m/QEh1Zko0KI7BACWkkneSs6s9cKZC/J27X3eZR6Upt1jkmZ/4FK+XUOPPxMEN7+lbUXfSlA== @@ -14297,17 +14239,6 @@ react-ace@10.0.0: lodash.isequal "^4.5.0" prop-types "^15.7.2" -react-ace@^9.5.0: - version "9.5.0" - resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-9.5.0.tgz#b6c32b70d404dd821a7e01accc2d76da667ff1f7" - integrity sha512-4l5FgwGh6K7A0yWVMQlPIXDItM4Q9zzXRqOae8KkCl6MkOob7sC1CzHxZdOGvV+QioKWbX2p5HcdOVUv6cAdSg== - dependencies: - ace-builds "^1.4.13" - diff-match-patch "^1.0.5" - lodash.get "^4.4.2" - lodash.isequal "^4.5.0" - prop-types "^15.7.2" - react-app-polyfill@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/react-app-polyfill/-/react-app-polyfill-3.0.0.tgz#95221e0a9bd259e5ca6b177c7bb1cb6768f68fd7" @@ -14330,13 +14261,6 @@ react-base16-styling@^0.6.0: lodash.flow "^3.3.0" pure-color "^1.2.0" -react-codejar@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/react-codejar/-/react-codejar-1.1.2.tgz#b55789f8c7e5360bb63f3d2501c99e49453845cf" - integrity sha512-xGmwZ3ij1AQNkpeJUgOIqFzgZx9Nl4/onflOt6FjJrexzRMkBowAqmLTlLzZGdA8QmCSJf7hSlrClHZGFC8b4A== - dependencies: - codejar "^3.2.3" - react-colorful@^5.1.2: version "5.5.1" resolved "https://registry.yarnpkg.com/react-colorful/-/react-colorful-5.5.1.tgz#29d9c4e496f2ca784dd2bb5053a3a4340cfaf784" @@ -14393,15 +14317,6 @@ react-docgen@^5.0.0: node-dir "^0.1.10" strip-indent "^3.0.0" -react-dom@^17.0.2: - version "17.0.2" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23" - integrity sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - scheduler "^0.20.2" - react-dom@^18.0.0: version "18.0.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.0.0.tgz#26b88534f8f1dbb80853e1eabe752f24100d8023" @@ -14562,61 +14477,6 @@ react-router@6.3.0, react-router@^6.0.0: dependencies: history "^5.2.0" -react-scripts@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-5.0.0.tgz#6547a6d7f8b64364ef95273767466cc577cb4b60" - integrity sha512-3i0L2CyIlROz7mxETEdfif6Sfhh9Lfpzi10CtcGs1emDQStmZfWjJbAIMtRD0opVUjQuFWqHZyRZ9PPzKCFxWg== - dependencies: - "@babel/core" "^7.16.0" - "@pmmmwh/react-refresh-webpack-plugin" "^0.5.3" - "@svgr/webpack" "^5.5.0" - babel-jest "^27.4.2" - babel-loader "^8.2.3" - babel-plugin-named-asset-import "^0.3.8" - babel-preset-react-app "^10.0.1" - bfj "^7.0.2" - browserslist "^4.18.1" - camelcase "^6.2.1" - case-sensitive-paths-webpack-plugin "^2.4.0" - css-loader "^6.5.1" - css-minimizer-webpack-plugin "^3.2.0" - dotenv "^10.0.0" - dotenv-expand "^5.1.0" - eslint "^8.3.0" - eslint-config-react-app "^7.0.0" - eslint-webpack-plugin "^3.1.1" - file-loader "^6.2.0" - fs-extra "^10.0.0" - html-webpack-plugin "^5.5.0" - identity-obj-proxy "^3.0.0" - jest "^27.4.3" - jest-resolve "^27.4.2" - jest-watch-typeahead "^1.0.0" - mini-css-extract-plugin "^2.4.5" - postcss "^8.4.4" - postcss-flexbugs-fixes "^5.0.2" - postcss-loader "^6.2.1" - postcss-normalize "^10.0.1" - postcss-preset-env "^7.0.1" - prompts "^2.4.2" - react-app-polyfill "^3.0.0" - react-dev-utils "^12.0.0" - react-refresh "^0.11.0" - resolve "^1.20.0" - resolve-url-loader "^4.0.0" - sass-loader "^12.3.0" - semver "^7.3.5" - source-map-loader "^3.0.0" - style-loader "^3.3.1" - tailwindcss "^3.0.2" - terser-webpack-plugin "^5.2.5" - webpack "^5.64.4" - webpack-dev-server "^4.6.0" - webpack-manifest-plugin "^4.0.2" - workbox-webpack-plugin "^6.4.1" - optionalDependencies: - fsevents "^2.3.2" - react-scripts@5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-5.0.1.tgz#6285dbd65a8ba6e49ca8d651ce30645a6d980003" @@ -14702,7 +14562,7 @@ react-textarea-autosize@^8.3.0, react-textarea-autosize@^8.3.2: use-composed-ref "^1.0.0" use-latest "^1.0.0" -react-vega@^7.4.4, react-vega@^7.5.0: +react-vega@^7.5.0: version "7.5.0" resolved "https://registry.yarnpkg.com/react-vega/-/react-vega-7.5.0.tgz#b9726d4fd7f35299d417d340935e093bf4bed558" integrity sha512-JysyZ0PdihfSztkbxOd7DcYBrCVotRbkKiGNYWKkLP1D4Mt2Dq0uMwNtBEBGjoWdmrE3Qwd+uz7ekklP6MqxDw== @@ -14711,7 +14571,7 @@ react-vega@^7.4.4, react-vega@^7.5.0: fast-deep-equal "^3.1.1" vega-embed "^6.5.1" -react@^17.0.2, react@^18.0.0: +react@^18.0.0: version "18.0.0" resolved "https://registry.yarnpkg.com/react/-/react-18.0.0.tgz#b468736d1f4a5891f38585ba8e8fb29f91c3cb96" integrity sha512-x+VL6wbT4JRVPm7EGxXhZ8w8LTROaxPXOqhlGyVSrv0sB1jkyFGgXxJ8LVoPRLvPR6/CIZGFmfzqUa2NYeMr2A== @@ -15359,14 +15219,6 @@ saxes@^5.0.1: dependencies: xmlchars "^2.2.0" -scheduler@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91" - integrity sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - scheduler@^0.21.0: version "0.21.0" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0.tgz#6fd2532ff5a6d877b6edb12f00d8ab7e8f308820" @@ -17613,7 +17465,7 @@ vega-wordcloud@~4.1.3: vega-statistics "^1.7.9" vega-util "^1.15.2" -vega@^5.21.0, vega@^5.22.1: +vega@^5.22.1: version "5.22.1" resolved "https://registry.yarnpkg.com/vega/-/vega-5.22.1.tgz#e028f3645de18e0070317bc04410282975549e1e" integrity sha512-KJBI7OWSzpfCPbmWl3GQCqBqbf2TIdpWS0mzO6MmWbvdMhWHf74P9IVnx1B1mhg0ZTqWFualx9ZYhWzMMwudaQ== From f58def8585b56173e0683ec82748a13bb249430d Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 25 Apr 2022 14:52:52 -0400 Subject: [PATCH 17/62] Rename AlgebraicShapeCombination test case --- .../Distributions/AlgebraicShapeCombination_test.res | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res index 21e029db..7b84ee99 100644 --- a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res @@ -1,9 +1,9 @@ open Jest open TestHelpers -describe("combine with discrete", () => { +describe("Combining Continuous and Discrete Distributions", () => { makeTest( - "keep order when multiplying by negative number", + "keep order of xs when multiplying by negative number", AlgebraicShapeCombination.isOrdered( AlgebraicShapeCombination.combineShapesContinuousDiscrete( #Multiply, From aa192883e2063e8a862784547644049a7b9d6137 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 25 Apr 2022 15:18:18 -0400 Subject: [PATCH 18/62] Fix missing paramater in test Value: [0.001 to 0.01] --- .../__tests__/Distributions/AlgebraicShapeCombination_test.res | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res index 7b84ee99..c1e203ad 100644 --- a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res @@ -9,6 +9,7 @@ describe("Combining Continuous and Discrete Distributions", () => { #Multiply, {xs: [0., 1.], ys: [1., 1.]}, {xs: [-1.], ys: [1.]}, + false ), ), // Multiply distribution by -1 true, From 62653d55b4dc69f6c5bc4c3dc7e59a14fb69e40e Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 25 Apr 2022 15:46:56 -0400 Subject: [PATCH 19/62] Fix pointwise not commuting for subtraction --- .../ReducerInterface/ReducerInterface_Distribution_test.res | 1 + .../PointSetDist/AlgebraicShapeCombination.res | 6 +++++- 2 files changed, 6 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 605797b9..a4569a88 100644 --- a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res @@ -54,6 +54,7 @@ describe("eval on distribution functions", () => { describe("subtract", () => { testEval("10 - normal(5, 1)", "Ok(Normal(5,1))") testEval("normal(5, 1) - 10", "Ok(Normal(-5,1))") + testEval("mean(1 - toPointSet(normal(5, 2)))", "Ok(-4.002309896304692)") }) describe("multiply", () => { testEval("normal(10, 2) * 2", "Ok(Normal(20,4))") diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index 673f53f7..cf563d91 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -209,9 +209,13 @@ let combineShapesContinuousDiscrete = ( // creates a new continuous shape for each one of the discrete points, and collects them in outXYShapes. let dxyShape: array<(float, float)> = Belt.Array.makeUninitializedUnsafe(t1n) for i in 0 to t1n - 1 { + // When this operation is flipped (like 1 - normal(5, 2)) then the + // x axis coordinates would all come out the wrong order. So we need + // to fill them out in the opposite direction + let index = flip ? t1n - 1 - i : i Belt.Array.set( dxyShape, - i, + index, ( fn(continuousShape.xs[i], discreteShape.xs[j]), continuousShape.ys[i] *. discreteShape.ys[j], From 6bfecf22041673a1cb7afa9ea755b20db54983d8 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 25 Apr 2022 15:55:25 -0400 Subject: [PATCH 20/62] Rename flip argument to be more descriptive --- .../AlgebraicShapeCombination_test.res | 2 +- .../PointSetDist/AlgebraicShapeCombination.res | 8 +++++--- .../Distributions/PointSetDist/Continuous.res | 4 ++-- .../rescript/Distributions/PointSetDist/Mixed.res | 4 ++-- .../Distributions/PointSetDist/PointSetDist.res | 14 ++++++++++++-- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res index c1e203ad..702b67a4 100644 --- a/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/AlgebraicShapeCombination_test.res @@ -9,7 +9,7 @@ describe("Combining Continuous and Discrete Distributions", () => { #Multiply, {xs: [0., 1.], ys: [1., 1.]}, {xs: [-1.], ys: [1.]}, - false + ~discretePosition=Second, ), ), // Multiply distribution by -1 true, diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index cf563d91..63600e43 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -187,18 +187,20 @@ let toDiscretePointMassesFromDiscrete = (s: PointSetTypes.xyShape): pointMassesW {n: n, masses: masses, means: means, variances: variances} } +type argumentPosition = First | Second + let combineShapesContinuousDiscrete = ( op: Operation.convolutionOperation, continuousShape: PointSetTypes.xyShape, discreteShape: PointSetTypes.xyShape, - flip: bool, + ~discretePosition: argumentPosition, ): PointSetTypes.xyShape => { let t1n = continuousShape |> XYShape.T.length let t2n = discreteShape |> XYShape.T.length // each x pair is added/subtracted let opFunc = Operation.Convolution.toFn(op) - let fn = flip ? (a, b) => opFunc(b, a) : opFunc + let fn = discretePosition == First ? (a, b) => opFunc(b, a) : opFunc let outXYShapes: array> = Belt.Array.makeUninitializedUnsafe(t2n) @@ -212,7 +214,7 @@ let combineShapesContinuousDiscrete = ( // When this operation is flipped (like 1 - normal(5, 2)) then the // x axis coordinates would all come out the wrong order. So we need // to fill them out in the opposite direction - let index = flip ? t1n - 1 - i : i + let index = discretePosition == First ? t1n - 1 - i : i Belt.Array.set( dxyShape, index, diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res index de5d65ed..5e44f900 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res @@ -278,7 +278,7 @@ let combineAlgebraicallyWithDiscrete = ( op: Operation.convolutionOperation, t1: t, t2: PointSetTypes.discreteShape, - flip: bool, + ~discretePosition: AlgebraicShapeCombination.argumentPosition, ) => { let t1s = t1 |> getShape let t2s = t2.xyShape // TODO would like to use Discrete.getShape here, but current file structure doesn't allow for that @@ -295,7 +295,7 @@ let combineAlgebraicallyWithDiscrete = ( op, continuousAsLinear |> getShape, t2s, - flip, + ~discretePosition, ) let combinedIntegralSum = switch op { diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res index da604262..4ce2bdd6 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res @@ -281,13 +281,13 @@ let combineAlgebraically = (op: Operation.convolutionOperation, t1: t, t2: t): t op, t2.continuous, t1.discrete, - true, + ~discretePosition=First, ) let cdConvResult = Continuous.combineAlgebraicallyWithDiscrete( op, t1.continuous, t2.discrete, - false, + ~discretePosition=Second, ) let continuousConvResult = Continuous.sum([ccConvResult, dcConvResult, cdConvResult]) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res index 641532d6..12aa5477 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res @@ -47,9 +47,19 @@ let combineAlgebraically = (op: Operation.convolutionOperation, t1: t, t2: t): t | (Continuous(m1), Continuous(m2)) => Continuous.combineAlgebraically(op, m1, m2) |> Continuous.T.toPointSetDist | (Discrete(m1), Continuous(m2)) => - Continuous.combineAlgebraicallyWithDiscrete(op, m2, m1, true) |> Continuous.T.toPointSetDist + Continuous.combineAlgebraicallyWithDiscrete( + op, + m2, + m1, + ~discretePosition=First, + ) |> Continuous.T.toPointSetDist | (Continuous(m1), Discrete(m2)) => - Continuous.combineAlgebraicallyWithDiscrete(op, m1, m2, false) |> Continuous.T.toPointSetDist + Continuous.combineAlgebraicallyWithDiscrete( + op, + m1, + m2, + ~discretePosition=Second, + ) |> Continuous.T.toPointSetDist | (Discrete(m1), Discrete(m2)) => Discrete.combineAlgebraically(op, m1, m2) |> Discrete.T.toPointSetDist | (m1, m2) => Mixed.combineAlgebraically(op, toMixed(m1), toMixed(m2)) |> Mixed.T.toPointSetDist From 18dd66e5a4925b6d6fa460f90c9bfceeec101cdb Mon Sep 17 00:00:00 2001 From: Quinn Date: Mon, 25 Apr 2022 16:11:11 -0400 Subject: [PATCH 21/62] hotfix: codecov stuff in `.npmignore` --- packages/squiggle-lang/.npmignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/squiggle-lang/.npmignore b/packages/squiggle-lang/.npmignore index 74c2c781..bfbe051d 100644 --- a/packages/squiggle-lang/.npmignore +++ b/packages/squiggle-lang/.npmignore @@ -9,3 +9,7 @@ examples yarn.nix bsconfig.json tsconfig.json +.nyc_outputs +*.coverage +_coverage +coverage From 3367b82eef8ec4a2ac86a07fb6ba214a31867b46 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 25 Apr 2022 20:55:16 -0400 Subject: [PATCH 22/62] `mode` to determine dist mode to operate in Value: [1.2 to 4.6] --- .../Distributions/DistributionTypes.res | 2 ++ .../Distributions/GenericDist/GenericDist.res | 18 +++++++++++++++++- .../Distributions/GenericDist/GenericDist.resi | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res index 98c49a21..3a256ea0 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res @@ -14,6 +14,7 @@ type error = | OperationError(Operation.Error.t) | PointSetConversionError(SampleSetDist.pointsetConversionError) | SparklineError(PointSetTypes.sparklineError) // This type of error is for when we find a sparkline of a discrete distribution. This should probably at some point be actually implemented + | RequestedModeInvalidError | OtherError(string) @genType @@ -33,6 +34,7 @@ module Error = { | OperationError(err) => Operation.Error.toString(err) | PointSetConversionError(err) => SampleSetDist.pointsetConversionErrorToString(err) | SparklineError(err) => PointSetTypes.sparklineErrorToString(err) + | RequestedModeInvalidError => `Requested mode invalid` | OtherError(s) => s } diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index 47fb2c01..d91db41e 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -5,6 +5,7 @@ type toPointSetFn = t => result type toSampleSetFn = t => result type scaleMultiplyFn = (t, float) => result type pointwiseAddFn = (t, t) => result +type asMode = AsSymbolic | AsMontecarlo | AsConvolution let sampleN = (t: t, n) => switch t { @@ -215,7 +216,7 @@ module AlgebraicCombination = { : Convolution(convOp) } - let run = ( + let run' = ( t1: t, ~toPointSetFn: toPointSetFn, ~toSampleSetFn: toSampleSetFn, @@ -233,6 +234,21 @@ module AlgebraicCombination = { } } } + + let run = ( + ~mode: option=?, + t1: t, + ~toPointSetFn: toPointSetFn, + ~toSampleSetFn: toSampleSetFn, + ~arithmeticOperation, + ~t2: t, + ): result => { + let algebraicResult = run'(t1, ~toPointSetFn, ~toSampleSetFn, ~arithmeticOperation, ~t2) + switch mode { + | Some(_) => algebraicResult + | None => Error(RequestedModeInvalidError) + } + } } let algebraicCombination = AlgebraicCombination.run diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi index ce32a39b..ccb9a5c6 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi @@ -4,6 +4,7 @@ type toPointSetFn = t => result type toSampleSetFn = t => result type scaleMultiplyFn = (t, float) => result type pointwiseAddFn = (t, t) => result +type asMode = AsSymbolic | AsMontecarlo | AsConvolution let sampleN: (t, int) => array @@ -42,6 +43,7 @@ let truncate: ( ) => result let algebraicCombination: ( + ~mode: asMode=?, t, ~toPointSetFn: toPointSetFn, ~toSampleSetFn: toSampleSetFn, From 5ef8cf5dde446106c25bac1492449556f02c73c1 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 25 Apr 2022 21:04:11 -0400 Subject: [PATCH 23/62] Fixed implementation Value: [0.4 to 2] --- .../rescript/Distributions/GenericDist/GenericDist.res | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index d91db41e..71054fe8 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -244,9 +244,13 @@ module AlgebraicCombination = { ~t2: t, ): result => { let algebraicResult = run'(t1, ~toPointSetFn, ~toSampleSetFn, ~arithmeticOperation, ~t2) - switch mode { - | Some(_) => algebraicResult - | None => Error(RequestedModeInvalidError) + switch (mode, algebraicResult) { + | (None, _) + | (Some(AsSymbolic), Ok(Symbolic(_))) + | (Some(AsMontecarlo), Ok(DistributionTypes.SampleSet(_))) + | (Some(AsConvolution), Ok(DistributionTypes.PointSet(_))) + | (Some(_), Error(_)) => algebraicResult + | (Some(_), Ok(_)) => Error(RequestedModeInvalidError) } } } From 2c1aff25d3bb2f3b5143b3bc670a0ebf4e850f7d Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Mon, 25 Apr 2022 21:46:40 -0400 Subject: [PATCH 24/62] Added basic functins to SampleSetDist --- .../Invariants/AlgebraicCombination_test.res | 11 ++++----- .../Distributions/GenericDist/GenericDist.res | 23 ++++++++++++------- .../SampleSetDist/SampleSetDist.res | 10 ++++++++ .../squiggle-lang/src/rescript/Utility/E.res | 15 +++++++++--- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res index 430bc900..c03f934b 100644 --- a/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res @@ -65,8 +65,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - // Answer found from WolframAlpha: ``mean(uniform(9,10)) + mean(betaDistribution(2,5))`` - | Some(x) => x->expect->toBeSoCloseTo(9.786, ~digits=1) // (uniformMean +. betaMean) + | Some(x) => x->expect->toBeSoCloseTo(9.786831807237022, ~digits=1) // (uniformMean +. betaMean) } }) test("beta(alpha=2, beta=5) + uniform(low=9, high=10)", () => { @@ -83,7 +82,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(9.786, ~digits=1) // (uniformMean +. betaMean) + | Some(x) => x->expect->toBeSoCloseTo(9.784290207736126, ~digits=1) // (uniformMean +. betaMean) } }) }) @@ -164,7 +163,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(1.025, ~digits=1) + | Some(x) => x->expect->toBeSoCloseTo(0.9677, ~digits=1) } }) test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).pdf(10)", () => { @@ -347,7 +346,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(9.174960348568693, ~digits=0) + | Some(x) => x->expect->toBeSoCloseTo(9.18416389919939, ~digits=0) } }) test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).inv(2e-2)", () => { @@ -362,7 +361,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(9.168291999681523, ~digits=0) + | Some(x) => x->expect->toBeSoCloseTo(9.190872365862756, ~digits=0) } }) }) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index 47fb2c01..20da5f75 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -46,18 +46,25 @@ let toFloatOperation = ( ~toPointSetFn: toPointSetFn, ~distToFloatOperation: Operation.distToFloatOperation, ) => { - let symbolicSolution = switch (t: t) { - | Symbolic(r) => - switch SymbolicDist.T.operate(distToFloatOperation, r) { - | Ok(f) => Some(f) - | _ => None - } + let trySymbolicSolution = switch (t: t) { + | Symbolic(r) => SymbolicDist.T.operate(distToFloatOperation, r)->E.R.toOption | _ => None } - switch symbolicSolution { + let trySampleSetSolution = switch ((t: t), distToFloatOperation) { + | (SampleSet(sampleSet), #Mean) => SampleSetDist.mean(sampleSet)->Some + | (SampleSet(sampleSet), #Sample) => SampleSetDist.sample(sampleSet)->Some + | (SampleSet(sampleSet), #Inv(r)) => SampleSetDist.percentile(sampleSet, r)->Some + | _ => None + } + + switch trySymbolicSolution { | Some(r) => Ok(r) - | None => toPointSetFn(t)->E.R2.fmap(PointSetDist.operate(distToFloatOperation)) + | None => + switch trySampleSetSolution { + | Some(r) => Ok(r) + | None => toPointSetFn(t)->E.R2.fmap(PointSetDist.operate(distToFloatOperation)) + } } } diff --git a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res index 74dba954..d85b8716 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res @@ -98,3 +98,13 @@ let map2 = (~fn: (float, float) => result, ~t1: t, ~t2 E.R.toExn("Input of samples should be larger than 5", make(x)) ) } + +let mean = t => T.get(t)->E.A.Floats.mean +let geomean = t => T.get(t)->E.A.Floats.geomean +let mode = t => T.get(t)->E.A.Floats.mode +let sum = t => T.get(t)->E.A.Floats.sum +let min = t => T.get(t)->E.A.Floats.min +let max = t => T.get(t)->E.A.Floats.max +let stdev = t => T.get(t)->E.A.Floats.stdev +let variance = t => T.get(t)->E.A.Floats.variance +let percentile = (t,f) => T.get(t)->E.A.Floats.percentile(f) \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/Utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res index 78c872ff..5a4e1203 100644 --- a/packages/squiggle-lang/src/rescript/Utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -522,7 +522,8 @@ module A = { | n if n == maxIndex => [index - 1] | _ => [index - 1, index + 1] } |> Belt.Array.map(_, r => sortedArray[r]) - let hasSimilarElement = Belt.Array.some(possiblySimilarElements, r => r == element) + // let hasSimilarElement = Belt.Array.some(possiblySimilarElements, r => r == element) + let hasSimilarElement = false hasSimilarElement ? FloatFloatMap.increment(element, discrete) : { @@ -538,10 +539,18 @@ module A = { } module Floats = { - let sum = Belt.Array.reduce(_, 0., (i, j) => i +. j) - let mean = a => sum(a) /. (Array.length(a) |> float_of_int) + let mean = Jstat.mean + let geomean = Jstat.geomean + let mode = Jstat.mode + let variance = Jstat.variance + let stdev = Jstat.stdev + let sum = Jstat.sum let random = Js.Math.random_int + //Passing true for the exclusive parameter excludes both endpoints of the range. + //https://jstat.github.io/all.html + let percentile = (a,b) => Jstat.percentile(a,b, false) + // Gives an array with all the differences between values // diff([1,5,3,7]) = [4,-2,4] let diff = (arr: array): array => From 9cfadffcb75582b99ae1460c3e768f010d21327f Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 09:54:16 -0400 Subject: [PATCH 25/62] Added `rescript-fast-check` Value: [0.1 to 1] Sam actually gets credit for figuring out how this works without Mocha. --- packages/squiggle-lang/package.json | 1 + yarn.lock | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 2ba09ab6..d912f208 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -37,6 +37,7 @@ "pdfast": "^0.2.0", "rationale": "0.2.0", "rescript": "^9.1.4", + "rescript-fast-check": "^1.1.1", "@glennsl/rescript-jest": "^0.9.0", "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/jest": "^27.4.0", diff --git a/yarn.lock b/yarn.lock index 9ed487a8..b4c753b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8479,6 +8479,13 @@ fast-check@2.24.0: dependencies: pure-rand "^5.0.1" +fast-check@^2.17.0: + version "2.25.0" + resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.25.0.tgz#5146601851bf3be0953bd17eb2b7d547936c6561" + integrity sha512-wRUT2KD2lAmT75WNIJIHECawoUUMHM0I5jrlLXGtGeqmPL8jl/EldUDjY1VCp6fDY8yflyfUeIOsOBrIbIiArg== + dependencies: + pure-rand "^5.0.1" + fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3, fast-deep-equal@~3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -14970,6 +14977,13 @@ requires-port@^1.0.0: resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= +rescript-fast-check@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/rescript-fast-check/-/rescript-fast-check-1.1.1.tgz#ef153cb01254b2f01a738faf85b73327d423d5e1" + integrity sha512-wxeW0TsL/prkRvEYGbhEiLaLKmYJaECyDcKEWh65hDqP2i76lARzVW3QmYujSYK4OnjAC70dln3X6UC/2m2Huw== + dependencies: + fast-check "^2.17.0" + rescript@^9.1.4: version "9.1.4" resolved "https://registry.yarnpkg.com/rescript/-/rescript-9.1.4.tgz#1eb126f98d6c16942c0bf0df67c050198e580515" From 809703c418b660e5f4ab508c7d8879473479dd7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:04:14 +0000 Subject: [PATCH 26/62] :arrow_up: Bump antd from 4.20.0 to 4.20.1 Bumps [antd](https://github.com/ant-design/ant-design) from 4.20.0 to 4.20.1. - [Release notes](https://github.com/ant-design/ant-design/releases) - [Changelog](https://github.com/ant-design/ant-design/blob/master/CHANGELOG.en-US.md) - [Commits](https://github.com/ant-design/ant-design/compare/4.20.0...4.20.1) --- updated-dependencies: - dependency-name: antd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- packages/components/package.json | 2 +- yarn.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index def2be7f..537932bd 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -2,7 +2,7 @@ "name": "@quri/squiggle-components", "version": "0.2.9", "dependencies": { - "antd": "^4.19.3", + "antd": "^4.20.1", "react-ace": "10.0.0", "react-dom": "^18.0.0", "@react-hook/size": "^2.1.2", diff --git a/yarn.lock b/yarn.lock index 9ed487a8..38479784 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4089,9 +4089,9 @@ "@types/react" "*" "@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": - version "18.0.6" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.6.tgz#30206c3830af6ce8639b91ace5868bc2d3d1d96c" - integrity sha512-bPqwzJRzKtfI0mVYr5R+1o9BOE8UEXefwc1LwcBtfnaAn6OoqMhLa/91VA8aeWfDPJt1kHvYKI8RHcQybZLHHA== + version "18.0.7" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.7.tgz#8437a226763adf854969954dfe582529a406cbad" + integrity sha512-CXSXHzTexlX9esf4ReIUJeaemKcmBEvYzxHDUk19c3BCcEGUvUjkeC3jkscPSfSaQ6SPDRNd/zMxi8oc/P1zxA== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -4899,10 +4899,10 @@ ansi-to-html@^0.6.11: dependencies: entities "^2.0.0" -antd@^4.19.3: - version "4.20.0" - resolved "https://registry.yarnpkg.com/antd/-/antd-4.20.0.tgz#5f5fa4fccb90dd3e091c8d6e9d503114d98d862f" - integrity sha512-Msowfvabsn/yJIo3qYU0vMqGb31OUylMeFRDilosBViG2AS8R2VB2IX53kbw4kFV3vr7fr2HXcuQkf/FMLU+Dg== +antd@^4.20.1: + version "4.20.1" + resolved "https://registry.yarnpkg.com/antd/-/antd-4.20.1.tgz#6cd5a406c7172d61a5d0693ea52ee908650cf674" + integrity sha512-asKxOV0a6AijqonbcXkO08/q+XvqS/HmGfaRIS6ZH1ALR3FS2q+kTW52rJZO9rfoOb/ldPhEBVSWiNrbiB+uCQ== dependencies: "@ant-design/colors" "^6.0.0" "@ant-design/icons" "^4.7.0" From 6a6e27463fdab2c0d922912d9333a4865cd2d1d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:05:52 +0000 Subject: [PATCH 27/62] :arrow_up: Bump fast-check from 2.24.0 to 2.25.0 Bumps [fast-check](https://github.com/dubzzz/fast-check) from 2.24.0 to 2.25.0. - [Release notes](https://github.com/dubzzz/fast-check/releases) - [Changelog](https://github.com/dubzzz/fast-check/blob/main/CHANGELOG.md) - [Commits](https://github.com/dubzzz/fast-check/compare/v2.24.0...v2.25.0) --- updated-dependencies: - dependency-name: fast-check dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- packages/squiggle-lang/package.json | 2 +- yarn.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 2ba09ab6..bf31a059 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -42,7 +42,7 @@ "@types/jest": "^27.4.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", "codecov": "3.8.3", - "fast-check": "2.24.0", + "fast-check": "2.25.0", "gentype": "^4.3.0", "jest": "^27.5.1", "moduleserve": "0.9.1", diff --git a/yarn.lock b/yarn.lock index 9ed487a8..39061da5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4089,9 +4089,9 @@ "@types/react" "*" "@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": - version "18.0.6" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.6.tgz#30206c3830af6ce8639b91ace5868bc2d3d1d96c" - integrity sha512-bPqwzJRzKtfI0mVYr5R+1o9BOE8UEXefwc1LwcBtfnaAn6OoqMhLa/91VA8aeWfDPJt1kHvYKI8RHcQybZLHHA== + version "18.0.7" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.7.tgz#8437a226763adf854969954dfe582529a406cbad" + integrity sha512-CXSXHzTexlX9esf4ReIUJeaemKcmBEvYzxHDUk19c3BCcEGUvUjkeC3jkscPSfSaQ6SPDRNd/zMxi8oc/P1zxA== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -8472,10 +8472,10 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -fast-check@2.24.0: - version "2.24.0" - resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.24.0.tgz#39f85586862108a4de6394c5196ebcf8b76b6c8b" - integrity sha512-iNXbN90lbabaCUfnW5jyXYPwMJLFYl09eJDkXA9ZoidFlBK63gNRvcKxv+8D1OJ1kIYjwBef4bO/K3qesUeWLQ== +fast-check@2.25.0: + version "2.25.0" + resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.25.0.tgz#5146601851bf3be0953bd17eb2b7d547936c6561" + integrity sha512-wRUT2KD2lAmT75WNIJIHECawoUUMHM0I5jrlLXGtGeqmPL8jl/EldUDjY1VCp6fDY8yflyfUeIOsOBrIbIiArg== dependencies: pure-rand "^5.0.1" From 00553c03e1027bc1fdf205d3211784ce09282752 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:12:31 +0000 Subject: [PATCH 28/62] :arrow_up: Bump react-ace from 10.0.0 to 10.1.0 Bumps [react-ace](https://github.com/securingsincity/react-ace) from 10.0.0 to 10.1.0. - [Release notes](https://github.com/securingsincity/react-ace/releases) - [Changelog](https://github.com/securingsincity/react-ace/blob/main/CHANGELOG.md) - [Commits](https://github.com/securingsincity/react-ace/compare/v10.0.0...v10.1.0) --- updated-dependencies: - dependency-name: react-ace dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- packages/components/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index 537932bd..f0bf32f2 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -3,7 +3,7 @@ "version": "0.2.9", "dependencies": { "antd": "^4.20.1", - "react-ace": "10.0.0", + "react-ace": "10.1.0", "react-dom": "^18.0.0", "@react-hook/size": "^2.1.2", "styled-components": "^5.3.5" diff --git a/yarn.lock b/yarn.lock index 5e2eb43a..90b85189 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14228,10 +14228,10 @@ rc@^1.2.8: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-ace@10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-10.0.0.tgz#1760e302604cff35ba40963db43eb027513b6572" - integrity sha512-AUoA2OsKOCv8fXLqcFM232dF/Z8w14bwPUZ9z5I2zjBfqfZOZLqxnhXN+qKL6VrQXs1DLUvalGOuM5TABAFOCA== +react-ace@10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-10.1.0.tgz#d348eac2b16475231779070b6cd16768deed565f" + integrity sha512-VkvUjZNhdYTuKOKQpMIZi7uzZZVgzCjM7cLYu6F64V0mejY8a2XTyPUIMszC6A4trbeMIHbK5fYFcT/wkP/8VA== dependencies: ace-builds "^1.4.14" diff-match-patch "^1.0.5" From 0b42604ea7c5ee78ad735778f2a96c5dd638233d Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Tue, 26 Apr 2022 11:59:07 -0400 Subject: [PATCH 29/62] First attempt at fixing tests --- .../__tests__/Distributions/SampleSetDist_test.res | 1 + packages/squiggle-lang/__tests__/TS/JS_test.ts | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_test.res b/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_test.res index ee36d191..1c430f3d 100644 --- a/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_test.res @@ -37,4 +37,5 @@ describe("Continuous and discrete splits", () => { ) let toArr2 = discrete2 |> E.FloatFloatMap.toArray makeTest("splitMedium at count=500", toArr2 |> Belt.Array.length, 500) + // makeTest("foo", [] |> Belt.Array.length, 500) }) diff --git a/packages/squiggle-lang/__tests__/TS/JS_test.ts b/packages/squiggle-lang/__tests__/TS/JS_test.ts index 7a68160c..ee1183a4 100644 --- a/packages/squiggle-lang/__tests__/TS/JS_test.ts +++ b/packages/squiggle-lang/__tests__/TS/JS_test.ts @@ -56,13 +56,13 @@ describe("Distribution", () => { ); test("mean", () => { - expect(dist.mean().value).toBeCloseTo(5.3913); + expect(dist.mean().value).toBeCloseTo(9.5555); }); test("pdf", () => { - expect(dist.pdf(5.0).value).toBeCloseTo(0.0431); + expect(dist.pdf(5.0).value).toBeCloseTo(0.10499); }); test("cdf", () => { - expect(dist.cdf(5.0).value).toBeCloseTo(0.224); + expect(dist.cdf(5.0).value).toBeCloseTo(0.328); }); test("inv", () => { expect(dist.inv(0.5).value).toBeCloseTo(6.0); @@ -73,7 +73,7 @@ describe("Distribution", () => { ).toEqual(Ok("Point Set Distribution")); }); test("toSparkline", () => { - expect(dist.toSparkline(20).value).toEqual("▁▁▃▅███▆▄▃▂▁▁▂▂▃▂▁▁▁"); + expect(dist.toSparkline(20).value).toEqual("▁▁▃▇█▇▄▂▂▂▁▁▁▁▁▂▂▁▁▁"); }); test("algebraicAdd", () => { expect( @@ -87,6 +87,6 @@ describe("Distribution", () => { resultMap(dist.pointwiseAdd(dist2), (r: Distribution) => r.toSparkline(20) ).value - ).toEqual(Ok("▁▂▅█▇▅▅▆▇██▇▅▄▃▃▃▂▁▁")); + ).toEqual(Ok("▁▂██▃▃▃▃▄▅▄▃▃▂▂▂▁▁▁▁")); }); }); From e47deb84334e076907239437af62ae96f08fc3d4 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 12:22:31 -0400 Subject: [PATCH 30/62] Translate pmf to pdf for kde --- .../Invariants/AlgebraicCombination_test.res | 25 +++++++++---------- .../SampleSetDist_ToPointSet_test.res | 22 ++++++++++++++++ .../squiggle-lang/__tests__/TS/JS_test.ts | 14 +++++++---- .../__tests__/TS/SampleSet_test.ts | 4 ++- .../Distributions/SampleSetDist/KdeLibrary.js | 12 ++++++++- 5 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 packages/squiggle-lang/__tests__/Distributions/SampleSetDist_ToPointSet_test.res diff --git a/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res b/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res index a0f492a1..488ffaa6 100644 --- a/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/Invariants/AlgebraicCombination_test.res @@ -65,7 +65,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(0.01927225696028752, ~digits=1) // (uniformMean +. betaMean) + | Some(x) => x->expect->toBeSoCloseTo(9.78655777150074, ~digits=1) // (uniformMean +. betaMean) } }) test("beta(alpha=2, beta=5) + uniform(low=9, high=10)", () => { @@ -82,7 +82,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(0.019275414920485248, ~digits=1) // (uniformMean +. betaMean) + | Some(x) => x->expect->toBeSoCloseTo(9.786753454457116, ~digits=1) // (uniformMean +. betaMean) } }) }) @@ -162,8 +162,8 @@ describe("(Algebraic) addition of distributions", () => { switch received { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. - // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(0.001978994877226945, ~digits=3) + // This value was calculated by a python script + | Some(x) => x->expect->toBeSoCloseTo(0.979023, ~digits=0) } }) test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).pdf(10)", () => { @@ -176,9 +176,8 @@ describe("(Algebraic) addition of distributions", () => { ->E.R.toExn("Expected float", _) switch received { | None => "algebraicAdd has"->expect->toBe("failed") - // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. - // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(0.001978994877226945, ~digits=3) + // This is nondeterministic. + | Some(x) => x->expect->toBeSoCloseTo(0.979023, ~digits=0) } }) }) @@ -253,8 +252,8 @@ describe("(Algebraic) addition of distributions", () => { switch received { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. - // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(0.0013961779932477507, ~digits=3) + // The value was calculated externally using a python script + | Some(x) => x->expect->toBeSoCloseTo(0.71148, ~digits=1) } }) test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).cdf(10)", () => { @@ -268,8 +267,8 @@ describe("(Algebraic) addition of distributions", () => { switch received { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. - // sometimes it works with ~digits=4. - | Some(x) => x->expect->toBeSoCloseTo(0.001388898111625753, ~digits=3) + // The value was calculated externally using a python script + | Some(x) => x->expect->toBeSoCloseTo(0.71148, ~digits=1) } }) }) @@ -346,7 +345,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(10.927078217530806, ~digits=0) + | Some(x) => x->expect->toBeSoCloseTo(9.179319623146968, ~digits=0) } }) test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).inv(2e-2)", () => { @@ -361,7 +360,7 @@ describe("(Algebraic) addition of distributions", () => { | None => "algebraicAdd has"->expect->toBe("failed") // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. // sometimes it works with ~digits=2. - | Some(x) => x->expect->toBeSoCloseTo(10.915396627014363, ~digits=0) + | Some(x) => x->expect->toBeSoCloseTo(9.174267267465632, ~digits=0) } }) }) diff --git a/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_ToPointSet_test.res b/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_ToPointSet_test.res new file mode 100644 index 00000000..2145220b --- /dev/null +++ b/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_ToPointSet_test.res @@ -0,0 +1,22 @@ +open Jest +open Expect + +describe("Converting from a sample set distribution", () => { + test("Should be normalized", () => { + let outputXYShape = SampleSetDist_ToPointSet.Internals.KDE.normalSampling( + [1., 2., 3., 3., 4., 5., 5., 5., 6., 8., 9., 9.], + 50, + 2, + ) + let c: PointSetTypes.continuousShape = { + xyShape: outputXYShape, + interpolation: #Linear, + integralSumCache: None, + integralCache: None, + } + let fullShape = Continuous.updateIntegralCache(Some(Continuous.T.integral(c)), c) + let endY = Continuous.T.integralEndY(fullShape) + + expect(endY)->toBeCloseTo(1.) + }) +}) diff --git a/packages/squiggle-lang/__tests__/TS/JS_test.ts b/packages/squiggle-lang/__tests__/TS/JS_test.ts index 8e6db265..a2fa99d9 100644 --- a/packages/squiggle-lang/__tests__/TS/JS_test.ts +++ b/packages/squiggle-lang/__tests__/TS/JS_test.ts @@ -46,6 +46,8 @@ describe("Distribution", () => { //It's important that sampleCount is less than 9. If it's more, than that will create randomness //Also, note, the value should be created using makeSampleSetDist() later on. let env = { sampleCount: 8, xyPointLength: 100 }; + let dist1Samples = [3, 4, 5, 6, 6, 7, 10, 15, 30]; + let dist1SampleCount = dist1Samples.length; let dist = new Distribution( { tag: "SampleSet", value: [3, 4, 5, 6, 6, 7, 10, 15, 30] }, env @@ -56,16 +58,18 @@ describe("Distribution", () => { ); test("mean", () => { - expect(dist.mean().value).toBeCloseTo(3.737); + expect(dist.mean().value).toBeCloseTo(8.704375514292865); }); test("pdf", () => { - expect(dist.pdf(5.0).value).toBeCloseTo(0.0431); + expect(dist.pdf(5.0).value).toBeCloseTo(0.052007455285386944, 1); }); test("cdf", () => { - expect(dist.cdf(5.0).value).toBeCloseTo(0.155); + expect(dist.cdf(5.0).value).toBeCloseTo( + dist1Samples.filter((x) => x <= 5).length / dist1SampleCount + ); }); test("inv", () => { - expect(dist.inv(0.5).value).toBeCloseTo(9.458); + expect(dist.inv(0.5).value).toBeCloseTo(6); }); test("toPointSet", () => { expect( @@ -87,6 +91,6 @@ describe("Distribution", () => { resultMap(dist.pointwiseAdd(dist2), (r: Distribution) => r.toSparkline(20) ).value - ).toEqual(Ok("▁▂▅██▅▅▅▆▇█▆▅▃▃▂▂▁▁▁")); + ).toEqual(Ok("▁▂▅██▅▅▅▆▆▇▅▄▃▃▂▂▁▁▁")); }); }); diff --git a/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts b/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts index c4599f7c..36a0a47b 100644 --- a/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts +++ b/packages/squiggle-lang/__tests__/TS/SampleSet_test.ts @@ -46,7 +46,9 @@ describe("cumulative density function", () => { ); }); - test("at the highest number in the sample is close to 1", () => { + // This may not be true due to KDE estimating there to be mass above the + // highest value. These tests fail + test.skip("at the highest number in the sample is close to 1", () => { fc.assert( fc.property(arrayGen(), (xs_) => { let xs = Array.from(xs_); diff --git a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/KdeLibrary.js b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/KdeLibrary.js index 460846e8..9cc75b39 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/KdeLibrary.js +++ b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/KdeLibrary.js @@ -15,8 +15,18 @@ const samplesToContinuousPdf = ( if (_.isFinite(max)) { _samples = _.filter(_samples, (r) => r < max); } + + // The pdf that's created from this function is not a pdf but a pmf. y values + // being probability mass and not density. + // This is awkward, because our code assumes later that y is a density let pdf = pdfast.create(_samples, { size, width }); - return { xs: pdf.map((r) => r.x), ys: pdf.map((r) => r.y) }; + + // To convert this to a density, we need to find the step size. This is kept + // constant for all y values + let stepSize = pdf[1].x - pdf[0].x; + + // We then adjust the y values to density + return { xs: pdf.map((r) => r.x), ys: pdf.map((r) => r.y / stepSize) }; }; module.exports = { From 350e42088437902e0702cd6564df3e8edccf8cd5 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 13:25:45 -0400 Subject: [PATCH 31/62] Add isNormalized to Continuous --- .../Distributions/SampleSetDist_ToPointSet_test.res | 4 +--- .../src/rescript/Distributions/PointSetDist/Continuous.res | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_ToPointSet_test.res b/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_ToPointSet_test.res index 2145220b..a2c7baa1 100644 --- a/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_ToPointSet_test.res +++ b/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_ToPointSet_test.res @@ -14,9 +14,7 @@ describe("Converting from a sample set distribution", () => { integralSumCache: None, integralCache: None, } - let fullShape = Continuous.updateIntegralCache(Some(Continuous.T.integral(c)), c) - let endY = Continuous.T.integralEndY(fullShape) - expect(endY)->toBeCloseTo(1.) + expect(Continuous.isNormalized(c))->toBe(true) }) }) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res index 5e44f900..905ffdb1 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res @@ -269,6 +269,11 @@ module T = Dist({ XYShape.Analysis.getVarianceDangerously(t, mean, Analysis.getMeanOfSquares) }) +let isNormalized = (t: t): bool => { + let areaUnderIntegral = t |> updateIntegralCache(Some(T.integral(t))) |> T.integralEndY + areaUnderIntegral -. 1. < 1e-7 +} + let downsampleEquallyOverX = (length, t): t => t |> shapeMap(XYShape.XsConversion.proportionEquallyOverX(length)) From 7302a3ec10e60ba156eb971c63a551518d33329e Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 13:28:08 -0400 Subject: [PATCH 32/62] Give isNormalised lower bound --- .../src/rescript/Distributions/PointSetDist/Continuous.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res index 905ffdb1..d4286387 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res @@ -271,7 +271,7 @@ module T = Dist({ let isNormalized = (t: t): bool => { let areaUnderIntegral = t |> updateIntegralCache(Some(T.integral(t))) |> T.integralEndY - areaUnderIntegral -. 1. < 1e-7 + areaUnderIntegral < 1. +. 1e-7 && areaUnderIntegral > 1. -. 1e-7 } let downsampleEquallyOverX = (length, t): t => From ba412f2df6de4c6a56d176ea80d3d4f7fe8966cb Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 14:15:37 -0400 Subject: [PATCH 33/62] Fix resolution issue --- .../Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res index d1219f79..b7df0ff3 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res @@ -90,7 +90,7 @@ let dispatchMacroCall = ( Js.Dict.set(acc, key, value) acc }) - externalBindings->EvRecord->ExpressionT.EValue->Ok + externalBindings->ExpressionValue.EvRecord->ExpressionT.EValue->Ok } let doBindExpression = (expression: expression, bindings: ExpressionT.bindings) => From 60f3445277b59d72a5a96a47c66ea20aa676b814 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 14:26:02 -0400 Subject: [PATCH 34/62] Initial loss testing proof of concept --- .../benchmark/conversion_tests.ts | 9 ++ .../squiggle-lang/benchmark/generators.ts | 12 +++ packages/squiggle-lang/benchmark/lib.ts | 31 +++++++ packages/squiggle-lang/package.json | 17 ++-- packages/squiggle-lang/tsconfig.json | 1 + yarn.lock | 91 ++++++++++++++++++- 6 files changed, 150 insertions(+), 11 deletions(-) create mode 100644 packages/squiggle-lang/benchmark/conversion_tests.ts create mode 100644 packages/squiggle-lang/benchmark/generators.ts create mode 100644 packages/squiggle-lang/benchmark/lib.ts diff --git a/packages/squiggle-lang/benchmark/conversion_tests.ts b/packages/squiggle-lang/benchmark/conversion_tests.ts new file mode 100644 index 00000000..52804c0b --- /dev/null +++ b/packages/squiggle-lang/benchmark/conversion_tests.ts @@ -0,0 +1,9 @@ +import { generateNormal } from "./generators"; +import { test, expectEqual } from "./lib"; + +test("mean is the same under point set transform", () => { + let normal = generateNormal(); + let symbolicMean = `mean(${normal})`; + let pointSetMean = `mean(toPointSet(${normal}))`; + return expectEqual(symbolicMean, pointSetMean); +}); diff --git a/packages/squiggle-lang/benchmark/generators.ts b/packages/squiggle-lang/benchmark/generators.ts new file mode 100644 index 00000000..6d5d7854 --- /dev/null +++ b/packages/squiggle-lang/benchmark/generators.ts @@ -0,0 +1,12 @@ +let generateFloat = (): number => Math.random() * 200 - 100; + +let generatePositive = (): number => Math.random() * 100; + +export let generateNormal = (): string => + `normal(${generateFloat()}, ${generatePositive()})`; + +export let generateBeta = (): string => + `beta(${generatePositive()}, ${generatePositive()})`; + +export let generateLognormal = (): string => + `lognormal(${generateFloat()}, ${generatePositive()})`; diff --git a/packages/squiggle-lang/benchmark/lib.ts b/packages/squiggle-lang/benchmark/lib.ts new file mode 100644 index 00000000..382d2d54 --- /dev/null +++ b/packages/squiggle-lang/benchmark/lib.ts @@ -0,0 +1,31 @@ +import { run, squiggleExpression, errorValueToString } from "../src/js/index"; +import _ from "lodash"; + +let testRun = (x: string): squiggleExpression => { + let result = run(x, { sampleCount: 100, xyPointLength: 100 }); + if (result.tag === "Ok") { + return result.value; + } else { + throw Error( + "Expected squiggle expression to evaluate but got error: " + + errorValueToString(result.value) + ); + } +}; + +export function test(name: string, fn: () => void) { + console.log(name); + fn(); +} + +export function expectEqual(expression1: string, expression2: string) { + let result1 = testRun(expression1); + let result2 = testRun(expression2); + if (result1.tag === "number" && result2.tag === "number") { + let loss = getLoss(result1.value, result2.value); + console.log(`${result1.value} === ${result2.value}\nLoss: ${loss}`); + } +} + +let getLoss = (actual: number, expected: number): number => + Math.abs(expected - actual); diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index bf31a059..e9e77766 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -30,26 +30,27 @@ "author": "Quantified Uncertainty Research Institute", "license": "MIT", "devDependencies": { - "bisect_ppx": "^2.7.1", - "jstat": "^1.9.5", - "lodash": "4.17.21", - "mathjs": "10.5.0", - "pdfast": "^0.2.0", - "rationale": "0.2.0", - "rescript": "^9.1.4", "@glennsl/rescript-jest": "^0.9.0", "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/jest": "^27.4.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", + "bisect_ppx": "^2.7.1", "codecov": "3.8.3", "fast-check": "2.25.0", "gentype": "^4.3.0", "jest": "^27.5.1", + "jstat": "^1.9.5", + "lodash": "4.17.21", + "mathjs": "10.5.0", "moduleserve": "0.9.1", - "reanalyze": "^2.19.0", "nyc": "^15.1.0", + "pdfast": "^0.2.0", + "rationale": "0.2.0", + "reanalyze": "^2.19.0", + "rescript": "^9.1.4", "ts-jest": "^27.1.4", "ts-loader": "^9.2.8", + "ts-node": "^10.7.0", "typescript": "^4.6.3", "webpack": "^5.72.0", "webpack-cli": "^4.9.2" diff --git a/packages/squiggle-lang/tsconfig.json b/packages/squiggle-lang/tsconfig.json index 7a610d10..f1f9a00d 100644 --- a/packages/squiggle-lang/tsconfig.json +++ b/packages/squiggle-lang/tsconfig.json @@ -4,6 +4,7 @@ "jsx": "react", "allowJs": true, "noImplicitAny": true, + "esModuleInterop": true, "removeComments": true, "preserveConstEnums": true, "sourceMap": true, diff --git a/yarn.lock b/yarn.lock index 90b85189..b82019b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1334,6 +1334,18 @@ resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== +"@cspotcode/source-map-consumer@0.8.0": + version "0.8.0" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" + integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== + +"@cspotcode/source-map-support@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5" + integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA== + dependencies: + "@cspotcode/source-map-consumer" "0.8.0" + "@csstools/normalize.css@*": version "12.0.0" resolved "https://registry.yarnpkg.com/@csstools/normalize.css/-/normalize.css-12.0.0.tgz#a9583a75c3f150667771f30b60d9f059473e62c4" @@ -3694,6 +3706,26 @@ resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== +"@tsconfig/node10@^1.0.7": + version "1.0.8" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9" + integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg== + +"@tsconfig/node12@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c" + integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw== + +"@tsconfig/node14@^1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" + integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== + +"@tsconfig/node16@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" + integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== + "@types/aria-query@^4.2.0": version "4.2.2" resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.2.tgz#ed4e0ad92306a704f9fb132a0cfcf77486dbe2bc" @@ -4088,7 +4120,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": +"@types/react@*", "@types/react@^18.0.3": version "18.0.7" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.7.tgz#8437a226763adf854969954dfe582529a406cbad" integrity sha512-CXSXHzTexlX9esf4ReIUJeaemKcmBEvYzxHDUk19c3BCcEGUvUjkeC3jkscPSfSaQ6SPDRNd/zMxi8oc/P1zxA== @@ -4097,6 +4129,15 @@ "@types/scheduler" "*" csstype "^3.0.2" +"@types/react@^16.9.19": + version "16.14.25" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.14.25.tgz#d003f712c7563fdef5a87327f1892825af375608" + integrity sha512-cXRVHd7vBT5v1is72mmvmsg9stZrbJO04DJqFeh3Yj2tVKO6vmxg5BI+ybI6Ls7ROXRG3aFbZj9x0WA3ZAoDQw== + dependencies: + "@types/prop-types" "*" + "@types/scheduler" "*" + csstype "^3.0.2" + "@types/resolve@1.17.1": version "1.17.1" resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" @@ -4682,7 +4723,7 @@ acorn-walk@^7.0.0, acorn-walk@^7.1.1, acorn-walk@^7.2.0: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== -acorn-walk@^8.0.0: +acorn-walk@^8.0.0, acorn-walk@^8.1.1: version "8.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== @@ -5000,6 +5041,11 @@ are-we-there-yet@^2.0.0: delegates "^1.0.0" readable-stream "^3.6.0" +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + arg@^5.0.0, arg@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.1.tgz#eb0c9a8f77786cad2af8ff2b862899842d7b6adb" @@ -6788,6 +6834,11 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + cross-env@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" @@ -7529,6 +7580,11 @@ diff-sequences@^27.5.1: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327" integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ== +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + diffie-hellman@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" @@ -11517,7 +11573,7 @@ make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0: dependencies: semver "^6.0.0" -make-error@1.x: +make-error@1.x, make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== @@ -16602,6 +16658,25 @@ ts-loader@^9.2.8: micromatch "^4.0.0" semver "^7.3.4" +ts-node@^10.7.0: + version "10.7.0" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.7.0.tgz#35d503d0fab3e2baa672a0e94f4b40653c2463f5" + integrity sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A== + dependencies: + "@cspotcode/source-map-support" "0.7.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.0" + yn "3.1.1" + ts-pnp@^1.1.6: version "1.2.0" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" @@ -17099,6 +17174,11 @@ uuid@^8.0.0, uuid@^8.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== +v8-compile-cache-lib@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + v8-compile-cache@^2.0.3: version "2.3.0" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" @@ -18337,6 +18417,11 @@ yargs@~17.2.1: y18n "^5.0.5" yargs-parser "^20.2.2" +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" From 592bdbb9e92fd669890383d086a27a003b3d665f Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 14:30:03 -0400 Subject: [PATCH 35/62] Improve messages in benchmarking --- packages/squiggle-lang/benchmark/lib.ts | 5 ++++- packages/squiggle-lang/package.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/squiggle-lang/benchmark/lib.ts b/packages/squiggle-lang/benchmark/lib.ts index 382d2d54..7049d62c 100644 --- a/packages/squiggle-lang/benchmark/lib.ts +++ b/packages/squiggle-lang/benchmark/lib.ts @@ -23,7 +23,10 @@ export function expectEqual(expression1: string, expression2: string) { let result2 = testRun(expression2); if (result1.tag === "number" && result2.tag === "number") { let loss = getLoss(result1.value, result2.value); - console.log(`${result1.value} === ${result2.value}\nLoss: ${loss}`); + console.log(`${expression1} === ${expression2}`); + console.log(`${result1.value} === ${result2.value}`); + console.log(`loss = ${loss}`); + console.log(`logloss = ${Math.log(loss)}`); } } diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index e9e77766..7542e8ff 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -8,6 +8,7 @@ "start": "rescript build -w -with-deps", "clean": "rescript clean", "test:reducer": "jest __tests__/Reducer*/", + "benchmark": "ts-node benchmark/conversion_tests.ts", "test": "jest", "test:ts": "jest __tests__/TS/", "test:rescript": "jest --modulePathIgnorePatterns=__tests__/TS/*", From 752f2a1ea575641fefe5bb77a13ff463b0c45425 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 16:05:16 -0400 Subject: [PATCH 36/62] Add other distributions and operations into benchmarking --- .../benchmark/conversion_tests.ts | 32 +++++++++++++---- .../squiggle-lang/benchmark/generators.ts | 34 ++++++++++++++++++- packages/squiggle-lang/benchmark/lib.ts | 6 +++- .../src/rescript/TypescriptInterface.res | 3 ++ 4 files changed, 67 insertions(+), 8 deletions(-) diff --git a/packages/squiggle-lang/benchmark/conversion_tests.ts b/packages/squiggle-lang/benchmark/conversion_tests.ts index 52804c0b..c2f9dcd7 100644 --- a/packages/squiggle-lang/benchmark/conversion_tests.ts +++ b/packages/squiggle-lang/benchmark/conversion_tests.ts @@ -1,9 +1,29 @@ -import { generateNormal } from "./generators"; +import { distributions, generateFloat, generateFloatRange } from "./generators"; import { test, expectEqual } from "./lib"; -test("mean is the same under point set transform", () => { - let normal = generateNormal(); - let symbolicMean = `mean(${normal})`; - let pointSetMean = `mean(toPointSet(${normal}))`; - return expectEqual(symbolicMean, pointSetMean); +let checkDistributionSame = (distribution: string, operation: (arg: string) => string): void => { + expectEqual(operation(distribution), operation(`toPointSet(${distribution})`)); + expectEqual(operation(distribution), operation(`toSampleSet(${distribution})`)); +} + +Object.entries(distributions).map(([key, generator]) => { + let distribution = generator(); + test(`mean is the same for ${key} distribution under all distribution types`, () => + checkDistributionSame(distribution, (d: string) => `mean(${d})`) + ) + + test(`cdf is the same for ${key} distribution under all distribution types`, () => { + let cdf_value = generateFloat(); + checkDistributionSame(distribution, (d: string) => `cdf(${d}, ${cdf_value})`) + }) + + test(`pdf is the same for ${key} distribution under all distribution types`, () => { + let pdf_value = generateFloat(); + checkDistributionSame(distribution, (d: string) => `pdf(${d}, ${pdf_value})`) + }) + + test(`inv is the same for ${key} distribution under all distribution types`, () => { + let inv_value = generateFloatRange(0, 1); + checkDistributionSame(distribution, (d: string) => `inv(${d}, ${inv_value})`) + }) }); diff --git a/packages/squiggle-lang/benchmark/generators.ts b/packages/squiggle-lang/benchmark/generators.ts index 6d5d7854..9e134a0b 100644 --- a/packages/squiggle-lang/benchmark/generators.ts +++ b/packages/squiggle-lang/benchmark/generators.ts @@ -1,4 +1,6 @@ -let generateFloat = (): number => Math.random() * 200 - 100; +export let generateFloat = (): number => Math.random() * 200 - 100; +export let generateFloatMin = (min:number): number => Math.random() * (100 - min) + min; +export let generateFloatRange = (min:number, max: number): number => Math.random() * (max - min) + min; let generatePositive = (): number => Math.random() * 100; @@ -10,3 +12,33 @@ export let generateBeta = (): string => export let generateLognormal = (): string => `lognormal(${generateFloat()}, ${generatePositive()})`; + +export let generateExponential = (): string => + `exponential(${generatePositive()})`; + +export let generateUniform = (): string => { + let a = generateFloat() + let b = generateFloatMin(a) + return `uniform(${a}, ${b})` +} +export let generateCauchy = (): string => { + return `cauchy(${generateFloat()}, ${generatePositive()})` +} + +export let generateTriangular = (): string => { + let a = generateFloat() + let b = generateFloatMin(a) + let c = generateFloatMin(b) + return `triangular(${a}, ${b}, ${c})` +} + +export let distributions : {[key: string]: () => string} = { + normal: generateNormal, + beta: generateBeta, + lognormal: generateLognormal, + exponential: generateExponential, + triangular: generateTriangular , + cauchy: generateCauchy, + uniform: generateUniform +} + diff --git a/packages/squiggle-lang/benchmark/lib.ts b/packages/squiggle-lang/benchmark/lib.ts index 7049d62c..ab63c317 100644 --- a/packages/squiggle-lang/benchmark/lib.ts +++ b/packages/squiggle-lang/benchmark/lib.ts @@ -26,7 +26,11 @@ export function expectEqual(expression1: string, expression2: string) { console.log(`${expression1} === ${expression2}`); console.log(`${result1.value} === ${result2.value}`); console.log(`loss = ${loss}`); - console.log(`logloss = ${Math.log(loss)}`); + console.log(`logloss = ${Math.abs(Math.log(result1.value) - Math.log(result2.value))}`); + console.log() + } + else { + throw Error(`Expected both to be number, but got ${result1.tag} and ${result2.tag}`) } } diff --git a/packages/squiggle-lang/src/rescript/TypescriptInterface.res b/packages/squiggle-lang/src/rescript/TypescriptInterface.res index 8704bf5e..fc381729 100644 --- a/packages/squiggle-lang/src/rescript/TypescriptInterface.res +++ b/packages/squiggle-lang/src/rescript/TypescriptInterface.res @@ -31,6 +31,9 @@ let makeSampleSetDist = SampleSetDist.make @genType let evaluate = Reducer.evaluate +@genType +let evaluateUsingExternalBindings = Reducer.evaluateUsingExternalBindings + @genType type expressionValue = ReducerInterface_ExpressionValue.expressionValue From c53e56e7738ac8750c39693779d1a1a7b6952ea9 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 16:06:51 -0400 Subject: [PATCH 37/62] The proper issue326 (again) Value: [1 to 3.6] --- .../DistributionOperation.res | 12 +++- .../Distributions/DistributionTypes.res | 22 +++--- .../Distributions/GenericDist/GenericDist.res | 68 ++++++++++++------- .../GenericDist/GenericDist.resi | 3 +- .../ReducerInterface_GenericDistribution.res | 10 +-- 5 files changed, 71 insertions(+), 44 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res index 9cb514fe..18ee2d6a 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res @@ -154,10 +154,16 @@ let rec run = (~env, functionCallInfo: functionCallInfo): outputType => { ->GenericDist.toPointSet(~xyPointLength, ~sampleCount, ()) ->E.R2.fmap(r => Dist(PointSet(r))) ->OutputLocal.fromResult - | ToDistCombination(Algebraic, _, #Float(_)) => GenDistError(NotYetImplemented) - | ToDistCombination(Algebraic, arithmeticOperation, #Dist(t2)) => + | ToDistCombination(Algebraic(_), _, #Float(_)) => GenDistError(NotYetImplemented) + | ToDistCombination(Algebraic(strategy), arithmeticOperation, #Dist(t2)) => dist - ->GenericDist.algebraicCombination(~toPointSetFn, ~toSampleSetFn, ~arithmeticOperation, ~t2) + ->GenericDist.algebraicCombination( + ~strategy, + ~toPointSetFn, + ~toSampleSetFn, + ~arithmeticOperation, + ~t2, + ) ->E.R2.fmap(r => Dist(r)) ->OutputLocal.fromResult | ToDistCombination(Pointwise, algebraicCombination, #Dist(t2)) => diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res index 1e7164e1..e94f8421 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res @@ -4,6 +4,8 @@ type genericDist = | SampleSet(SampleSetDist.t) | Symbolic(SymbolicDistTypes.symbolicDist) +type asAlgebraicCombinationStrategy = AsDefault | AsSymbolic | AsMontecarlo | AsConvolution + @genType type error = | NotYetImplemented @@ -14,7 +16,7 @@ type error = | OperationError(Operation.Error.t) | PointSetConversionError(SampleSetDist.pointsetConversionError) | SparklineError(PointSetTypes.sparklineError) // This type of error is for when we find a sparkline of a discrete distribution. This should probably at some point be actually implemented - | RequestedModeInvalidError + | RequestedStrategyInvalidError | LogarithmOfDistributionError(string) | OtherError(string) @@ -36,7 +38,7 @@ module Error = { | OperationError(err) => Operation.Error.toString(err) | PointSetConversionError(err) => SampleSetDist.pointsetConversionErrorToString(err) | SparklineError(err) => PointSetTypes.sparklineErrorToString(err) - | RequestedModeInvalidError => `Requested mode invalid` + | RequestedStrategyInvalidError => `Requested mode invalid` | OtherError(s) => s } @@ -55,7 +57,7 @@ module DistributionOperation = { type pointsetXSelection = [#Linear | #ByWeight] type direction = - | Algebraic + | Algebraic(asAlgebraicCombinationStrategy) | Pointwise type toFloat = [ @@ -112,7 +114,7 @@ module DistributionOperation = { | ToString(ToString) => `toString` | ToString(ToSparkline(n)) => `toSparkline(${E.I.toString(n)})` | ToBool(IsNormalized) => `isNormalized` - | ToDistCombination(Algebraic, _, _) => `algebraic` + | ToDistCombination(Algebraic(_), _, _) => `algebraic` | ToDistCombination(Pointwise, _, _) => `pointwise` } @@ -141,27 +143,27 @@ module Constructors = { let toString = (dist): t => FromDist(ToString(ToString), dist) let toSparkline = (dist, n): t => FromDist(ToString(ToSparkline(n)), dist) let algebraicAdd = (dist1, dist2: genericDist): t => FromDist( - ToDistCombination(Algebraic, #Add, #Dist(dist2)), + ToDistCombination(Algebraic(AsDefault), #Add, #Dist(dist2)), dist1, ) let algebraicMultiply = (dist1, dist2): t => FromDist( - ToDistCombination(Algebraic, #Multiply, #Dist(dist2)), + ToDistCombination(Algebraic(AsDefault), #Multiply, #Dist(dist2)), dist1, ) let algebraicDivide = (dist1, dist2): t => FromDist( - ToDistCombination(Algebraic, #Divide, #Dist(dist2)), + ToDistCombination(Algebraic(AsDefault), #Divide, #Dist(dist2)), dist1, ) let algebraicSubtract = (dist1, dist2): t => FromDist( - ToDistCombination(Algebraic, #Subtract, #Dist(dist2)), + ToDistCombination(Algebraic(AsDefault), #Subtract, #Dist(dist2)), dist1, ) let algebraicLogarithm = (dist1, dist2): t => FromDist( - ToDistCombination(Algebraic, #Logarithm, #Dist(dist2)), + ToDistCombination(Algebraic(AsDefault), #Logarithm, #Dist(dist2)), dist1, ) let algebraicPower = (dist1, dist2): t => FromDist( - ToDistCombination(Algebraic, #Power, #Dist(dist2)), + ToDistCombination(Algebraic(AsDefault), #Power, #Dist(dist2)), dist1, ) let pointwiseAdd = (dist1, dist2): t => FromDist( diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index 6b730b21..0137e2c0 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -5,7 +5,6 @@ type toPointSetFn = t => result type toSampleSetFn = t => result type scaleMultiplyFn = (t, float) => result type pointwiseAddFn = (t, t) => result -type asMode = AsSymbolic | AsMontecarlo | AsConvolution let sampleN = (t: t, n) => switch t { @@ -243,7 +242,7 @@ module AlgebraicCombination = { type calculationMethod = MonteCarlo | Convolution(Operation.convolutionOperation) - let chooseConvolutionOrMonteCarlo = ( + let chooseConvolutionOrMonteCarloDefault = ( op: Operation.algebraicOperation, t2: t, t1: t, @@ -259,7 +258,26 @@ module AlgebraicCombination = { : Convolution(convOp) } - let run' = ( + let chooseConvolutionOrMonteCarlo = ( + ~strat: DistributionTypes.asAlgebraicCombinationStrategy, + op: Operation.algebraicOperation, + t2: t, + t1: t, + ): result => { + switch strat { + | AsDefault => Ok(chooseConvolutionOrMonteCarloDefault(op, t2, t1)) + | AsConvolution => + switch op { + | #Divide | #Power | #Logarithm => Error(RequestedStrategyInvalidError) + | (#Add | #Subtract | #Multiply) as convOp => Ok(Convolution(convOp)) + } + | AsMontecarlo => Ok(MonteCarlo) + | AsSymbolic => Error(RequestedStrategyInvalidError) + } + } + + let run = ( + ~strategy: DistributionTypes.asAlgebraicCombinationStrategy, t1: t, ~toPointSetFn: toPointSetFn, ~toSampleSetFn: toSampleSetFn, @@ -273,35 +291,37 @@ module AlgebraicCombination = { switch getInvalidOperationError(t1, t2, ~toPointSetFn, ~arithmeticOperation) { | Some(e) => Error(e) | None => - switch chooseConvolutionOrMonteCarlo(arithmeticOperation, t1, t2) { - | MonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) - | Convolution(convOp) => + switch chooseConvolutionOrMonteCarlo(~strat=strategy, arithmeticOperation, t1, t2) { + | Ok(MonteCarlo) => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) + | Ok(Convolution(convOp)) => runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet( r, )) + | Error(RequestedStrategyInvalidError) => Error(RequestedStrategyInvalidError) + | Error(err) => Error(err) } } } } - let run = ( - ~mode: option=?, - t1: t, - ~toPointSetFn: toPointSetFn, - ~toSampleSetFn: toSampleSetFn, - ~arithmeticOperation, - ~t2: t, - ): result => { - let algebraicResult = run'(t1, ~toPointSetFn, ~toSampleSetFn, ~arithmeticOperation, ~t2) - switch (mode, algebraicResult) { - | (None, _) - | (Some(AsSymbolic), Ok(Symbolic(_))) - | (Some(AsMontecarlo), Ok(DistributionTypes.SampleSet(_))) - | (Some(AsConvolution), Ok(DistributionTypes.PointSet(_))) - | (Some(_), Error(_)) => algebraicResult - | (Some(_), Ok(_)) => Error(RequestedModeInvalidError) - } - } + // let run = ( + // ~mode: option=?, + // t1: t, + // ~toPointSetFn: toPointSetFn, + // ~toSampleSetFn: toSampleSetFn, + // ~arithmeticOperation, + // ~t2: t, + // ): result => { + // let algebraicResult = run'(t1, ~toPointSetFn, ~toSampleSetFn, ~arithmeticOperation, ~t2) + // switch (mode, algebraicResult) { + // | (None, _) + // | (Some(AsSymbolic), Ok(Symbolic(_))) + // | (Some(AsMontecarlo), Ok(DistributionTypes.SampleSet(_))) + // | (Some(AsConvolution), Ok(DistributionTypes.PointSet(_))) + // | (Some(_), Error(_)) => algebraicResult + // | (Some(_), Ok(_)) => Error(RequestedModeInvalidError) + // } + // } } let algebraicCombination = AlgebraicCombination.run diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi index ccb9a5c6..ed2c5c03 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi @@ -4,7 +4,6 @@ type toPointSetFn = t => result type toSampleSetFn = t => result type scaleMultiplyFn = (t, float) => result type pointwiseAddFn = (t, t) => result -type asMode = AsSymbolic | AsMontecarlo | AsConvolution let sampleN: (t, int) => array @@ -43,7 +42,7 @@ let truncate: ( ) => result let algebraicCombination: ( - ~mode: asMode=?, + ~strategy: DistributionTypes.asAlgebraicCombinationStrategy, t, ~toPointSetFn: toPointSetFn, ~toSampleSetFn: toSampleSetFn, diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index f39dc932..53f680ab 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -208,7 +208,7 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< Helpers.toStringFn(ToSparkline(Belt.Float.toInt(n)), dist) | ("exp", [EvDistribution(a)]) => // https://mathjs.org/docs/reference/functions/exp.html - Helpers.twoDiststoDistFn(Algebraic, "pow", GenericDist.fromFloat(Math.e), a)->Some + Helpers.twoDiststoDistFn(Algebraic(AsDefault), "pow", GenericDist.fromFloat(Math.e), a)->Some | ("normalize", [EvDistribution(dist)]) => Helpers.toDistFn(Normalize, dist) | ("isNormalized", [EvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist) | ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist) @@ -228,14 +228,14 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< Helpers.toDistFn(Truncate(Some(float1), Some(float2)), dist) | ("mx" | "mixture", args) => Helpers.mixture(args)->Some | ("log", [EvDistribution(a)]) => - Helpers.twoDiststoDistFn(Algebraic, "log", a, GenericDist.fromFloat(Math.e))->Some + Helpers.twoDiststoDistFn(Algebraic(AsDefault), "log", a, GenericDist.fromFloat(Math.e))->Some | ("log10", [EvDistribution(a)]) => - Helpers.twoDiststoDistFn(Algebraic, "log", a, GenericDist.fromFloat(10.0))->Some + Helpers.twoDiststoDistFn(Algebraic(AsDefault), "log", a, GenericDist.fromFloat(10.0))->Some | ("unaryMinus", [EvDistribution(a)]) => - Helpers.twoDiststoDistFn(Algebraic, "multiply", a, GenericDist.fromFloat(-1.0))->Some + Helpers.twoDiststoDistFn(Algebraic(AsDefault), "multiply", a, GenericDist.fromFloat(-1.0))->Some | (("add" | "multiply" | "subtract" | "divide" | "pow" | "log") as arithmetic, [_, _] as args) => Helpers.catchAndConvertTwoArgsToDists(args)->E.O2.fmap(((fst, snd)) => - Helpers.twoDiststoDistFn(Algebraic, arithmetic, fst, snd) + Helpers.twoDiststoDistFn(Algebraic(AsDefault), arithmetic, fst, snd) ) | ( ("dotAdd" From 69ab296bb44244c1a0fc7f02afef6bbb95eb2642 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 16:38:17 -0400 Subject: [PATCH 38/62] Colors for loss testing --- .../benchmark/conversion_tests.ts | 41 ++++++++++----- .../squiggle-lang/benchmark/generators.ts | 51 ++++++++++--------- packages/squiggle-lang/benchmark/lib.ts | 30 ++++++----- packages/squiggle-lang/package.json | 1 + packages/squiggle-lang/tsconfig.json | 1 - yarn.lock | 17 ++----- 6 files changed, 78 insertions(+), 63 deletions(-) diff --git a/packages/squiggle-lang/benchmark/conversion_tests.ts b/packages/squiggle-lang/benchmark/conversion_tests.ts index c2f9dcd7..94a6475d 100644 --- a/packages/squiggle-lang/benchmark/conversion_tests.ts +++ b/packages/squiggle-lang/benchmark/conversion_tests.ts @@ -1,29 +1,46 @@ import { distributions, generateFloat, generateFloatRange } from "./generators"; import { test, expectEqual } from "./lib"; -let checkDistributionSame = (distribution: string, operation: (arg: string) => string): void => { - expectEqual(operation(distribution), operation(`toPointSet(${distribution})`)); - expectEqual(operation(distribution), operation(`toSampleSet(${distribution})`)); -} +let checkDistributionSame = ( + distribution: string, + operation: (arg: string) => string +): void => { + expectEqual( + operation(distribution), + operation(`toPointSet(${distribution})`) + ); + expectEqual( + operation(distribution), + operation(`toSampleSet(${distribution})`) + ); +}; Object.entries(distributions).map(([key, generator]) => { let distribution = generator(); test(`mean is the same for ${key} distribution under all distribution types`, () => - checkDistributionSame(distribution, (d: string) => `mean(${d})`) - ) + checkDistributionSame(distribution, (d: string) => `mean(${d})`)); test(`cdf is the same for ${key} distribution under all distribution types`, () => { let cdf_value = generateFloat(); - checkDistributionSame(distribution, (d: string) => `cdf(${d}, ${cdf_value})`) - }) + checkDistributionSame( + distribution, + (d: string) => `cdf(${d}, ${cdf_value})` + ); + }); test(`pdf is the same for ${key} distribution under all distribution types`, () => { let pdf_value = generateFloat(); - checkDistributionSame(distribution, (d: string) => `pdf(${d}, ${pdf_value})`) - }) + checkDistributionSame( + distribution, + (d: string) => `pdf(${d}, ${pdf_value})` + ); + }); test(`inv is the same for ${key} distribution under all distribution types`, () => { let inv_value = generateFloatRange(0, 1); - checkDistributionSame(distribution, (d: string) => `inv(${d}, ${inv_value})`) - }) + checkDistributionSame( + distribution, + (d: string) => `inv(${d}, ${inv_value})` + ); + }); }); diff --git a/packages/squiggle-lang/benchmark/generators.ts b/packages/squiggle-lang/benchmark/generators.ts index 9e134a0b..d07c359c 100644 --- a/packages/squiggle-lang/benchmark/generators.ts +++ b/packages/squiggle-lang/benchmark/generators.ts @@ -1,8 +1,12 @@ -export let generateFloat = (): number => Math.random() * 200 - 100; -export let generateFloatMin = (min:number): number => Math.random() * (100 - min) + min; -export let generateFloatRange = (min:number, max: number): number => Math.random() * (max - min) + min; +export let generateFloatRange = (min: number, max: number): number => + Math.floor(Math.random() * (max - min) + min); -let generatePositive = (): number => Math.random() * 100; +export let generateFloatMin = (min: number): number => + generateFloatRange(min, 100); + +export let generateFloat = (): number => generateFloatMin(-100); + +let generatePositive = (): number => generateFloatMin(1); export let generateNormal = (): string => `normal(${generateFloat()}, ${generatePositive()})`; @@ -17,28 +21,27 @@ export let generateExponential = (): string => `exponential(${generatePositive()})`; export let generateUniform = (): string => { - let a = generateFloat() - let b = generateFloatMin(a) - return `uniform(${a}, ${b})` -} + let a = generateFloat(); + let b = generateFloatMin(a + 1); + return `uniform(${a}, ${b})`; +}; export let generateCauchy = (): string => { - return `cauchy(${generateFloat()}, ${generatePositive()})` -} + return `cauchy(${generateFloat()}, ${generatePositive()})`; +}; export let generateTriangular = (): string => { - let a = generateFloat() - let b = generateFloatMin(a) - let c = generateFloatMin(b) - return `triangular(${a}, ${b}, ${c})` -} + let a = generateFloat(); + let b = generateFloatMin(a + 1); + let c = generateFloatMin(b + 1); + return `triangular(${a}, ${b}, ${c})`; +}; -export let distributions : {[key: string]: () => string} = { - normal: generateNormal, - beta: generateBeta, - lognormal: generateLognormal, - exponential: generateExponential, - triangular: generateTriangular , +export let distributions: { [key: string]: () => string } = { + normal: generateNormal, + beta: generateBeta, + lognormal: generateLognormal, + exponential: generateExponential, + triangular: generateTriangular, cauchy: generateCauchy, - uniform: generateUniform -} - + uniform: generateUniform, +}; diff --git a/packages/squiggle-lang/benchmark/lib.ts b/packages/squiggle-lang/benchmark/lib.ts index ab63c317..72dd1f66 100644 --- a/packages/squiggle-lang/benchmark/lib.ts +++ b/packages/squiggle-lang/benchmark/lib.ts @@ -1,5 +1,5 @@ import { run, squiggleExpression, errorValueToString } from "../src/js/index"; -import _ from "lodash"; +import * as chalk from "chalk"; let testRun = (x: string): squiggleExpression => { let result = run(x, { sampleCount: 100, xyPointLength: 100 }); @@ -22,17 +22,21 @@ export function expectEqual(expression1: string, expression2: string) { let result1 = testRun(expression1); let result2 = testRun(expression2); if (result1.tag === "number" && result2.tag === "number") { - let loss = getLoss(result1.value, result2.value); - console.log(`${expression1} === ${expression2}`); - console.log(`${result1.value} === ${result2.value}`); - console.log(`loss = ${loss}`); - console.log(`logloss = ${Math.abs(Math.log(result1.value) - Math.log(result2.value))}`); - console.log() - } - else { - throw Error(`Expected both to be number, but got ${result1.tag} and ${result2.tag}`) + let logloss = Math.log(Math.abs(result1.value - result2.value)); + let isBadLogless = logloss > 1; + console.log(chalk.blue(`${expression1} = ${expression2}`)); + console.log(`${result1.value} = ${result2.value}`); + console.log( + `logloss = ${ + isBadLogless + ? chalk.red(logloss.toFixed(2)) + : chalk.green(logloss.toFixed(2)) + }` + ); + console.log(); + } else { + throw Error( + `Expected both to be number, but got ${result1.tag} and ${result2.tag}` + ); } } - -let getLoss = (actual: number, expected: number): number => - Math.abs(expected - actual); diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 7542e8ff..df586436 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -36,6 +36,7 @@ "@types/jest": "^27.4.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", "bisect_ppx": "^2.7.1", + "chalk": "^4.1.2", "codecov": "3.8.3", "fast-check": "2.25.0", "gentype": "^4.3.0", diff --git a/packages/squiggle-lang/tsconfig.json b/packages/squiggle-lang/tsconfig.json index f1f9a00d..7a610d10 100644 --- a/packages/squiggle-lang/tsconfig.json +++ b/packages/squiggle-lang/tsconfig.json @@ -4,7 +4,6 @@ "jsx": "react", "allowJs": true, "noImplicitAny": true, - "esModuleInterop": true, "removeComments": true, "preserveConstEnums": true, "sourceMap": true, diff --git a/yarn.lock b/yarn.lock index b82019b8..7740c473 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4120,19 +4120,10 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^18.0.3": - version "18.0.7" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.7.tgz#8437a226763adf854969954dfe582529a406cbad" - integrity sha512-CXSXHzTexlX9esf4ReIUJeaemKcmBEvYzxHDUk19c3BCcEGUvUjkeC3jkscPSfSaQ6SPDRNd/zMxi8oc/P1zxA== - dependencies: - "@types/prop-types" "*" - "@types/scheduler" "*" - csstype "^3.0.2" - -"@types/react@^16.9.19": - version "16.14.25" - resolved "https://registry.yarnpkg.com/@types/react/-/react-16.14.25.tgz#d003f712c7563fdef5a87327f1892825af375608" - integrity sha512-cXRVHd7vBT5v1is72mmvmsg9stZrbJO04DJqFeh3Yj2tVKO6vmxg5BI+ybI6Ls7ROXRG3aFbZj9x0WA3ZAoDQw== +"@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": + version "18.0.8" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.8.tgz#a051eb380a9fbcaa404550543c58e1cf5ce4ab87" + integrity sha512-+j2hk9BzCOrrOSJASi5XiOyBbERk9jG5O73Ya4M0env5Ixi6vUNli4qy994AINcEF+1IEHISYFfIT4zwr++LKw== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" From 6f00716722eb68c76c436a4fa2f02af7239b22c9 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 16:39:52 -0400 Subject: [PATCH 39/62] deleted comment Value: [0.001 to 0.01] --- .../Distributions/GenericDist/GenericDist.res | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index 0137e2c0..c5308ad3 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -303,25 +303,6 @@ module AlgebraicCombination = { } } } - - // let run = ( - // ~mode: option=?, - // t1: t, - // ~toPointSetFn: toPointSetFn, - // ~toSampleSetFn: toSampleSetFn, - // ~arithmeticOperation, - // ~t2: t, - // ): result => { - // let algebraicResult = run'(t1, ~toPointSetFn, ~toSampleSetFn, ~arithmeticOperation, ~t2) - // switch (mode, algebraicResult) { - // | (None, _) - // | (Some(AsSymbolic), Ok(Symbolic(_))) - // | (Some(AsMontecarlo), Ok(DistributionTypes.SampleSet(_))) - // | (Some(AsConvolution), Ok(DistributionTypes.PointSet(_))) - // | (Some(_), Error(_)) => algebraicResult - // | (Some(_), Ok(_)) => Error(RequestedModeInvalidError) - // } - // } } let algebraicCombination = AlgebraicCombination.run From 93bedc88d9a6f87232ef4b4f07c1b59a789e2cac Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 16:48:01 -0400 Subject: [PATCH 40/62] Bold test titles Value: [0.00000000001 to 0.00000001] --- packages/squiggle-lang/benchmark/lib.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/squiggle-lang/benchmark/lib.ts b/packages/squiggle-lang/benchmark/lib.ts index 72dd1f66..1133640c 100644 --- a/packages/squiggle-lang/benchmark/lib.ts +++ b/packages/squiggle-lang/benchmark/lib.ts @@ -14,7 +14,7 @@ let testRun = (x: string): squiggleExpression => { }; export function test(name: string, fn: () => void) { - console.log(name); + console.log(chalk.cyan.bold(name)); fn(); } From f19f8478aa387850df6ff44c69a28e77b11ac25d Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 16:54:32 -0400 Subject: [PATCH 41/62] first pass at multi-arg lambda specification Value: [0.2 to 0.83] --- packages/website/docs/Internal/Grammar.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/website/docs/Internal/Grammar.md b/packages/website/docs/Internal/Grammar.md index 2c9a9de4..97fd546b 100644 --- a/packages/website/docs/Internal/Grammar.md +++ b/packages/website/docs/Internal/Grammar.md @@ -26,7 +26,7 @@ Think of javascript's list unpacking notation to read our variable-argument func ::= + | - | .+ | .- | ::= * | / | .* | | ::= ^ | .^ | - ::= | | | ( ) | | | . | => | () | (, ) | ... + ::= | | | ( ) | | | . | => | (, ) => | ... | () | (, ) | ... ``` ## Data structures From b9c8a7e2c711c2bc1ac109330f5b7f1802e6a2e1 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 16:58:36 -0400 Subject: [PATCH 42/62] Input validation for cauchy Value: [0.01 to 0.08] Sam gets most of the credit --- .../rescript/Distributions/SymbolicDist/SymbolicDist.res | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDist.res b/packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDist.res index 92249eae..997506d9 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDist.res @@ -86,9 +86,10 @@ module Exponential = { module Cauchy = { type t = cauchy - let make = (local, scale): result => Ok( - #Cauchy({local: local, scale: scale}), - ) + let make = (local, scale): result => + scale > 0.0 + ? Ok(#Cauchy({local: local, scale: scale})) + : Error("Cauchy distribution scale parameter must larger than 0.") let pdf = (x, t: t) => Jstat.Cauchy.pdf(x, t.local, t.scale) let cdf = (x, t: t) => Jstat.Cauchy.cdf(x, t.local, t.scale) let inv = (p, t: t) => Jstat.Cauchy.inv(p, t.local, t.scale) From e6d40362ef1d7b5c1fde0ad63aaf28dcc499a51c Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 17:59:38 -0400 Subject: [PATCH 43/62] Add MIT Licneses to projects --- packages/components/package.json | 1 + packages/squiggle-lang/package.json | 1 + packages/website/package.json | 1 + 3 files changed, 3 insertions(+) diff --git a/packages/components/package.json b/packages/components/package.json index f0bf32f2..c2e4ef79 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,7 @@ { "name": "@quri/squiggle-components", "version": "0.2.9", + "licence": "MIT", "dependencies": { "antd": "^4.20.1", "react-ace": "10.1.0", diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index bf31a059..5c808113 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -2,6 +2,7 @@ "name": "@quri/squiggle-lang", "version": "0.2.5", "homepage": "https://squiggle-language.com", + "licence": "MIT", "scripts": { "build": "rescript build -with-deps", "bundle": "webpack", diff --git a/packages/website/package.json b/packages/website/package.json index a0e5fd33..501778cf 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -2,6 +2,7 @@ "name": "squiggle-website", "version": "0.0.0", "private": true, + "license": "MIT", "scripts": { "start": "docusaurus start", "build": "docusaurus build", From 2553229d2815d3bee1623fef8c1bbeadac071d1d Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 18:41:57 -0400 Subject: [PATCH 44/62] The real 326 Value: [0.04 to 0.3] --- .../Distributions/DistributionTypes.res | 4 +- .../Distributions/GenericDist/GenericDist.res | 101 ++++++++++++------ 2 files changed, 72 insertions(+), 33 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res index e94f8421..c16ea1b2 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res @@ -4,7 +4,7 @@ type genericDist = | SampleSet(SampleSetDist.t) | Symbolic(SymbolicDistTypes.symbolicDist) -type asAlgebraicCombinationStrategy = AsDefault | AsSymbolic | AsMontecarlo | AsConvolution +type asAlgebraicCombinationStrategy = AsDefault | AsSymbolic | AsMonteCarlo | AsConvolution @genType type error = @@ -38,7 +38,7 @@ module Error = { | OperationError(err) => Operation.Error.toString(err) | PointSetConversionError(err) => SampleSetDist.pointsetConversionErrorToString(err) | SparklineError(err) => PointSetTypes.sparklineErrorToString(err) - | RequestedStrategyInvalidError => `Requested mode invalid` + | RequestedStrategyInvalidError => `Requested strategy invalid` | OtherError(s) => s } diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index c5308ad3..25169b2f 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -147,21 +147,6 @@ let truncate = Truncate.run TODO: It would be useful to be able to pass in a paramater to get this to run either with convolution or monte carlo. */ module AlgebraicCombination = { - let tryAnalyticalSimplification = ( - arithmeticOperation: Operation.algebraicOperation, - t1: t, - t2: t, - ): option> => - switch (arithmeticOperation, t1, t2) { - | (arithmeticOperation, Symbolic(d1), Symbolic(d2)) => - switch SymbolicDist.T.tryAnalyticalSimplification(d1, d2, arithmeticOperation) { - | #AnalyticalSolution(symbolicDist) => Some(Ok(symbolicDist)) - | #Error(er) => Some(Error(er)) - | #NoSolution => None - } - | _ => None - } - let runConvolution = ( toPointSet: toPointSetFn, arithmeticOperation: Operation.convolutionOperation, @@ -271,11 +256,63 @@ module AlgebraicCombination = { | #Divide | #Power | #Logarithm => Error(RequestedStrategyInvalidError) | (#Add | #Subtract | #Multiply) as convOp => Ok(Convolution(convOp)) } - | AsMontecarlo => Ok(MonteCarlo) + | AsMonteCarlo => Ok(MonteCarlo) | AsSymbolic => Error(RequestedStrategyInvalidError) } } + let tryAnalyticalSimplificationDefault = ( + arithmeticOperation: Operation.algebraicOperation, + t1: t, + t2: t, + ): option> => + switch (t1, t2) { + | (Symbolic(d1), Symbolic(d2)) => + switch SymbolicDist.T.tryAnalyticalSimplification(d1, d2, arithmeticOperation) { + | #AnalyticalSolution(symbolicDist) => Some(Ok(symbolicDist)) + | #Error(er) => Some(Error(er)) + | #NoSolution => None + } + | _ => None + } + + let tryAnalyticalSimplification = ( + arithmeticOperation: Operation.algebraicOperation, + t1: t, + t2: t, + ): option => { + switch (t1, t2) { + | (DistributionTypes.Symbolic(d1), DistributionTypes.Symbolic(d2)) => + Some(SymbolicDist.T.tryAnalyticalSimplification(d1, d2, arithmeticOperation)) + | _ => None + } + } + + let runDefault = ( + t1: t, + ~toPointSetFn: toPointSetFn, + ~toSampleSetFn: toSampleSetFn, + ~arithmeticOperation, + ~t2: t, + ): result => { + switch tryAnalyticalSimplificationDefault(arithmeticOperation, t1, t2) { + | Some(Ok(symbolicDist)) => Ok(Symbolic(symbolicDist)) + | Some(Error(e)) => Error(OperationError(e)) + | None => + switch getInvalidOperationError(t1, t2, ~toPointSetFn, ~arithmeticOperation) { + | Some(e) => Error(e) + | None => + switch chooseConvolutionOrMonteCarloDefault(arithmeticOperation, t1, t2) { + | MonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) + | Convolution(convOp) => + runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet( + r, + )) + } + } + } + } + let run = ( ~strategy: DistributionTypes.asAlgebraicCombinationStrategy, t1: t, @@ -284,22 +321,24 @@ module AlgebraicCombination = { ~arithmeticOperation, ~t2: t, ): result => { - switch tryAnalyticalSimplification(arithmeticOperation, t1, t2) { - | Some(Ok(symbolicDist)) => Ok(Symbolic(symbolicDist)) - | Some(Error(e)) => Error(OperationError(e)) - | None => - switch getInvalidOperationError(t1, t2, ~toPointSetFn, ~arithmeticOperation) { - | Some(e) => Error(e) + switch strategy { + | AsDefault => runDefault(t1, ~toPointSetFn, ~toSampleSetFn, ~arithmeticOperation, ~t2) + | AsSymbolic => + switch tryAnalyticalSimplification(arithmeticOperation, t1, t2) { + | Some(#AnalyticalSolution(symbolicDist)) => Ok(Symbolic(symbolicDist)) + | Some(#NoSolution) | None => - switch chooseConvolutionOrMonteCarlo(~strat=strategy, arithmeticOperation, t1, t2) { - | Ok(MonteCarlo) => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) - | Ok(Convolution(convOp)) => - runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet( - r, - )) - | Error(RequestedStrategyInvalidError) => Error(RequestedStrategyInvalidError) - | Error(err) => Error(err) - } + Error(RequestedStrategyInvalidError) + | Some(#Error(err)) => Error(OperationError(err)) + } + | AsConvolution + | AsMonteCarlo => + switch chooseConvolutionOrMonteCarlo(~strat=strategy, arithmeticOperation, t1, t2) { + | Ok(MonteCarlo) => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) + | Ok(Convolution(convOp)) => + runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet(r)) + | Error(RequestedStrategyInvalidError) => Error(RequestedStrategyInvalidError) + | Error(err) => Error(err) } } } From 787d4135c77ad2be5821932174606de2ac63b2c0 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 18:59:27 -0400 Subject: [PATCH 45/62] Fix inv tests always checking 0 --- .../benchmark/conversion_tests.ts | 6 ++-- .../squiggle-lang/benchmark/generators.ts | 31 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/squiggle-lang/benchmark/conversion_tests.ts b/packages/squiggle-lang/benchmark/conversion_tests.ts index 94a6475d..7cdd72cc 100644 --- a/packages/squiggle-lang/benchmark/conversion_tests.ts +++ b/packages/squiggle-lang/benchmark/conversion_tests.ts @@ -1,4 +1,4 @@ -import { distributions, generateFloat, generateFloatRange } from "./generators"; +import { distributions, generateInt, generateFloatRange } from "./generators"; import { test, expectEqual } from "./lib"; let checkDistributionSame = ( @@ -21,7 +21,7 @@ Object.entries(distributions).map(([key, generator]) => { checkDistributionSame(distribution, (d: string) => `mean(${d})`)); test(`cdf is the same for ${key} distribution under all distribution types`, () => { - let cdf_value = generateFloat(); + let cdf_value = generateInt(); checkDistributionSame( distribution, (d: string) => `cdf(${d}, ${cdf_value})` @@ -29,7 +29,7 @@ Object.entries(distributions).map(([key, generator]) => { }); test(`pdf is the same for ${key} distribution under all distribution types`, () => { - let pdf_value = generateFloat(); + let pdf_value = generateInt(); checkDistributionSame( distribution, (d: string) => `pdf(${d}, ${pdf_value})` diff --git a/packages/squiggle-lang/benchmark/generators.ts b/packages/squiggle-lang/benchmark/generators.ts index d07c359c..e3949e9b 100644 --- a/packages/squiggle-lang/benchmark/generators.ts +++ b/packages/squiggle-lang/benchmark/generators.ts @@ -1,38 +1,39 @@ export let generateFloatRange = (min: number, max: number): number => - Math.floor(Math.random() * (max - min) + min); + Math.random() * (max - min) + min; +export let generateIntRange = (min: number, max: number): number => + Math.floor(generateFloatRange(min, max)); -export let generateFloatMin = (min: number): number => - generateFloatRange(min, 100); +export let generateIntMin = (min: number): number => generateIntRange(min, 100); -export let generateFloat = (): number => generateFloatMin(-100); +export let generateInt = (): number => generateIntMin(-100); -let generatePositive = (): number => generateFloatMin(1); +let generatePositiveInt = (): number => generateIntMin(1); export let generateNormal = (): string => - `normal(${generateFloat()}, ${generatePositive()})`; + `normal(${generateInt()}, ${generatePositiveInt()})`; export let generateBeta = (): string => - `beta(${generatePositive()}, ${generatePositive()})`; + `beta(${generatePositiveInt()}, ${generatePositiveInt()})`; export let generateLognormal = (): string => - `lognormal(${generateFloat()}, ${generatePositive()})`; + `lognormal(${generateInt()}, ${generatePositiveInt()})`; export let generateExponential = (): string => - `exponential(${generatePositive()})`; + `exponential(${generatePositiveInt()})`; export let generateUniform = (): string => { - let a = generateFloat(); - let b = generateFloatMin(a + 1); + let a = generateInt(); + let b = generateIntMin(a + 1); return `uniform(${a}, ${b})`; }; export let generateCauchy = (): string => { - return `cauchy(${generateFloat()}, ${generatePositive()})`; + return `cauchy(${generateInt()}, ${generatePositiveInt()})`; }; export let generateTriangular = (): string => { - let a = generateFloat(); - let b = generateFloatMin(a + 1); - let c = generateFloatMin(b + 1); + let a = generateInt(); + let b = generateIntMin(a + 1); + let c = generateIntMin(b + 1); return `triangular(${a}, ${b}, ${c})`; }; From 938a10766c916d73c34a0776a22d63a57174c386 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 20:30:38 -0400 Subject: [PATCH 46/62] Response to CR Value: [0.005 to 0.43] --- .../Distributions/DistributionTypes.res | 4 +- .../Distributions/GenericDist/GenericDist.res | 81 ++++++------------- 2 files changed, 28 insertions(+), 57 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res index c16ea1b2..e27a138d 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res @@ -16,7 +16,7 @@ type error = | OperationError(Operation.Error.t) | PointSetConversionError(SampleSetDist.pointsetConversionError) | SparklineError(PointSetTypes.sparklineError) // This type of error is for when we find a sparkline of a discrete distribution. This should probably at some point be actually implemented - | RequestedStrategyInvalidError + | RequestedStrategyInvalidError(string) | LogarithmOfDistributionError(string) | OtherError(string) @@ -38,7 +38,7 @@ module Error = { | OperationError(err) => Operation.Error.toString(err) | PointSetConversionError(err) => SampleSetDist.pointsetConversionErrorToString(err) | SparklineError(err) => PointSetTypes.sparklineErrorToString(err) - | RequestedStrategyInvalidError => `Requested strategy invalid` + | RequestedStrategyInvalidError(err) => `Requested strategy invalid: ${err}` | OtherError(s) => s } diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index 25169b2f..a83bc8c2 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -225,55 +225,22 @@ module AlgebraicCombination = { | _ => 1000 } - type calculationMethod = MonteCarlo | Convolution(Operation.convolutionOperation) + type calculationStrategy = MonteCarloStrat | ConvolutionStrat(Operation.convolutionOperation) let chooseConvolutionOrMonteCarloDefault = ( op: Operation.algebraicOperation, t2: t, t1: t, - ): calculationMethod => + ): calculationStrategy => switch op { | #Divide | #Power | #Logarithm => - MonteCarlo + MonteCarloStrat | (#Add | #Subtract | #Multiply) as convOp => expectedConvolutionCost(t1) * expectedConvolutionCost(t2) > 10000 - ? MonteCarlo - : Convolution(convOp) - } - - let chooseConvolutionOrMonteCarlo = ( - ~strat: DistributionTypes.asAlgebraicCombinationStrategy, - op: Operation.algebraicOperation, - t2: t, - t1: t, - ): result => { - switch strat { - | AsDefault => Ok(chooseConvolutionOrMonteCarloDefault(op, t2, t1)) - | AsConvolution => - switch op { - | #Divide | #Power | #Logarithm => Error(RequestedStrategyInvalidError) - | (#Add | #Subtract | #Multiply) as convOp => Ok(Convolution(convOp)) - } - | AsMonteCarlo => Ok(MonteCarlo) - | AsSymbolic => Error(RequestedStrategyInvalidError) - } - } - - let tryAnalyticalSimplificationDefault = ( - arithmeticOperation: Operation.algebraicOperation, - t1: t, - t2: t, - ): option> => - switch (t1, t2) { - | (Symbolic(d1), Symbolic(d2)) => - switch SymbolicDist.T.tryAnalyticalSimplification(d1, d2, arithmeticOperation) { - | #AnalyticalSolution(symbolicDist) => Some(Ok(symbolicDist)) - | #Error(er) => Some(Error(er)) - | #NoSolution => None - } - | _ => None + ? MonteCarloStrat + : ConvolutionStrat(convOp) } let tryAnalyticalSimplification = ( @@ -295,16 +262,17 @@ module AlgebraicCombination = { ~arithmeticOperation, ~t2: t, ): result => { - switch tryAnalyticalSimplificationDefault(arithmeticOperation, t1, t2) { - | Some(Ok(symbolicDist)) => Ok(Symbolic(symbolicDist)) - | Some(Error(e)) => Error(OperationError(e)) + switch tryAnalyticalSimplification(arithmeticOperation, t1, t2) { + | Some(#AnalyticalSolution(symbolicDist)) => Ok(Symbolic(symbolicDist)) + | Some(#Error(e)) => Error(OperationError(e)) + | Some(#NoSolution) | None => switch getInvalidOperationError(t1, t2, ~toPointSetFn, ~arithmeticOperation) { | Some(e) => Error(e) | None => switch chooseConvolutionOrMonteCarloDefault(arithmeticOperation, t1, t2) { - | MonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) - | Convolution(convOp) => + | MonteCarloStrat => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) + | ConvolutionStrat(convOp) => runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet( r, )) @@ -318,7 +286,7 @@ module AlgebraicCombination = { t1: t, ~toPointSetFn: toPointSetFn, ~toSampleSetFn: toSampleSetFn, - ~arithmeticOperation, + ~arithmeticOperation: Operation.algebraicOperation, ~t2: t, ): result => { switch strategy { @@ -326,20 +294,23 @@ module AlgebraicCombination = { | AsSymbolic => switch tryAnalyticalSimplification(arithmeticOperation, t1, t2) { | Some(#AnalyticalSolution(symbolicDist)) => Ok(Symbolic(symbolicDist)) - | Some(#NoSolution) - | None => - Error(RequestedStrategyInvalidError) + | Some(#NoSolution) => Error(RequestedStrategyInvalidError(`No analytical solution`)) + | None => Error(RequestedStrategyInvalidError("Inputs were not even symbolic")) | Some(#Error(err)) => Error(OperationError(err)) } - | AsConvolution - | AsMonteCarlo => - switch chooseConvolutionOrMonteCarlo(~strat=strategy, arithmeticOperation, t1, t2) { - | Ok(MonteCarlo) => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) - | Ok(Convolution(convOp)) => - runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet(r)) - | Error(RequestedStrategyInvalidError) => Error(RequestedStrategyInvalidError) - | Error(err) => Error(err) + | AsConvolution => { + let errString = opString => `Can't convolve on ${opString}` + switch arithmeticOperation { + | (#Add | #Subtract | #Multiply) as convOp => + runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet( + r, + )) + | #Divide => "divide"->errString->RequestedStrategyInvalidError->Error + | #Power => "power"->errString->RequestedStrategyInvalidError->Error + | #Logarithm => "logarithm"->errString->RequestedStrategyInvalidError->Error + } } + | AsMonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) } } } From 4f2dda4625995ae1f1b40fa82c0adc82372d3b86 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 27 Apr 2022 09:45:48 -0400 Subject: [PATCH 47/62] CR comment about `toString`. Value: [0.001 to 0.04] --- .../src/rescript/Distributions/GenericDist/GenericDist.res | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index a83bc8c2..3af431f2 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -305,9 +305,8 @@ module AlgebraicCombination = { runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet( r, )) - | #Divide => "divide"->errString->RequestedStrategyInvalidError->Error - | #Power => "power"->errString->RequestedStrategyInvalidError->Error - | #Logarithm => "logarithm"->errString->RequestedStrategyInvalidError->Error + | (#Divide | #Power | #Logarithm) as op => + op->Operation.Algebraic.toString->errString->RequestedStrategyInvalidError->Error } } | AsMonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2) From 729b3e70f082ccbe9a79586d2ee3e74f64824f74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:32:32 +0000 Subject: [PATCH 48/62] :arrow_up: Bump react-dom from 18.0.0 to 18.1.0 Bumps [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom) from 18.0.0 to 18.1.0. - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v18.1.0/packages/react-dom) --- updated-dependencies: - dependency-name: react-dom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- packages/components/package.json | 2 +- packages/website/package.json | 2 +- yarn.lock | 33 +++++++++++++------------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index c2e4ef79..0fe1a4cf 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -5,7 +5,7 @@ "dependencies": { "antd": "^4.20.1", "react-ace": "10.1.0", - "react-dom": "^18.0.0", + "react-dom": "^18.1.0", "@react-hook/size": "^2.1.2", "styled-components": "^5.3.5" }, diff --git a/packages/website/package.json b/packages/website/package.json index 501778cf..d53d28de 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -18,7 +18,7 @@ "clsx": "^1.1.1", "prism-react-renderer": "^1.2.1", "react": "^18.0.0", - "react-dom": "^18.0.0", + "react-dom": "^18.1.0", "remark-math": "^3", "rehype-katex": "^5", "hast-util-is-element": "2.1.2" diff --git a/yarn.lock b/yarn.lock index f59f2fc2..90824400 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4089,9 +4089,9 @@ "@types/react" "*" "@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": - version "18.0.7" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.7.tgz#8437a226763adf854969954dfe582529a406cbad" - integrity sha512-CXSXHzTexlX9esf4ReIUJeaemKcmBEvYzxHDUk19c3BCcEGUvUjkeC3jkscPSfSaQ6SPDRNd/zMxi8oc/P1zxA== + version "18.0.8" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.8.tgz#a051eb380a9fbcaa404550543c58e1cf5ce4ab87" + integrity sha512-+j2hk9BzCOrrOSJASi5XiOyBbERk9jG5O73Ya4M0env5Ixi6vUNli4qy994AINcEF+1IEHISYFfIT4zwr++LKw== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -8472,14 +8472,7 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -fast-check@2.25.0: - version "2.25.0" - resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.25.0.tgz#5146601851bf3be0953bd17eb2b7d547936c6561" - integrity sha512-wRUT2KD2lAmT75WNIJIHECawoUUMHM0I5jrlLXGtGeqmPL8jl/EldUDjY1VCp6fDY8yflyfUeIOsOBrIbIiArg== - dependencies: - pure-rand "^5.0.1" - -fast-check@^2.17.0: +fast-check@2.25.0, fast-check@^2.17.0: version "2.25.0" resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.25.0.tgz#5146601851bf3be0953bd17eb2b7d547936c6561" integrity sha512-wRUT2KD2lAmT75WNIJIHECawoUUMHM0I5jrlLXGtGeqmPL8jl/EldUDjY1VCp6fDY8yflyfUeIOsOBrIbIiArg== @@ -14324,13 +14317,13 @@ react-docgen@^5.0.0: node-dir "^0.1.10" strip-indent "^3.0.0" -react-dom@^18.0.0: - version "18.0.0" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.0.0.tgz#26b88534f8f1dbb80853e1eabe752f24100d8023" - integrity sha512-XqX7uzmFo0pUceWFCt7Gff6IyIMzFUn7QMZrbrQfGxtaxXZIcGQzoNpRLE3fQLnS4XzLLPMZX2T9TRcSrasicw== +react-dom@^18.1.0: + version "18.1.0" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.1.0.tgz#7f6dd84b706408adde05e1df575b3a024d7e8a2f" + integrity sha512-fU1Txz7Budmvamp7bshe4Zi32d0ll7ect+ccxNu9FlObT605GOEB8BfO4tmRJ39R5Zj831VCpvQ05QPBW5yb+w== dependencies: loose-envify "^1.1.0" - scheduler "^0.21.0" + scheduler "^0.22.0" react-draggable@^4.4.3: version "4.4.4" @@ -15233,10 +15226,10 @@ saxes@^5.0.1: dependencies: xmlchars "^2.2.0" -scheduler@^0.21.0: - version "0.21.0" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0.tgz#6fd2532ff5a6d877b6edb12f00d8ab7e8f308820" - integrity sha512-1r87x5fz9MXqswA2ERLo0EbOAU74DpIUO090gIasYTqlVoJeMcl+Z1Rg7WHz+qtPujhS/hGIt9kxZOYBV3faRQ== +scheduler@^0.22.0: + version "0.22.0" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.22.0.tgz#83a5d63594edf074add9a7198b1bae76c3db01b8" + integrity sha512-6QAm1BgQI88NPYymgGQLCZgvep4FyePDWFpXVK+zNSUgHwlqpJy8VEh8Et0KxTACS4VWwMousBElAZOH9nkkoQ== dependencies: loose-envify "^1.1.0" From 4193bf9d6765a8c718b94b40c39231ed43db33e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:32:54 +0000 Subject: [PATCH 49/62] :arrow_up: Bump @types/node from 17.0.27 to 17.0.29 Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 17.0.27 to 17.0.29. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- packages/components/package.json | 2 +- yarn.lock | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index c2e4ef79..d41870bc 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -32,7 +32,7 @@ "@testing-library/user-event": "^14.1.1", "@types/jest": "^27.4.0", "@types/lodash": "^4.14.182", - "@types/node": "^17.0.25", + "@types/node": "^17.0.29", "@types/react": "^18.0.3", "@types/react-dom": "^18.0.2", "cross-env": "^7.0.3", diff --git a/yarn.lock b/yarn.lock index f59f2fc2..2dc42614 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3966,21 +3966,16 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@^17.0.5": - version "17.0.26" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.26.tgz#1bbff9b23ee5a64f87b4f30c0c854b112ee2e635" - integrity sha512-z/FG/6DUO7pnze3AE3TBGIjGGKkvCcGcWINe1C7cADY8hKLJPDYpzsNE37uExQ4md5RFtTCvg+M8Mu1Enyeg2A== +"@types/node@*", "@types/node@^17.0.29", "@types/node@^17.0.5": + version "17.0.29" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.29.tgz#7f2e1159231d4a077bb660edab0fde373e375a3d" + integrity sha512-tx5jMmMFwx7wBwq/V7OohKDVb/JwJU5qCVkeLMh1//xycAJ/ESuw9aJ9SEtlCZDYi2pBfe4JkisSoAtbOsBNAA== "@types/node@^14.0.10": version "14.18.13" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.13.tgz#6ad4d9db59e6b3faf98dcfe4ca9d2aec84443277" integrity sha512-Z6/KzgyWOga3pJNS42A+zayjhPbf2zM3hegRQaOPnLOzEi86VV++6FLDWgR1LGrVCRufP/ph2daa3tEa5br1zA== -"@types/node@^17.0.25": - version "17.0.27" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.27.tgz#f4df3981ae8268c066e8f49995639f855469081e" - integrity sha512-4/Ke7bbWOasuT3kceBZFGakP1dYN2XFd8v2l9bqF2LNWrmeU07JLpp56aEeG6+Q3olqO5TvXpW0yaiYnZJ5CXg== - "@types/normalize-package-data@^2.4.0": version "2.4.1" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" @@ -4089,9 +4084,9 @@ "@types/react" "*" "@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": - version "18.0.7" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.7.tgz#8437a226763adf854969954dfe582529a406cbad" - integrity sha512-CXSXHzTexlX9esf4ReIUJeaemKcmBEvYzxHDUk19c3BCcEGUvUjkeC3jkscPSfSaQ6SPDRNd/zMxi8oc/P1zxA== + version "18.0.8" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.8.tgz#a051eb380a9fbcaa404550543c58e1cf5ce4ab87" + integrity sha512-+j2hk9BzCOrrOSJASi5XiOyBbERk9jG5O73Ya4M0env5Ixi6vUNli4qy994AINcEF+1IEHISYFfIT4zwr++LKw== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -8472,14 +8467,7 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -fast-check@2.25.0: - version "2.25.0" - resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.25.0.tgz#5146601851bf3be0953bd17eb2b7d547936c6561" - integrity sha512-wRUT2KD2lAmT75WNIJIHECawoUUMHM0I5jrlLXGtGeqmPL8jl/EldUDjY1VCp6fDY8yflyfUeIOsOBrIbIiArg== - dependencies: - pure-rand "^5.0.1" - -fast-check@^2.17.0: +fast-check@2.25.0, fast-check@^2.17.0: version "2.25.0" resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.25.0.tgz#5146601851bf3be0953bd17eb2b7d547936c6561" integrity sha512-wRUT2KD2lAmT75WNIJIHECawoUUMHM0I5jrlLXGtGeqmPL8jl/EldUDjY1VCp6fDY8yflyfUeIOsOBrIbIiArg== From 0ca3115d4f83b04470d1e32cd4a3f4d54c9c1239 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:34:15 +0000 Subject: [PATCH 50/62] :arrow_up: Bump ts-loader from 9.2.8 to 9.2.9 Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 9.2.8 to 9.2.9. - [Release notes](https://github.com/TypeStrong/ts-loader/releases) - [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md) - [Commits](https://github.com/TypeStrong/ts-loader/compare/v9.2.8...v9.2.9) --- updated-dependencies: - dependency-name: ts-loader dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- packages/components/package.json | 2 +- packages/squiggle-lang/package.json | 2 +- yarn.lock | 23 ++++++++--------------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index c2e4ef79..efcb8032 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -22,7 +22,7 @@ "@types/styled-components": "^5.1.24", "@types/webpack": "^5.28.0", "style-loader": "^3.3.1", - "ts-loader": "^9.2.8", + "ts-loader": "^9.2.9", "webpack": "^5.72.0", "webpack-cli": "^4.9.2", "webpack-dev-server": "^4.8.1", diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 1a1e6a29..128b01e5 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -51,7 +51,7 @@ "reanalyze": "^2.19.0", "nyc": "^15.1.0", "ts-jest": "^27.1.4", - "ts-loader": "^9.2.8", + "ts-loader": "^9.2.9", "typescript": "^4.6.3", "webpack": "^5.72.0", "webpack-cli": "^4.9.2" diff --git a/yarn.lock b/yarn.lock index f59f2fc2..dcacda48 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4089,9 +4089,9 @@ "@types/react" "*" "@types/react@*", "@types/react@^16.9.19", "@types/react@^18.0.1", "@types/react@^18.0.3": - version "18.0.7" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.7.tgz#8437a226763adf854969954dfe582529a406cbad" - integrity sha512-CXSXHzTexlX9esf4ReIUJeaemKcmBEvYzxHDUk19c3BCcEGUvUjkeC3jkscPSfSaQ6SPDRNd/zMxi8oc/P1zxA== + version "18.0.8" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.8.tgz#a051eb380a9fbcaa404550543c58e1cf5ce4ab87" + integrity sha512-+j2hk9BzCOrrOSJASi5XiOyBbERk9jG5O73Ya4M0env5Ixi6vUNli4qy994AINcEF+1IEHISYFfIT4zwr++LKw== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -8472,14 +8472,7 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -fast-check@2.25.0: - version "2.25.0" - resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.25.0.tgz#5146601851bf3be0953bd17eb2b7d547936c6561" - integrity sha512-wRUT2KD2lAmT75WNIJIHECawoUUMHM0I5jrlLXGtGeqmPL8jl/EldUDjY1VCp6fDY8yflyfUeIOsOBrIbIiArg== - dependencies: - pure-rand "^5.0.1" - -fast-check@^2.17.0: +fast-check@2.25.0, fast-check@^2.17.0: version "2.25.0" resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-2.25.0.tgz#5146601851bf3be0953bd17eb2b7d547936c6561" integrity sha512-wRUT2KD2lAmT75WNIJIHECawoUUMHM0I5jrlLXGtGeqmPL8jl/EldUDjY1VCp6fDY8yflyfUeIOsOBrIbIiArg== @@ -16606,10 +16599,10 @@ ts-jest@^27.1.4: semver "7.x" yargs-parser "20.x" -ts-loader@^9.2.8: - version "9.2.8" - resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.2.8.tgz#e89aa32fa829c5cad0a1d023d6b3adecd51d5a48" - integrity sha512-gxSak7IHUuRtwKf3FIPSW1VpZcqF9+MBrHOvBp9cjHh+525SjtCIJKVGjRKIAfxBwDGDGCFF00rTfzB1quxdSw== +ts-loader@^9.2.9: + version "9.2.9" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.2.9.tgz#0653e07fa1b4f225d0ca57a84fddbfd43d930f9e" + integrity sha512-b0+vUY2/enb0qYtDQuNlDnJ9900NTiPiJcDJ6sY7ax1CCCwXfYIqPOMm/BwW7jsF1km+Oz8W9s31HLuD+FLIMg== dependencies: chalk "^4.1.0" enhanced-resolve "^5.0.0" From b9db84c63fe9b7cc8501e43fc0c355c560abd813 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:50:13 +0000 Subject: [PATCH 51/62] :arrow_up: Bump ejs from 3.1.6 to 3.1.7 Bumps [ejs](https://github.com/mde/ejs) from 3.1.6 to 3.1.7. - [Release notes](https://github.com/mde/ejs/releases) - [Changelog](https://github.com/mde/ejs/blob/main/CHANGELOG.md) - [Commits](https://github.com/mde/ejs/compare/v3.1.6...v3.1.7) --- updated-dependencies: - dependency-name: ejs dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/yarn.lock b/yarn.lock index 90824400..2022eeab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5194,11 +5194,6 @@ async-validator@^4.0.2: resolved "https://registry.yarnpkg.com/async-validator/-/async-validator-4.0.7.tgz#034a0fd2103a6b2ebf010da75183bec299247afe" integrity sha512-Pj2IR7u8hmUEDOwB++su6baaRi+QvsgajuFB9j95foM1N2gy5HM4z60hfusIO0fBPG5uLAEl6yCJr1jNSVugEQ== -async@0.9.x: - version "0.9.2" - resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" - integrity sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0= - async@^2.6.2: version "2.6.4" resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221" @@ -5206,6 +5201,11 @@ async@^2.6.2: dependencies: lodash "^4.17.14" +async@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" + integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -5743,6 +5743,13 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + braces@^2.3.1, braces@^2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" @@ -7763,11 +7770,11 @@ ee-first@1.1.1: integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= ejs@^3.1.6: - version "3.1.6" - resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.6.tgz#5bfd0a0689743bb5268b3550cceeebbc1702822a" - integrity sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw== + version "3.1.7" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.7.tgz#c544d9c7f715783dd92f0bddcf73a59e6962d006" + integrity sha512-BIar7R6abbUxDA3bfXrO4DSgwo8I+fB5/1zgujl3HLLjwd6+9iOnrT+t3grn2qbk9vOgBubXOFwX2m9axoFaGw== dependencies: - jake "^10.6.1" + jake "^10.8.5" electron-to-chromium@^1.4.84: version "1.4.107" @@ -8634,11 +8641,11 @@ file-uri-to-path@1.0.0: integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== filelist@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.2.tgz#80202f21462d4d1c2e214119b1807c1bc0380e5b" - integrity sha512-z7O0IS8Plc39rTCq6i6iHxk43duYOn8uFJiWSewIq0Bww1RNybVHSCjahmcC87ZqAm4OTvFzlzeGu3XAzG1ctQ== + version "1.0.3" + resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.3.tgz#448607750376484932f67ef1b9ff07386b036c83" + integrity sha512-LwjCsruLWQULGYKy7TX0OPtrL9kLpojOFKc5VCTxdFTV7w5zbsgqVKfnkKG7Qgjtq50gKfO56hJv88OfcGb70Q== dependencies: - minimatch "^3.0.4" + minimatch "^5.0.1" filesize@^8.0.6: version "8.0.7" @@ -10476,12 +10483,12 @@ iterate-value@^1.0.2: es-get-iterator "^1.0.2" iterate-iterator "^1.0.1" -jake@^10.6.1: - version "10.8.4" - resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.4.tgz#f6a8b7bf90c6306f768aa82bb7b98bf4ca15e84a" - integrity sha512-MtWeTkl1qGsWUtbl/Jsca/8xSoK3x0UmS82sNbjqxxG/de/M/3b1DntdjHgPMC50enlTNwXOCRqPXLLt5cCfZA== +jake@^10.8.5: + version "10.8.5" + resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46" + integrity sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw== dependencies: - async "0.9.x" + async "^3.2.3" chalk "^4.0.2" filelist "^1.0.1" minimatch "^3.0.4" @@ -11848,6 +11855,13 @@ minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.1.2: dependencies: brace-expansion "^1.1.7" +minimatch@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6: version "1.2.6" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" From c6e86cfe2cfd0f2a2437e36d901cecd2082a538b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:51:21 +0000 Subject: [PATCH 52/62] :arrow_up: Bump react from 18.0.0 to 18.1.0 Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) from 18.0.0 to 18.1.0. - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v18.1.0/packages/react) --- updated-dependencies: - dependency-name: react dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- packages/components/package.json | 2 +- packages/website/package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index e4c216a2..d895d545 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -37,7 +37,7 @@ "@types/react-dom": "^18.0.2", "cross-env": "^7.0.3", "lodash": "^4.17.21", - "react": "^18.0.0", + "react": "^18.1.0", "react-scripts": "5.0.1", "react-vega": "^7.5.0", "tsconfig-paths-webpack-plugin": "^3.5.2", diff --git a/packages/website/package.json b/packages/website/package.json index d53d28de..c830fc27 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -17,7 +17,7 @@ "@quri/squiggle-components": "0.2.9", "clsx": "^1.1.1", "prism-react-renderer": "^1.2.1", - "react": "^18.0.0", + "react": "^18.1.0", "react-dom": "^18.1.0", "remark-math": "^3", "rehype-katex": "^5", diff --git a/yarn.lock b/yarn.lock index cb09517f..9f9044ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14566,10 +14566,10 @@ react-vega@^7.5.0: fast-deep-equal "^3.1.1" vega-embed "^6.5.1" -react@^18.0.0: - version "18.0.0" - resolved "https://registry.yarnpkg.com/react/-/react-18.0.0.tgz#b468736d1f4a5891f38585ba8e8fb29f91c3cb96" - integrity sha512-x+VL6wbT4JRVPm7EGxXhZ8w8LTROaxPXOqhlGyVSrv0sB1jkyFGgXxJ8LVoPRLvPR6/CIZGFmfzqUa2NYeMr2A== +react@^18.0.0, react@^18.1.0: + version "18.1.0" + resolved "https://registry.yarnpkg.com/react/-/react-18.1.0.tgz#6f8620382decb17fdc5cc223a115e2adbf104890" + integrity sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ== dependencies: loose-envify "^1.1.0" From b5f88e5ec96660fa15da2481166693fe0c51a202 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Wed, 27 Apr 2022 15:36:08 +0000 Subject: [PATCH 53/62] Update lock file to appease prettier Value: [0.00001 to 0.0001] --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 6163236a..f9feaabc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16655,7 +16655,7 @@ ts-jest@^27.1.4: semver "7.x" yargs-parser "20.x" -ts-loader@^9.2.9: +ts-loader@^9.2.8, ts-loader@^9.2.9: version "9.2.9" resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.2.9.tgz#0653e07fa1b4f225d0ca57a84fddbfd43d930f9e" integrity sha512-b0+vUY2/enb0qYtDQuNlDnJ9900NTiPiJcDJ6sY7ax1CCCwXfYIqPOMm/BwW7jsF1km+Oz8W9s31HLuD+FLIMg== From 9c29a7048ac4dee7544ad0c7c8a9c3efc1ace192 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 27 Apr 2022 11:50:24 -0400 Subject: [PATCH 54/62] Added `toPointSet` and `toSampleSet` to functions reference Value: [0.004 to 0.089] --- .prettierignore | 1 + packages/website/docs/Features/Functions.mdx | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/.prettierignore b/.prettierignore index 8a670c22..54df33a4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -10,3 +10,4 @@ packages/squiggle-lang/lib packages/squiggle-lang/.nyc_output/ packages/squiggle-lang/coverage/ packages/squiggle-lang/.cache/ +packages/website/build/ diff --git a/packages/website/docs/Features/Functions.mdx b/packages/website/docs/Features/Functions.mdx index bc8be820..e37ea315 100644 --- a/packages/website/docs/Features/Functions.mdx +++ b/packages/website/docs/Features/Functions.mdx @@ -305,6 +305,16 @@ The `sample(distribution)` samples a given distribution. +## Converting between distribution formats + +Recall the [three formats of distributions](https://develop--squiggle-documentation.netlify.app/docs/Discussions/Three-Types-Of-Distributions). We can force any distribution into `SampleSet` format + + + +Or `PointSet` format + + + ## Normalization Some distribution operations (like horizontal shift) return an unnormalized distriibution. From d81e68273b64d6d51fc3412976e56f8fa41619b2 Mon Sep 17 00:00:00 2001 From: Quinn Date: Wed, 27 Apr 2022 12:10:32 -0400 Subject: [PATCH 55/62] Hotfix: `reducer-dev` pr trigger --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd6e38d1..acd96119 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ on: branches: - master - develop + - reducer-dev jobs: pre_check: From 21d4c1b928d5273304106e54e10bb98ba9daaebf Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 27 Apr 2022 12:39:41 -0400 Subject: [PATCH 56/62] rm warning number 26 Value: [1e-4 to 5e-3] --- packages/squiggle-lang/src/rescript/Utility/E.res | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res index de2c5099..daba1861 100644 --- a/packages/squiggle-lang/src/rescript/Utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -523,11 +523,11 @@ module A = { let discrete = FloatFloatMap.empty() Belt.Array.forEachWithIndex(sortedArray, (index, element) => { let maxIndex = (sortedArray |> Array.length) - 1 - let possiblySimilarElements = switch index { - | 0 => [index + 1] - | n if n == maxIndex => [index - 1] - | _ => [index - 1, index + 1] - } |> Belt.Array.map(_, r => sortedArray[r]) + // let possiblySimilarElements = switch index { + // | 0 => [index + 1] + // | n if n == maxIndex => [index - 1] + // | _ => [index - 1, index + 1] + // } |> Belt.Array.map(_, r => sortedArray[r]) // let hasSimilarElement = Belt.Array.some(possiblySimilarElements, r => r == element) let hasSimilarElement = false hasSimilarElement From aabb53957ea320818c9295321fca3e01bfa33b96 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 27 Apr 2022 12:41:07 -0400 Subject: [PATCH 57/62] rm warnings 26 and 27 Value: [1e-5 to 1e-3] --- packages/squiggle-lang/src/rescript/Utility/E.res | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res index daba1861..362ed743 100644 --- a/packages/squiggle-lang/src/rescript/Utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -521,8 +521,8 @@ module A = { let split = (sortedArray: array) => { let continuous = [] let discrete = FloatFloatMap.empty() - Belt.Array.forEachWithIndex(sortedArray, (index, element) => { - let maxIndex = (sortedArray |> Array.length) - 1 + Belt.Array.forEachWithIndex(sortedArray, (_, element) => { + // let maxIndex = (sortedArray |> Array.length) - 1 // let possiblySimilarElements = switch index { // | 0 => [index + 1] // | n if n == maxIndex => [index - 1] From a5c4cba2f098adf62fb0ddb53bf41fca418b8be8 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 27 Apr 2022 12:54:42 -0400 Subject: [PATCH 58/62] Updated tests Value: [1e-4 to 8e-3] --- packages/squiggle-lang/__tests__/TS/JS_test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/squiggle-lang/__tests__/TS/JS_test.ts b/packages/squiggle-lang/__tests__/TS/JS_test.ts index 6ce886a0..1974dee6 100644 --- a/packages/squiggle-lang/__tests__/TS/JS_test.ts +++ b/packages/squiggle-lang/__tests__/TS/JS_test.ts @@ -58,14 +58,15 @@ describe("Distribution", () => { ); test("mean", () => { - expect(dist.mean().value).toBeCloseTo(8.704375514292865); + expect(dist.mean().value).toBeCloseTo(9.5555555); }); test("pdf", () => { - expect(dist.pdf(5.0).value).toBeCloseTo(0.052007455285386944, 1); + expect(dist.pdf(5.0).value).toBeCloseTo(0.10499097598222966, 1); }); test("cdf", () => { expect(dist.cdf(5.0).value).toBeCloseTo( - dist1Samples.filter((x) => x <= 5).length / dist1SampleCount + dist1Samples.filter((x) => x <= 5).length / dist1SampleCount, + 1 ); }); test("inv", () => { @@ -91,6 +92,6 @@ describe("Distribution", () => { resultMap(dist.pointwiseAdd(dist2), (r: Distribution) => r.toSparkline(20) ).value - ).toEqual(Ok("▁▂▅██▅▅▅▆▆▇▅▄▃▃▂▂▁▁▁")); + ).toEqual(Ok("▁▂██▃▃▃▃▄▅▄▃▃▂▂▂▁▁▁▁")); }); }); From a22fbb1afde7741da7ef930fe6beeb5db1d661e4 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 27 Apr 2022 12:57:49 -0400 Subject: [PATCH 59/62] lint Value: [1e-7 to 1e-6] --- .../src/rescript/Distributions/SampleSetDist/SampleSetDist.res | 2 +- packages/squiggle-lang/src/rescript/Utility/E.res | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res index d85b8716..14c66812 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res @@ -107,4 +107,4 @@ let min = t => T.get(t)->E.A.Floats.min let max = t => T.get(t)->E.A.Floats.max let stdev = t => T.get(t)->E.A.Floats.stdev let variance = t => T.get(t)->E.A.Floats.variance -let percentile = (t,f) => T.get(t)->E.A.Floats.percentile(f) \ No newline at end of file +let percentile = (t, f) => T.get(t)->E.A.Floats.percentile(f) diff --git a/packages/squiggle-lang/src/rescript/Utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res index 362ed743..030c2961 100644 --- a/packages/squiggle-lang/src/rescript/Utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -555,7 +555,7 @@ module A = { //Passing true for the exclusive parameter excludes both endpoints of the range. //https://jstat.github.io/all.html - let percentile = (a,b) => Jstat.percentile(a,b, false) + let percentile = (a, b) => Jstat.percentile(a, b, false) // Gives an array with all the differences between values // diff([1,5,3,7]) = [4,-2,4] From 7b87f64658739a9f38a9430ff0d483ec5ebae740 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 27 Apr 2022 13:59:33 -0400 Subject: [PATCH 60/62] Issue 325 Value: [1e-3 to 3e-2] --- .../squiggle-lang/__tests__/TestHelpers.res | 4 +-- .../Distributions/GenericDist/GenericDist.res | 28 +++++++++------- .../src/rescript/MagicNumbers.res | 24 ++++++++++++++ .../ReducerInterface_GenericDistribution.res | 33 ++++++++++++------- 4 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 packages/squiggle-lang/src/rescript/MagicNumbers.res diff --git a/packages/squiggle-lang/__tests__/TestHelpers.res b/packages/squiggle-lang/__tests__/TestHelpers.res index 5147857b..cbb3258d 100644 --- a/packages/squiggle-lang/__tests__/TestHelpers.res +++ b/packages/squiggle-lang/__tests__/TestHelpers.res @@ -30,8 +30,8 @@ let {toFloat, toDist, toString, toError, fmap} = module(DistributionOperation.Ou let fnImage = (theFn, inps) => Js.Array.map(theFn, inps) let env: DistributionOperation.env = { - sampleCount: 10000, - xyPointLength: 1000, + sampleCount: MagicNumbers.Environment.defaultSampleCount, + xyPointLength: MagicNumbers.Environment.defaultXYPointLength, } let run = DistributionOperation.run(~env) diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index a3fc6323..2d8d0fa8 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -186,13 +186,17 @@ module AlgebraicCombination = { */ let getLogarithmInputError = (t1: t, t2: t, ~toPointSetFn: toPointSetFn): option => { let firstOperandIsGreaterThanZero = - toFloatOperation(t1, ~toPointSetFn, ~distToFloatOperation=#Cdf(1e-10)) |> E.R.fmap(r => - r > 0. - ) + toFloatOperation( + t1, + ~toPointSetFn, + ~distToFloatOperation=#Cdf(MagicNumbers.Epsilon.ten), + ) |> E.R.fmap(r => r > 0.) let secondOperandIsGreaterThanZero = - toFloatOperation(t2, ~toPointSetFn, ~distToFloatOperation=#Cdf(1e-10)) |> E.R.fmap(r => - r > 0. - ) + toFloatOperation( + t2, + ~toPointSetFn, + ~distToFloatOperation=#Cdf(MagicNumbers.Epsilon.ten), + ) |> E.R.fmap(r => r > 0.) let items = E.A.R.firstErrorOrOpen([ firstOperandIsGreaterThanZero, secondOperandIsGreaterThanZero, @@ -224,12 +228,12 @@ module AlgebraicCombination = { //I'm (Ozzie) really just guessing here, very little idea what's best let expectedConvolutionCost: t => int = x => switch x { - | Symbolic(#Float(_)) => 1 - | Symbolic(_) => 1000 + | Symbolic(#Float(_)) => MagicNumbers.OpCost.floatCost + | Symbolic(_) => MagicNumbers.OpCost.symbolicCost | PointSet(Discrete(m)) => m.xyShape->XYShape.T.length - | PointSet(Mixed(_)) => 1000 - | PointSet(Continuous(_)) => 1000 - | _ => 1000 + | PointSet(Mixed(_)) => MagicNumbers.OpCost.mixedCost + | PointSet(Continuous(_)) => MagicNumbers.OpCost.continuousCost + | _ => MagicNumbers.OpCost.wildcardCost } type calculationStrategy = MonteCarloStrat | ConvolutionStrat(Operation.convolutionOperation) @@ -245,7 +249,7 @@ module AlgebraicCombination = { | #Logarithm => MonteCarloStrat | (#Add | #Subtract | #Multiply) as convOp => - expectedConvolutionCost(t1) * expectedConvolutionCost(t2) > 10000 + expectedConvolutionCost(t1) * expectedConvolutionCost(t2) > MagicNumbers.OpCost.monteCarloCost ? MonteCarloStrat : ConvolutionStrat(convOp) } diff --git a/packages/squiggle-lang/src/rescript/MagicNumbers.res b/packages/squiggle-lang/src/rescript/MagicNumbers.res new file mode 100644 index 00000000..291f05d6 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/MagicNumbers.res @@ -0,0 +1,24 @@ +module Math = { + let e = Js.Math._E + let pi = Js.Math._PI +} + +module Epsilon = { + let ten = 1e-10 + let seven = 1e-7 +} + +module Environment = { + let defaultXYPointLength = 1000 + let defaultSampleCount = 10000 +} + +module OpCost = { + let floatCost = 1 + let symbolicCost = 1000 + // Discrete cost is the length of the xyShape + let mixedCost = 1000 + let continuousCost = 1000 + let wildcardCost = 1000 + let monteCarloCost = Environment.defaultSampleCount +} diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index 53f680ab..ab76f469 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -1,12 +1,10 @@ module ExpressionValue = ReducerInterface_ExpressionValue type expressionValue = ReducerInterface_ExpressionValue.expressionValue -let defaultSampleCount = 10000 - let runGenericOperation = DistributionOperation.run( ~env={ - sampleCount: defaultSampleCount, - xyPointLength: 1000, + sampleCount: MagicNumbers.Environment.defaultSampleCount, + xyPointLength: MagicNumbers.Environment.defaultXYPointLength, }, ) @@ -176,10 +174,6 @@ module SymbolicConstructors = { } } -module Math = { - let e = 2.718281828459 -} - let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< DistributionOperation.outputType, > => { @@ -208,7 +202,12 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< Helpers.toStringFn(ToSparkline(Belt.Float.toInt(n)), dist) | ("exp", [EvDistribution(a)]) => // https://mathjs.org/docs/reference/functions/exp.html - Helpers.twoDiststoDistFn(Algebraic(AsDefault), "pow", GenericDist.fromFloat(Math.e), a)->Some + Helpers.twoDiststoDistFn( + Algebraic(AsDefault), + "pow", + GenericDist.fromFloat(MagicNumbers.Math.e), + a, + )->Some | ("normalize", [EvDistribution(dist)]) => Helpers.toDistFn(Normalize, dist) | ("isNormalized", [EvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist) | ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist) @@ -218,7 +217,7 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< | ("toSampleSet", [EvDistribution(dist), EvNumber(float)]) => Helpers.toDistFn(ToSampleSet(Belt.Int.fromFloat(float)), dist) | ("toSampleSet", [EvDistribution(dist)]) => - Helpers.toDistFn(ToSampleSet(defaultSampleCount), dist) + Helpers.toDistFn(ToSampleSet(MagicNumbers.Environment.defaultSampleCount), dist) | ("inspect", [EvDistribution(dist)]) => Helpers.toDistFn(Inspect, dist) | ("truncateLeft", [EvDistribution(dist), EvNumber(float)]) => Helpers.toDistFn(Truncate(Some(float), None), dist) @@ -228,7 +227,12 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< Helpers.toDistFn(Truncate(Some(float1), Some(float2)), dist) | ("mx" | "mixture", args) => Helpers.mixture(args)->Some | ("log", [EvDistribution(a)]) => - Helpers.twoDiststoDistFn(Algebraic(AsDefault), "log", a, GenericDist.fromFloat(Math.e))->Some + Helpers.twoDiststoDistFn( + Algebraic(AsDefault), + "log", + a, + GenericDist.fromFloat(MagicNumbers.Math.e), + )->Some | ("log10", [EvDistribution(a)]) => Helpers.twoDiststoDistFn(Algebraic(AsDefault), "log", a, GenericDist.fromFloat(10.0))->Some | ("unaryMinus", [EvDistribution(a)]) => @@ -249,7 +253,12 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< Helpers.twoDiststoDistFn(Pointwise, arithmetic, fst, snd) ) | ("dotExp", [EvDistribution(a)]) => - Helpers.twoDiststoDistFn(Pointwise, "dotPow", GenericDist.fromFloat(Math.e), a)->Some + Helpers.twoDiststoDistFn( + Pointwise, + "dotPow", + GenericDist.fromFloat(MagicNumbers.Math.e), + a, + )->Some | _ => None } } From 54f8b10a9577a376cfd67e35f425c957f37248ae Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Wed, 27 Apr 2022 22:00:42 +0200 Subject: [PATCH 61/62] Reducer: Environment (Give environement to all function dispatches) - closes #169 --- .../__tests__/Reducer/Reducer_TestHelpers.res | 13 +- .../src/rescript/Reducer/Reducer.res | 7 +- .../src/rescript/Reducer/Reducer.resi | 39 +++--- .../Reducer_Dispatch_BuiltIn.res | 6 +- .../Reducer_Dispatch_BuiltInMacros.res | 5 +- .../Reducer_Expression/Reducer_Expression.res | 114 +++++++++--------- .../ReducerInterface_ExpressionValue.res | 8 ++ .../ReducerInterface_ExternalLibrary.res | 4 +- .../ReducerInterface_GenericDistribution.res | 6 +- .../ReducerInterface_GenericDistribution.resi | 2 +- 10 files changed, 119 insertions(+), 85 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res index 581f6c8a..c56d4130 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_TestHelpers.res @@ -1,9 +1,17 @@ module Expression = Reducer.Expression module ExpressionValue = ReducerInterface.ExpressionValue +module ErrorValue = Reducer_ErrorValue open Jest open Expect +let unwrapRecord = rValue => + rValue->Belt.Result.flatMap(value => switch value { + | ExpressionValue.EvRecord(aRecord) => Ok(aRecord) + | _ => ErrorValue.RETodo("TODO: External bindings must be returned")->Error + } +) + let expectParseToBe = (expr: string, answer: string) => Reducer.parse(expr)->Expression.toStringResult->expect->toBe(answer) @@ -17,7 +25,7 @@ let expectEvalToBe = (expr: string, answer: string) => Reducer.evaluate(expr)->ExpressionValue.toStringResult->expect->toBe(answer) let expectEvalBindingsToBe = (expr: string, bindings: Reducer.externalBindings, answer: string) => - Reducer.evaluateUsingExternalBindings(expr, bindings) + Reducer.evaluateUsingOptions(expr, ~externalBindings=Some(bindings), ~isPartial=None, ~environment=None) ->ExpressionValue.toStringResult ->expect ->toBe(answer) @@ -27,7 +35,8 @@ let expectEvalPartialBindingsToBe = ( bindings: Reducer.externalBindings, answer: string, ) => - Reducer.evaluatePartialUsingExternalBindings(expr, bindings) + Reducer.evaluateUsingOptions(expr, ~externalBindings=Some(bindings), ~isPartial=Some(true), ~environment=None) + ->unwrapRecord ->ExpressionValue.toStringResultRecord ->expect ->toBe(answer) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer.res index 63e1f3a7..a403ccd3 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer.res @@ -5,11 +5,12 @@ module Extra = Reducer_Extra module Js = Reducer_Js module MathJs = Reducer_MathJs +type environment = ReducerInterface_ExpressionValue.environment +type errorValue = Reducer_ErrorValue.errorValue type expressionValue = ReducerInterface_ExpressionValue.expressionValue type externalBindings = ReducerInterface_ExpressionValue.externalBindings -let evaluate = Expression.eval -let evaluateUsingExternalBindings = Expression.evalUsingExternalBindings -let evaluatePartialUsingExternalBindings = Expression.evalPartialUsingExternalBindings +let evaluate = Expression.evaluate +let evaluateUsingOptions = Expression.evaluateUsingOptions let parse = Expression.parse let parseOuter = Expression.parseOuter let parsePartial = Expression.parsePartial diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi b/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi index 8bbfc0b5..d71f9a5a 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer.resi @@ -5,22 +5,29 @@ module Extra = Reducer_Extra module Js = Reducer_Js module MathJs = Reducer_MathJs -@genType +@genType +type environment = ReducerInterface_ExpressionValue.environment +@genType +type errorValue = Reducer_ErrorValue.errorValue +@genType type expressionValue = ReducerInterface_ExpressionValue.expressionValue -@genType +@genType type externalBindings = ReducerInterface_ExpressionValue.externalBindings -@genType -let evaluate: string => result -@genType -let evaluateUsingExternalBindings: ( + +@genType +let evaluateUsingOptions: ( + ~environment: option< + QuriSquiggleLang.ReducerInterface_ExpressionValue.environment, + >, + ~externalBindings: option< + QuriSquiggleLang.ReducerInterface_ExpressionValue.externalBindings, + >, + ~isPartial: option, string, - externalBindings, -) => result -@genType -let evaluatePartialUsingExternalBindings: ( - string, - externalBindings, -) => result -let parse: string => result -let parseOuter: string => result -let parsePartial: string => result +) => result +@genType +let evaluate: string => result + +let parse: string => result +let parseOuter: string => result +let parsePartial: string => result diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res index 3e365fd4..3733d7e2 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res @@ -11,7 +11,7 @@ open Reducer_ErrorValue exception TestRescriptException -let callInternal = (call: functionCall): result<'b, errorValue> => { +let callInternal = (call: functionCall, _environment): result<'b, errorValue> => { let callMathJs = (call: functionCall): result<'b, errorValue> => switch call { | ("javascriptraise", [msg]) => Js.Exn.raiseError(toString(msg)) // For Tests @@ -85,12 +85,12 @@ let callInternal = (call: functionCall): result<'b, errorValue> => { /* Reducer uses Result monad while reducing expressions */ -let dispatch = (call: functionCall): result => +let dispatch = (call: functionCall, environment): result => try { let (fn, args) = call // There is a bug that prevents string match in patterns // So we have to recreate a copy of the string - ExternalLibrary.dispatch((Js.String.make(fn), args), callInternal) + ExternalLibrary.dispatch((Js.String.make(fn), args), environment, callInternal) } catch { | Js.Exn.Error(obj) => REJavaScriptExn(Js.Exn.message(obj), Js.Exn.name(obj))->Error | _ => RETodo("unhandled rescript exception")->Error diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res index 5facc9e7..185897e9 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltInMacros.res @@ -10,10 +10,12 @@ module Result = Belt.Result open Reducer_ErrorValue type expression = ExpressionT.expression +type environment = ExpressionValue.environment type reducerFn = ( expression, ExpressionT.bindings, + environment, ) => result let rec replaceSymbols = (expression: expression, bindings: ExpressionT.bindings): result< @@ -101,6 +103,7 @@ let rec replaceSymbols = (expression: expression, bindings: ExpressionT.bindings let dispatchMacroCall = ( list: list, bindings: ExpressionT.bindings, + environment, reduceExpression: reducerFn, ): result => { let doBindStatement = (statement: expression, bindings: ExpressionT.bindings) => { @@ -114,7 +117,7 @@ let dispatchMacroCall = ( let rNewValue = rNewExpressionToReduce->Result.flatMap(newExpressionToReduce => - reduceExpression(newExpressionToReduce, bindings) + reduceExpression(newExpressionToReduce, bindings, environment) ) let rNewExpression = rNewValue->Result.map(newValue => ExpressionT.EValue(newValue)) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res index d27ece78..052648ed 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression.res @@ -8,9 +8,12 @@ module T = Reducer_Expression_T open Reducer_ErrorValue +type environment = ReducerInterface_ExpressionValue.environment +type errorValue = Reducer_ErrorValue.errorValue type expression = T.expression -type expressionValue = ExpressionValue.expressionValue -type internalCode = ExpressionValue.internalCode +type expressionValue = ReducerInterface_ExpressionValue.expressionValue +type externalBindings = ReducerInterface_ExpressionValue.externalBindings +type internalCode = ReducerInterface_ExpressionValue.internalCode type t = expression external castExpressionToInternalCode: expression => internalCode = "%identity" @@ -57,19 +60,20 @@ let defaultBindings: T.bindings = Belt.Map.String.empty /* Recursively evaluate/reduce the expression (Lisp AST) */ -let rec reduceExpression = (expression: t, bindings: T.bindings): result => { +let rec reduceExpression = (expression: t, bindings: T.bindings, environment: environment): result => { /* Macros are like functions but instead of taking values as parameters, they take expressions as parameters and return a new expression. Macros are used to define language building blocks. They are like Lisp macros. */ - let doMacroCall = (list: list, bindings: T.bindings): result => - Reducer_Dispatch_BuiltInMacros.dispatchMacroCall(list, bindings, reduceExpression) + let doMacroCall = (list: list, bindings: T.bindings, environment: environment): result => + Reducer_Dispatch_BuiltInMacros.dispatchMacroCall(list, bindings, environment, reduceExpression) let applyParametersToLambda = ( internal: internalCode, parameters: array, args: list, + environment ): result => { let expr = castInternalCodeToExpression(internal) let parameterList = parameters->Belt.List.fromArray @@ -81,22 +85,22 @@ let rec reduceExpression = (expression: t, bindings: T.bindings): result): result => + let reduceValueList = (valueList: list, environment): result => switch valueList { - | list{EvCall(fName), ...args} => (fName, args->Belt.List.toArray)->BuiltIn.dispatch + | list{EvCall(fName), ...args} => (fName, args->Belt.List.toArray)->BuiltIn.dispatch(environment) // "(lambda(x=>internal) param)" | list{EvLambda((parameters, internal)), ...args} => - applyParametersToLambda(internal, parameters, args) + applyParametersToLambda(internal, parameters, args, environment) | _ => valueList->Belt.List.toArray->ExpressionValue.EvArray->Ok } - let rec seekMacros = (expression: t, bindings: T.bindings): result => + let rec seekMacros = (expression: t, bindings: T.bindings, environment): result => switch expression { | T.EValue(_value) => expression->Ok | T.EBindings(_value) => expression->Ok @@ -108,17 +112,17 @@ let rec reduceExpression = (expression: t, bindings: T.bindings): result racc->Result.flatMap(acc => { each - ->seekMacros(bindings) + ->seekMacros(bindings, environment) ->Result.flatMap(newNode => { acc->Belt.List.add(newNode)->Ok }) }) ) - racc->Result.flatMap(acc => acc->doMacroCall(bindings)) + racc->Result.flatMap(acc => acc->doMacroCall(bindings, environment)) } } - let rec reduceExpandedExpression = (expression: t): result => + let rec reduceExpandedExpression = (expression: t, environment): result => switch expression { | T.EList(list{T.EValue(EvCall("$lambda")), T.EParameters(parameters), functionDefinition}) => EvLambda((parameters, functionDefinition->castExpressionToInternalCode))->Ok @@ -130,36 +134,36 @@ let rec reduceExpression = (expression: t, bindings: T.bindings): result racc->Result.flatMap(acc => { each - ->reduceExpandedExpression + ->reduceExpandedExpression(environment) ->Result.flatMap(newNode => { acc->Belt.List.add(newNode)->Ok }) }) ) - racc->Result.flatMap(acc => acc->reduceValueList) + racc->Result.flatMap(acc => acc->reduceValueList(environment)) } | EBindings(_bindings) => RETodo("Error: Bindings cannot be reduced to values")->Error | EParameters(_parameters) => RETodo("Error: Lambda Parameters cannot be reduced to values")->Error } - let rExpandedExpression: result = expression->seekMacros(bindings) + let rExpandedExpression: result = expression->seekMacros(bindings, environment) rExpandedExpression->Result.flatMap(expandedExpression => - expandedExpression->reduceExpandedExpression + expandedExpression->reduceExpandedExpression(environment) ) } -let evalUsingExternalBindingsExpression_ = (aExpression, bindings): result => - reduceExpression(aExpression, bindings) +let evalUsingExternalBindingsExpression_ = (aExpression, bindings, environment): result => + reduceExpression(aExpression, bindings, environment) /* Evaluates MathJs code via Reducer using bindings and answers the result. When bindings are used, the code is a partial code as if it is cut from a larger code. Therefore all statements are assignments. */ -let evalPartialUsingExternalBindings_ = (codeText: string, bindings: T.bindings) => { +let evalPartial_ = (codeText: string, bindings: T.bindings, environment: environment) => { parsePartial(codeText)->Result.flatMap(expression => - expression->evalUsingExternalBindingsExpression_(bindings) + expression->evalUsingExternalBindingsExpression_(bindings, environment) ) } @@ -168,23 +172,12 @@ let evalPartialUsingExternalBindings_ = (codeText: string, bindings: T.bindings) When bindings are used, the code is a partial code as if it is cut from a larger code. Therefore all statments are assignments. */ -let evalOuterWBindings_ = (codeText: string, bindings: T.bindings) => { +let evalOuter_ = (codeText: string, bindings: T.bindings, environment: environment) => { parseOuter(codeText)->Result.flatMap(expression => - expression->evalUsingExternalBindingsExpression_(bindings) + expression->evalUsingExternalBindingsExpression_(bindings, environment) ) } -/* - Evaluates MathJs code and bindings via Reducer and answers the result -*/ -let eval = (codeText: string) => { - parse(codeText)->Result.flatMap(expression => - expression->evalUsingExternalBindingsExpression_(defaultBindings) - ) -} - -type externalBindings = ReducerInterface.ExpressionValue.externalBindings //Js.Dict.t - let externalBindingsToBindings = (externalBindings: externalBindings): T.bindings => { let keys = Js.Dict.keys(externalBindings) keys->Belt.Array.reduce(defaultBindings, (acc, key) => { @@ -192,28 +185,41 @@ let externalBindingsToBindings = (externalBindings: externalBindings): T.binding acc->Belt.Map.String.set(key, T.EValue(value)) }) } -/* - Evaluates code with external bindings. External bindings are a record of expression values. -*/ -let evalUsingExternalBindings = (code: string, externalBindings: externalBindings) => { - let bindings = externalBindings->externalBindingsToBindings - evalOuterWBindings_(code, bindings) + +let evaluateUsingOptions = ( + ~environment: option, + ~externalBindings: option, + ~isPartial: option, + code: string): result => { + + let anEnvironment = switch environment { + | Some(env) => env + | None => ReducerInterface_ExpressionValue.defaultEnvironment + } + + let anExternalBindings = switch externalBindings { + | Some(bindings) => bindings + | None => ReducerInterface_ExpressionValue.defaultExternalBindings + } + + let anIsPartial = switch isPartial { + | Some(isPartial) => isPartial + | None => false + } + + let bindings = anExternalBindings->externalBindingsToBindings + + if anIsPartial { + evalPartial_(code, bindings, anEnvironment) + } else { + evalOuter_(code, bindings, anEnvironment) + } } /* - Evaluates code with external bindings. External bindings are a record of expression values. - The code is a partial code as if it is cut from a larger code. Therefore all statments are assignments. + Evaluates MathJs code and bindings via Reducer and answers the result */ -let evalPartialUsingExternalBindings = (code: string, externalBindings: externalBindings): result< - externalBindings, - 'e, -> => { - let bindings = externalBindings->externalBindingsToBindings - let answer = evalPartialUsingExternalBindings_(code, bindings) - answer->Result.flatMap(answer => - switch answer { - | EvRecord(aRecord) => Ok(aRecord) - | _ => RETodo("TODO: External bindings must be returned")->Error - } - ) +let evaluate = (code: string): result => { + evaluateUsingOptions(~environment=None, ~externalBindings=None, ~isPartial=None, code) } +let eval = evaluate diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res index 6c15536b..96068dca 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res @@ -22,6 +22,9 @@ type rec expressionValue = @genType type externalBindings = Js.Dict.t +@genType +let defaultExternalBindings: externalBindings = Js.Dict.empty() + type functionCall = (string, array) @@ -84,3 +87,8 @@ let toStringResultRecord = x => | Ok(a) => `Ok(${toStringRecord(a)})` | Error(m) => `Error(${ErrorValue.errorToString(m)})` } + +@genType +type environment = {dummy: int} +@genType +let defaultEnvironment: environment = {dummy: 0} diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res index 84d37d95..fde0faf2 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res @@ -14,8 +14,8 @@ type expressionValue = ExpressionValue.expressionValue Map external calls of Reducer */ -let dispatch = (call: ExpressionValue.functionCall, chain): result => - ReducerInterface_GenericDistribution.dispatch(call) |> E.O.default(chain(call)) +let dispatch = (call: ExpressionValue.functionCall, environment, chain): result => + ReducerInterface_GenericDistribution.dispatch(call, environment) |> E.O.default(chain(call, environment)) /* If your dispatch is too big you can divide it into smaller dispatches and pass the call so that it gets called finally. diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index f39dc932..5ed33809 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -180,7 +180,7 @@ module Math = { let e = 2.718281828459 } -let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< +let dispatchToGenericOutput = (call: ExpressionValue.functionCall, _environment): option< DistributionOperation.outputType, > => { let (fnName, args) = call @@ -266,6 +266,6 @@ let genericOutputToReducerValue = (o: DistributionOperation.outputType): result< | GenDistError(err) => Error(REDistributionError(err)) } -let dispatch = call => { - dispatchToGenericOutput(call)->E.O2.fmap(genericOutputToReducerValue) +let dispatch = (call, environment) => { + dispatchToGenericOutput(call, environment)->E.O2.fmap(genericOutputToReducerValue) } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi index fc7ebabc..26464d44 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi @@ -1,3 +1,3 @@ -let dispatch: ReducerInterface_ExpressionValue.functionCall => option< +let dispatch: (ReducerInterface_ExpressionValue.functionCall, ReducerInterface_ExpressionValue.environment) => option< result, > From 5c1ce71a40d838cb29c229976b065e061728d464 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Wed, 27 Apr 2022 22:09:25 +0200 Subject: [PATCH 62/62] fix TypescriptInterface.res --- packages/squiggle-lang/src/rescript/TypescriptInterface.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/squiggle-lang/src/rescript/TypescriptInterface.res b/packages/squiggle-lang/src/rescript/TypescriptInterface.res index 5e2a59b6..a16e6875 100644 --- a/packages/squiggle-lang/src/rescript/TypescriptInterface.res +++ b/packages/squiggle-lang/src/rescript/TypescriptInterface.res @@ -32,7 +32,7 @@ let makeSampleSetDist = SampleSetDist.make let evaluate = Reducer.evaluate @genType -let evaluateUsingExternalBindings = Reducer.evaluateUsingExternalBindings +let evaluateUsingOptions = Reducer.evaluateUsingOptions @genType type expressionValue = ReducerInterface_ExpressionValue.expressionValue