Merge branch 'develop' into reducer-project

This commit is contained in:
Umur Ozkul 2022-08-23 14:46:37 +02:00
commit 441854ffec
6 changed files with 92 additions and 71 deletions

View File

@ -11,16 +11,16 @@
"@quri/squiggle-lang": "^0.3.0",
"@react-hook/size": "^2.1.2",
"clsx": "^1.2.1",
"framer-motion": "^7.1.1",
"framer-motion": "^7.2.0",
"lodash": "^4.17.21",
"react": "^18.1.0",
"react-ace": "^10.1.0",
"react-hook-form": "^7.34.1",
"react-hook-form": "^7.34.2",
"react-use": "^17.4.0",
"react-vega": "^7.6.0",
"vega": "^5.22.1",
"vega-embed": "^6.21.0",
"vega-lite": "^5.4.0",
"vega-lite": "^5.5.0",
"vscode-uri": "^3.0.3",
"yup": "^0.32.11"
},
@ -38,8 +38,8 @@
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^27.5.0",
"@types/lodash": "^4.14.182",
"@types/node": "^18.7.4",
"@types/lodash": "^4.14.184",
"@types/node": "^18.7.9",
"@types/react": "^18.0.9",
"@types/styled-components": "^5.1.26",
"@types/webpack": "^5.28.0",

View File

@ -23,6 +23,30 @@ let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
expressionValue
}
module Internal = {
type t = PointSetDist.t
let toType = (r): result<
ReducerInterface_InternalExpressionValue.t,
Reducer_ErrorValue.errorValue,
> =>
switch r {
| Ok(r) => Ok(Wrappers.evDistribution(PointSet(r)))
| Error(err) => Error(REOperationError(err))
}
let doLambdaCall = (aLambdaValue, list, environment, reducer) =>
switch Reducer_Expression_Lambda.doLambdaCall(aLambdaValue, list, environment, reducer) {
| Ok(IEvNumber(f)) => Ok(f)
| _ => Error(Operation.SampleMapNeedsNtoNFunction)
}
let mapY = (pointSetDist: t, aLambdaValue, env, reducer) => {
let fn = r => doLambdaCall(aLambdaValue, list{IEvNumber(r)}, env, reducer)
PointSetDist.T.mapYResult(~fn, pointSetDist)->toType
}
}
let library = [
Function.make(
~name="fromDist",
@ -53,6 +77,27 @@ let library = [
],
(),
),
Function.make(
~name="mapY",
~nameSpace,
~requiresNamespace=true,
~examples=[`PointSet.mapY(mx(normal(5,2)), {|x| x + 1})`],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
~definitions=[
FnDefinition.make(
~name="mapY",
~inputs=[FRTypeDist, FRTypeLambda],
~run=(inputs, _, env, reducer) =>
switch inputs {
| [IEvDistribution(PointSet(dist)), IEvLambda(lambda)] =>
Internal.mapY(dist, lambda, env, reducer)->E.R2.errMap(Reducer_ErrorValue.errorToString)
| _ => Error(impossibleError)
},
(),
),
],
(),
),
Function.make(
~name="makeContinuous",
~nameSpace,

View File

@ -102,7 +102,7 @@ let library = [
GenericDist.toSampleSetDist(dist, accessors.environment.sampleCount)
->E.R2.fmap(Wrappers.sampleSet)
->E.R2.fmap(Wrappers.evDistribution)
->E.R2.errMap(_ => "")
->E.R2.errMap(DistributionTypes.Error.toString)
| _ => Error(impossibleError)
},
(),
@ -168,7 +168,7 @@ let library = [
| [IEvLambda(lambda)] =>
switch Internal.fromFn(lambda, accessors, reducer) {
| Ok(r) => Ok(r->Wrappers.sampleSet->Wrappers.evDistribution)
| Error(_) => Error("issue")
| Error(e) => Error(Operation.Error.toString(e))
}
| _ => Error(impossibleError)
},

View File

@ -7,7 +7,7 @@
"publisher": "QURI",
"repository": {
"type": "git",
"url": "git+https://github.com/quantified-uncertainty/squiggle.git"
"url": "https://github.com/quantified-uncertainty/squiggle.git"
},
"icon": "media/vendor/icon.png",
"engines": {
@ -130,7 +130,7 @@
"@types/node": "18.x",
"@types/vscode": "^1.70.0",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.0",
"@typescript-eslint/parser": "^5.33.1",
"eslint": "^8.22.0",
"glob": "^8.0.3",
"js-yaml": "^4.1.0",
@ -143,4 +143,4 @@
"vscode-languageserver-textdocument": "^1.0.5",
"@quri/squiggle-lang": "^0.2.11"
}
}
}

View File

