From 1102ceb4ec5441ade3c11b02ef94cfb977d6cf87 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 23 Apr 2022 17:51:41 -0400 Subject: [PATCH 01/24] 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 02/24] 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 3367b82eef8ec4a2ac86a07fb6ba214a31867b46 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 25 Apr 2022 20:55:16 -0400 Subject: [PATCH 03/24] `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 04/24] 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 9cfadffcb75582b99ae1460c3e768f010d21327f Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 09:54:16 -0400 Subject: [PATCH 05/24] 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 06/24] :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 07/24] :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 08/24] :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 e47deb84334e076907239437af62ae96f08fc3d4 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 26 Apr 2022 12:22:31 -0400 Subject: [PATCH 09/24] 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 10/24] 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 11/24] 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 12/24] 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 c53e56e7738ac8750c39693779d1a1a7b6952ea9 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 16:06:51 -0400 Subject: [PATCH 13/24] 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 6f00716722eb68c76c436a4fa2f02af7239b22c9 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 16:39:52 -0400 Subject: [PATCH 14/24] 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 b9c8a7e2c711c2bc1ac109330f5b7f1802e6a2e1 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 16:58:36 -0400 Subject: [PATCH 15/24] 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 16/24] 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 17/24] 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 938a10766c916d73c34a0776a22d63a57174c386 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 26 Apr 2022 20:30:38 -0400 Subject: [PATCH 18/24] 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 19/24] 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 20/24] :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 21/24] :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 22/24] :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 23/24] :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 24/24] :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"