diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 184ac544..dac2c269 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ on: - develop - reducer-dev - epic-reducer-project + - epic-0.5.0 jobs: pre_check: @@ -25,27 +26,27 @@ jobs: steps: - id: skip_lang_check name: Check if the changes are about squiggle-lang src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/squiggle-lang/**"]' - id: skip_components_check name: Check if the changes are about components src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/components/**"]' - id: skip_website_check name: Check if the changes are about website src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/website/**"]' - id: skip_vscodeext_check name: Check if the changes are about vscode extension src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/vscode-ext/**"]' - id: skip_cli_check name: Check if the changes are about cli src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/cli/**"]' diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index bd3fa87b..bea4046b 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -18,27 +18,27 @@ jobs: steps: - id: skip_lang_check name: Check if the changes are about squiggle-lang src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/squiggle-lang/**"]' - id: skip_components_check name: Check if the changes are about components src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/components/**"]' - id: skip_website_check name: Check if the changes are about website src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/website/**"]' - id: skip_vscodeext_check name: Check if the changes are about vscode extension src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/vscode-ext/**"]' - id: skip_cli_check name: Check if the changes are about cli src files - uses: fkirc/skip-duplicate-actions@v4.0.0 + uses: fkirc/skip-duplicate-actions@v5.1.0 with: paths: '["packages/cli/**"]' diff --git a/packages/components/package.json b/packages/components/package.json index 97e35bc2..f6acf4eb 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -12,11 +12,11 @@ "@react-hook/size": "^2.1.2", "@types/uuid": "^8.3.4", "clsx": "^1.2.1", - "framer-motion": "^7.3.5", + "framer-motion": "^7.4.0", "lodash": "^4.17.21", "react": "^18.1.0", "react-ace": "^10.1.0", - "react-hook-form": "^7.35.0", + "react-hook-form": "^7.36.1", "react-use": "^17.4.0", "react-vega": "^7.6.0", "uuid": "^9.0.0", @@ -41,8 +41,8 @@ "@testing-library/user-event": "^14.4.3", "@types/jest": "^27.5.0", "@types/lodash": "^4.14.185", - "@types/node": "^18.7.18", - "@types/react": "^18.0.18", + "@types/node": "^18.7.22", + "@types/react": "^18.0.21", "@types/styled-components": "^5.1.26", "@types/webpack": "^5.28.0", "cross-env": "^7.0.3", @@ -61,7 +61,7 @@ "web-vitals": "^3.0.2", "webpack": "^5.74.0", "webpack-cli": "^4.10.0", - "webpack-dev-server": "^4.11.0" + "webpack-dev-server": "^4.11.1" }, "peerDependencies": { "react": "^16.8.0 || ^17 || ^18", diff --git a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_Distribution_test.res b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_Distribution_test.res index 78d3f900..7328bcc1 100644 --- a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_Distribution_test.res +++ b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_Distribution_test.res @@ -98,6 +98,7 @@ describe("eval on distribution functions", () => { "log(normal(5,2), normal(10,1))", "Error(Distribution Math Error: Logarithm of input error: First input must be completely greater than 0)", ) + testEval("log(2, SampleSet.fromDist(0.0001 to 5))", "Ok(Sample Set Distribution)") // log with low values, see https://github.com/quantified-uncertainty/squiggle/issues/1098 testEval("log(uniform(5,8))", "Ok(Sample Set Distribution)") testEval("log10(uniform(5,8))", "Ok(Sample Set Distribution)") }) diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 195ddcd2..476726ae 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -56,7 +56,7 @@ "bisect_ppx": "^2.7.1", "chalk": "^5.0.1", "codecov": "^3.8.3", - "fast-check": "^3.1.3", + "fast-check": "^3.1.4", "gentype": "^4.5.0", "jest": "^27.5.1", "moduleserve": "^0.9.1", diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res index f9f5a5d0..231a893c 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist.res @@ -86,6 +86,7 @@ let toFloatOperation = ( | (SampleSet(sampleSet), #Inv(r)) => SampleSetDist.percentile(sampleSet, r)->Some | (SampleSet(sampleSet), #Min) => SampleSetDist.min(sampleSet)->Some | (SampleSet(sampleSet), #Max) => SampleSetDist.max(sampleSet)->Some + | (SampleSet(sampleSet), #Cdf(r)) => SampleSetDist.cdf(sampleSet, r)->Some | _ => None } @@ -277,22 +278,14 @@ module AlgebraicCombination = { 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 = + let isDistGreaterThanZero = t => toFloatOperation( - t1, + t, ~toPointSetFn, ~distToFloatOperation=#Cdf(MagicNumbers.Epsilon.ten), - ) |> E.R.fmap(r => r > 0.) - let secondOperandIsGreaterThanZero = - toFloatOperation( - t2, - ~toPointSetFn, - ~distToFloatOperation=#Cdf(MagicNumbers.Epsilon.ten), - ) |> E.R.fmap(r => r > 0.) - let items = E.A.R.firstErrorOrOpen([ - firstOperandIsGreaterThanZero, - secondOperandIsGreaterThanZero, - ]) + )->E.R2.fmap(r => r > 0.) + + let items = E.A.R.firstErrorOrOpen([isDistGreaterThanZero(t1), isDistGreaterThanZero(t2)]) switch items { | Error(r) => Some(r) | Ok([true, _]) => diff --git a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res index 41856882..17fbe431 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res @@ -131,6 +131,10 @@ 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) +let cdf = (t: t, f: float) => { + let countBelowF = t->E.A.reduce(0, (acc, x) => acc + (x <= f ? 1 : 0)) + countBelowF->Js.Int.toFloat /. t->length->Js.Int.toFloat +} let mixture = (values: array<(t, float)>, intendedLength: int) => { let totalWeight = values->E.A2.fmap(E.Tuple2.second)->E.A.Floats.sum diff --git a/packages/website/docs/Api/Function.md b/packages/website/docs/Api/Function.md deleted file mode 100644 index 1c08bb8f..00000000 --- a/packages/website/docs/Api/Function.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -sidebar_position: 6 -title: Function ---- - -## declare (experimental) - -Adds metadata to a function of the input ranges. Works now for numeric and date inputs. This is useful when making formal predictions. It allows you to limit the domain that your prediction will be used and scored within. - -The one function that declarations currently have is that they impact plotting. If you `declare` a single-variable function within a specific range, this specific range will be plotted. - -Declarations are currently experimental and will likely be removed or changed in the future. - -``` -Function.declare: (dict<{fn: lambda, inputs: array>}>) => declaration -``` - -**Examples** - -```javascript -Function.declare({ - fn: {|a| a+10 }, - inputs: [ - {min: 30, max: 100} - ] -}) -``` diff --git a/yarn.lock b/yarn.lock index b4e4ef54..d3030ec2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4678,10 +4678,10 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@18.x", "@types/node@^18.7.18": - version "18.7.18" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.18.tgz#633184f55c322e4fb08612307c274ee6d5ed3154" - integrity sha512-m+6nTEOadJZuTPkKR/SYK3A2d7FZrgElol9UP1Kae90VVU4a6mxnPuLiIW1m4Cq4gZ/nWb9GrdVXJCoCazDAbg== +"@types/node@*", "@types/node@18.x", "@types/node@^18.7.22": + version "18.7.22" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.22.tgz#76f7401362ad63d9d7eefa7dcdfa5fcd9baddff3" + integrity sha512-TsmoXYd4zrkkKjJB0URF/mTIKPl+kVcbqClB2F/ykU7vil1BfWZVndOnpEIozPv4fURD28gyPFeIkW2G+KXOvw== "@types/node@^14.0.10 || ^16.0.0", "@types/node@^14.14.20 || ^16.0.0": version "16.11.56" @@ -4776,10 +4776,10 @@ "@types/history" "^4.7.11" "@types/react" "*" -"@types/react@*", "@types/react@^18.0.1", "@types/react@^18.0.18": - version "18.0.20" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.20.tgz#e4c36be3a55eb5b456ecf501bd4a00fd4fd0c9ab" - integrity sha512-MWul1teSPxujEHVwZl4a5HxQ9vVNsjTchVA+xRqv/VYGCuKGAU6UhfrTdF5aBefwD1BHUD8i/zq+O/vyCm/FrA== +"@types/react@*", "@types/react@^18.0.1", "@types/react@^18.0.21": + version "18.0.21" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.21.tgz#b8209e9626bb00a34c76f55482697edd2b43cc67" + integrity sha512-7QUCOxvFgnD5Jk8ZKlUAhVcRj7GuJRjnjjiY/IUBWKgOlnvDvTMLD4RTF7NPyVmbRhNrbomZiOepg7M/2Kj1mA== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -9135,12 +9135,12 @@ fast-check@^2.17.0: dependencies: pure-rand "^5.0.1" -fast-check@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-3.1.3.tgz#134e5852e3c56b65e47a48b1a5022bee14c10ba3" - integrity sha512-IFY7xJrOUktiC1ZnaJdrinaRpFgDZtURRPwzAiOhL8eyt2NbBTHNF1CO7vZUla1BoUeJVI7gLnTQA+Lko0T2dQ== +fast-check@^3.1.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-3.1.4.tgz#e755623b4a63d0a26c285acbd1c1d8e3ea283a6e" + integrity sha512-AC4o8U7riY668tHAcJ10PHWpmhaNDfyzs2THFwQ6FJMPP05EmHKEmYvup7B1DCS+kKAzzosjSF51TamUM5IyPA== dependencies: - pure-rand "^5.0.1" + pure-rand "^5.0.2" fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3, fast-deep-equal@~3.1.3: version "3.1.3" @@ -9506,10 +9506,10 @@ fragment-cache@^0.2.1: dependencies: map-cache "^0.2.2" -framer-motion@^7.3.5: - version "7.3.5" - resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-7.3.5.tgz#9a3d30658290a473acca268f19c3b65e4c6aeb70" - integrity sha512-JrLLVCi59LMI3+ZvSSbxf/Z7SOIdYRZrgdkUvJkzyT2RXu34HtGy26n41jNrcD5K85boqlZhGTbfqnAIfMHRLQ== +framer-motion@^7.4.0: + version "7.4.0" + resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-7.4.0.tgz#318c52a76517f9f854aa4a298c292be04941521b" + integrity sha512-tcvL5L1cASYjIeBG6mQHhzfndm7MdyHjOwqIdOzOetIVa1yUqeYMufAoljgqg69XFgsgZet+c4iuSuFF+Vgbjg== dependencies: "@motionone/dom" "10.13.1" framesync "6.1.2" @@ -14702,10 +14702,10 @@ pure-color@^1.2.0: resolved "https://registry.yarnpkg.com/pure-color/-/pure-color-1.3.0.tgz#1fe064fb0ac851f0de61320a8bf796836422f33e" integrity sha512-QFADYnsVoBMw1srW7OVKEYjG+MbIa49s54w1MA1EDY6r2r/sTcKKYqRX1f4GYvnXP7eN/Pe9HFcX+hwzmrXRHA== -pure-rand@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-5.0.1.tgz#97a287b4b4960b2a3448c0932bf28f2405cac51d" - integrity sha512-ksWccjmXOHU2gJBnH0cK1lSYdvSZ0zLoCMSz/nTGh6hDvCSgcRxDyIcOBD6KNxFz3xhMPm/T267Tbe2JRymKEQ== +pure-rand@^5.0.1, pure-rand@^5.0.2: + version "5.0.3" + resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-5.0.3.tgz#a2f15dfbc3be8433d1d8ed67ee411aa83fb90406" + integrity sha512-9N8x1h8dptBQpHyC7aZMS+iNOAm97WMGY0AFrguU1cpfW3I5jINkWe5BIY5md0ofy+1TCIELsVcm/GJXZSaPbw== q@^1.1.2: version "1.5.1" @@ -14945,10 +14945,10 @@ react-helmet-async@*, react-helmet-async@^1.3.0: react-fast-compare "^3.2.0" shallowequal "^1.1.0" -react-hook-form@^7.35.0: - version "7.35.0" - resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.35.0.tgz#b133de48fc84b1e62f9277ba79dfbacd9bb13dd3" - integrity sha512-9CYdOed+Itbiu5VMVxW0PK9mBR3f0gDGJcZEyUSm0eJbDymQ913TRs2gHcQZZmfTC+rtxyDFRuelMxx/+xwMcw== +react-hook-form@^7.36.1: + version "7.36.1" + resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.36.1.tgz#82a311fe8cbe75e689fd4529f083b7c983da6520" + integrity sha512-EbYYkCG2p8ywe7ikOH2l02lAFMrrrslZi1I8fqd8ifDGNAkhomHZQzQsP6ksvzrWBKntRe8b5L5L7Zsd+Gm02Q== react-inspector@^5.1.0: version "5.1.1" @@ -15907,10 +15907,10 @@ select-hose@^2.0.0: resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" integrity sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg== -selfsigned@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.0.1.tgz#8b2df7fa56bf014d19b6007655fff209c0ef0a56" - integrity sha512-LmME957M1zOsUhG+67rAjKfiWFox3SBxE/yymatMZsAx+oMrJ0YQ8AToOnyCm7xbeg2ep37IHLxdu0o2MavQOQ== +selfsigned@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.1.1.tgz#18a7613d714c0cd3385c48af0075abf3f266af61" + integrity sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ== dependencies: node-forge "^1" @@ -18508,10 +18508,10 @@ webpack-dev-middleware@^5.3.1: range-parser "^1.2.1" schema-utils "^4.0.0" -webpack-dev-server@^4.11.0, webpack-dev-server@^4.6.0, webpack-dev-server@^4.9.3: - version "4.11.0" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.11.0.tgz#290ee594765cd8260adfe83b2d18115ea04484e7" - integrity sha512-L5S4Q2zT57SK7tazgzjMiSMBdsw+rGYIX27MgPgx7LDhWO0lViPrHKoLS7jo5In06PWYAhlYu3PbyoC6yAThbw== +webpack-dev-server@^4.11.1, webpack-dev-server@^4.6.0, webpack-dev-server@^4.9.3: + version "4.11.1" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.11.1.tgz#ae07f0d71ca0438cf88446f09029b92ce81380b5" + integrity sha512-lILVz9tAUy1zGFwieuaQtYiadImb5M3d+H+L1zDYalYoDl0cksAB1UNyuE5MMWJrG6zR1tXkCP2fitl7yoUJiw== dependencies: "@types/bonjour" "^3.5.9" "@types/connect-history-api-fallback" "^1.3.5" @@ -18536,7 +18536,7 @@ webpack-dev-server@^4.11.0, webpack-dev-server@^4.6.0, webpack-dev-server@^4.9.3 p-retry "^4.5.0" rimraf "^3.0.2" schema-utils "^4.0.0" - selfsigned "^2.0.1" + selfsigned "^2.1.1" serve-index "^1.9.1" sockjs "^0.3.24" spdy "^4.0.2"