@ -46,3 +46,13 @@ PointSet.makeDiscrete([
{ x: 3, y: 0.1 },
]);
```
### mapY
```
PointSet.mapY: (pointSetDist, (number => number)) => pointSetDist
```
```javascript
normal(5,3) |> PointSet.fromDist |> PointSet.mapY({|x| x ^ 2}) |> normalize
```

View File

@ -4696,10 +4696,10 @@
resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.11.1.tgz#34de04477dcf79e2ef6c8d23b41a3d81f9ebeaf5"
integrity sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg==
"@types/lodash@^4.14.167", "@types/lodash@^4.14.175", "@types/lodash@^4.14.182":
version "4.14.182"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2"
integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==
"@types/lodash@^4.14.167", "@types/lodash@^4.14.175", "@types/lodash@^4.14.184":
version "4.14.184"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.184.tgz#23f96cd2a21a28e106dc24d825d4aa966de7a9fe"
integrity sha512-RoZphVtHbxPZizt4IcILciSWiC6dcn+eZ8oX9IWEYfDMcocdd42f7NPI6fQj+6zI8y4E0L7gu2pcZKLGTRaV9Q==
"@types/mdast@^3.0.0":
version "3.0.10"
@ -4726,10 +4726,10 @@
"@types/node" "*"
form-data "^3.0.0"
"@types/node@*", "@types/node@18.x", "@types/node@^18.7.4":
version "18.7.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.4.tgz#95baa50846ae112a7376869d49fec23b2506c69d"
integrity sha512-RzRcw8c0B8LzryWOR4Wj7YOTFXvdYKwvrb6xQQyuDfnlTxwYXGCV5RZ/TEbq5L5kn+w3rliHAUyRcG1RtbmTFg==
"@types/node@*", "@types/node@18.x", "@types/node@^18.7.9":
version "18.7.9"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.9.tgz#180bfc495c91dc62573967edf047e15dbdce1491"
integrity sha512-0N5Y1XAdcl865nDdjbO0m3T6FdmQ4ijE89/urOHLREyTXbpMWbSafx9y7XIsgWGtwUP2iYTinLyyW3FatAxBLQ==
"@types/node@^14.0.10 || ^16.0.0", "@types/node@^14.14.20 || ^16.0.0":
version "16.11.41"
@ -5027,14 +5027,14 @@
dependencies:
"@typescript-eslint/utils" "5.29.0"
"@typescript-eslint/parser@^5.33.0", "@typescript-eslint/parser@^5.5.0":
version "5.33.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.33.0.tgz#26ec3235b74f0667414613727cb98f9b69dc5383"
integrity sha512-cgM5cJrWmrDV2KpvlcSkelTBASAs1mgqq+IUGKJvFxWrapHpaRy5EXPQz9YaKF3nZ8KY18ILTiVpUtbIac86/w==
"@typescript-eslint/parser@^5.33.1", "@typescript-eslint/parser@^5.5.0":
version "5.33.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.33.1.tgz#e4b253105b4d2a4362cfaa4e184e2d226c440ff3"
integrity sha512-IgLLtW7FOzoDlmaMoXdxG8HOCByTBXrB1V2ZQYSEV1ggMmJfAkMWTwUjjzagS6OkfpySyhKFkBw7A9jYmcHpZA==
dependencies:
"@typescript-eslint/scope-manager" "5.33.0"
"@typescript-eslint/types" "5.33.0"
"@typescript-eslint/typescript-estree" "5.33.0"
"@typescript-eslint/scope-manager" "5.33.1"
"@typescript-eslint/types" "5.33.1"
"@typescript-eslint/typescript-estree" "5.33.1"
debug "^4.3.4"
"@typescript-eslint/scope-manager@5.29.0":
@ -5045,14 +5045,6 @@
"@typescript-eslint/types" "5.29.0"
"@typescript-eslint/visitor-keys" "5.29.0"
"@typescript-eslint/scope-manager@5.33.0":
version "5.33.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.33.0.tgz#509d7fa540a2c58f66bdcfcf278a3fa79002e18d"
integrity sha512-/Jta8yMNpXYpRDl8EwF/M8It2A9sFJTubDo0ATZefGXmOqlaBffEw0ZbkbQ7TNDK6q55NPHFshGBPAZvZkE8Pw==
dependencies:
"@typescript-eslint/types" "5.33.0"
"@typescript-eslint/visitor-keys" "5.33.0"
"@typescript-eslint/scope-manager@5.33.1":
version "5.33.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.33.1.tgz#8d31553e1b874210018ca069b3d192c6d23bc493"
@ -5075,11 +5067,6 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.29.0.tgz#7861d3d288c031703b2d97bc113696b4d8c19aab"
integrity sha512-X99VbqvAXOMdVyfFmksMy3u8p8yoRGITgU1joBJPzeYa0rhdf5ok9S56/itRoUSh99fiDoMtarSIJXo7H/SnOg==
"@typescript-eslint/types@5.33.0":
version "5.33.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.33.0.tgz#d41c584831805554b063791338b0220b613a275b"
integrity sha512-nIMt96JngB4MYFYXpZ/3ZNU4GWPNdBbcB5w2rDOCpXOVUkhtNlG2mmm8uXhubhidRZdwMaMBap7Uk8SZMU/ppw==
"@typescript-eslint/types@5.33.1":
version "5.33.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.33.1.tgz#3faef41793d527a519e19ab2747c12d6f3741ff7"
@ -5098,19 +5085,6 @@
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/typescript-estree@5.33.0":
version "5.33.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.33.0.tgz#02d9c9ade6f4897c09e3508c27de53ad6bfa54cf"
integrity sha512-tqq3MRLlggkJKJUrzM6wltk8NckKyyorCSGMq4eVkyL5sDYzJJcMgZATqmF8fLdsWrW7OjjIZ1m9v81vKcaqwQ==
dependencies:
"@typescript-eslint/types" "5.33.0"
"@typescript-eslint/visitor-keys" "5.33.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/typescript-estree@5.33.1":
version "5.33.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.33.1.tgz#a573bd360790afdcba80844e962d8b2031984f34"
@ -5156,14 +5130,6 @@
"@typescript-eslint/types" "5.29.0"
eslint-visitor-keys "^3.3.0"
"@typescript-eslint/visitor-keys@5.33.0":
version "5.33.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.33.0.tgz#fbcbb074e460c11046e067bc3384b5d66b555484"
integrity sha512-/XsqCzD4t+Y9p5wd9HZiptuGKBlaZO5showwqODii5C0nZawxWLF+Q6k5wYHBrQv96h6GYKyqqMHCSTqta8Kiw==
dependencies:
"@typescript-eslint/types" "5.33.0"
eslint-visitor-keys "^3.3.0"
"@typescript-eslint/visitor-keys@5.33.1":
version "5.33.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.33.1.tgz#0155c7571c8cd08956580b880aea327d5c34a18b"
@ -9654,10 +9620,10 @@ fragment-cache@^0.2.1:
dependencies:
map-cache "^0.2.2"
framer-motion@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-7.1.1.tgz#4d56ed18a7cf2c6a1a4a1af5b57714f8e6b52d9e"
integrity sha512-ONFaG7as1GBBYYIqzX8ENVsfa4eh6f7/nSc3QCADAHOaCt1Lh3UdWbQ0+HVGOOORvEW2L99GlCr4wQc0GLddXg==
framer-motion@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-7.2.0.tgz#1abc8090e185eaac8a3b3729e2529154d2edcb17"
integrity sha512-D24ZHtbtdpiaByamNYiVXafVU6JfBxjrVlR1beyNupJL80haaDE23xS4dR0b/Qb64frtw/Mpdd9VYwSCv+UtSw==
dependencies:
"@motionone/dom" "10.13.1"
framesync "6.1.2"
@ -15067,10 +15033,10 @@ react-helmet-async@*, react-helmet-async@^1.3.0:
react-fast-compare "^3.2.0"
shallowequal "^1.1.0"
react-hook-form@^7.34.1:
version "7.34.1"
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.34.1.tgz#06cb216daf706bf9ae4969747115afae0d09410d"
integrity sha512-tH7TaZgAURMhjzVE2M/EFmxHz2HdaPMAVs9FXTweNW551VlhXSuVcpcYlkiMZf2zHQiTztupVFpBHJFTma+N7w==
react-hook-form@^7.34.2:
version "7.34.2"
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.34.2.tgz#9ac6d1a309a7c4aaa369d1269357a70e9e9bf4de"
integrity sha512-1lYWbEqr0GW7HHUjMScXMidGvV0BE2RJV3ap2BL7G0EJirkqpccTaawbsvBO8GZaB3JjCeFBEbnEWI1P8ZoLRQ==
react-inspector@^5.1.0:
version "5.1.1"
@ -18130,10 +18096,10 @@ vega-label@~1.2.0:
vega-scenegraph "^4.9.2"
vega-util "^1.15.2"
vega-lite@^5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/vega-lite/-/vega-lite-5.4.0.tgz#d09331e2a1c87843d5865de0fa7704919796ab56"
integrity sha512-e/P5iOtBE62WEWZhKP7sLcBd92YS9prfUQafelxoOeloooSSrkUwM/ZDmN5Q5ffByEZTiKfODtnwD6/xKDYUmw==
vega-lite@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/vega-lite/-/vega-lite-5.5.0.tgz#07345713d538cd63278748ec119c261722be66ff"
integrity sha512-MQBJt/iaUegvhRTS/hZVWfMOSF5ai4awlR2qtwTgHd84bErf9v7GtaZ9ArhJqXCb+FizvZ2jatmoYCzovgAhkg==
dependencies:
"@types/clone" "~2.1.1"
array-flat-polyfill "^1.0.1"