This commit is contained in:
Quinn Dougherty 2022-04-06 15:19:27 -04:00
parent 952ce9da11
commit 3bed89b558
6 changed files with 647 additions and 541 deletions

View File

@ -17,3 +17,5 @@ yarn-error.log
*.gen.tsx
*.gen.js
dist
*.coverage
_coverage

View File

@ -6,7 +6,7 @@ let env: DistributionOperation.env = {
xyPointLength: 100,
}
let normalDist: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 5.0, stdev: 2.0}))
let normalDist5: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 5.0, stdev: 2.0}))
let normalDist10: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 10.0, stdev: 2.0}))
let normalDist20: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 20.0, stdev: 2.0}))
let uniformDist: GenericDist_Types.genericDist = Symbolic(#Uniform({low: 9.0, high: 10.0}))
@ -22,14 +22,14 @@ let toExt: option<'a> => 'a = E.O.toExt(
describe("normalize", () => {
test("has no impact on normal dist", () => {
let result = run(FromDist(ToDist(Normalize), normalDist))
expect(result)->toEqual(Dist(normalDist))
let result = run(FromDist(ToDist(Normalize), normalDist5))
expect(result)->toEqual(Dist(normalDist5))
})
})
describe("mean", () => {
test("for a normal distribution", () => {
let result = DistributionOperation.run(~env, FromDist(ToFloat(#Mean), normalDist))
let result = DistributionOperation.run(~env, FromDist(ToFloat(#Mean), normalDist5))
expect(result)->toEqual(Float(5.0))
})
})
@ -48,7 +48,7 @@ describe("mixture", () => {
describe("toPointSet", () => {
test("on symbolic normal distribution", () => {
let result =
run(FromDist(ToDist(ToPointSet), normalDist))
run(FromDist(ToDist(ToPointSet), normalDist5))
->outputMap(FromDist(ToFloat(#Mean)))
->toFloat
->toExt
@ -65,7 +65,7 @@ describe("toPointSet", () => {
Skip.test("on sample set", () => {
let result =
run(FromDist(ToDist(ToPointSet), normalDist))
run(FromDist(ToDist(ToPointSet), normalDist5))
->outputMap(FromDist(ToDist(ToSampleSet(1000))))
->outputMap(FromDist(ToDist(ToPointSet)))
->outputMap(FromDist(ToFloat(#Mean)))

View File

@ -1,6 +1,5 @@
{
"name": "@quri/squiggle-lang",
"reason": {},
"sources": [
{
"dir": "src/rescript",
@ -28,7 +27,8 @@
"bs-dependencies": [
"@glennsl/rescript-jest",
"@glennsl/bs-json",
"rationale"
"rationale",
"bisect_ppx"
],
"gentypeconfig": {
"language": "typescript",
@ -43,5 +43,11 @@
"warnings": {
"number": "+A-42-48-9-30-4-102-20-27-41"
},
"ppx-flags": []
"ppx-flags": [
[
"../../node_modules/bisect_ppx/ppx",
"--exclude-files",
".*_Test\\.res$$"
]
]
}

View File

@ -2,4 +2,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFilesAfterEnv: [
"<rootdir>/../../node_modules/bisect_ppx/src/runtime/js/jest.bs.js"
],
};

View File

@ -10,6 +10,7 @@
"test:reducer": "jest --testPathPattern '.*__tests__/Reducer.*'",
"test": "jest",
"test:watch": "jest --watchAll",
"coverage": "rm -f *.coverage; yarn clean; BISECT_ENABLE=yes yarn build; yarn test; ./node_modules/.bin/bisect-ppx-report html",
"all": "yarn build && yarn bundle && yarn test"
},
"keywords": [
@ -24,7 +25,8 @@
"mathjs": "10.4.1",
"pdfast": "^0.2.0",
"rationale": "0.2.0",
"rescript": "^9.1.4"
"rescript": "^9.1.4",
"bisect_ppx": "^2.7.1"
},
"devDependencies": {
"@glennsl/rescript-jest": "^0.9.0",
@ -38,7 +40,7 @@
"ts-loader": "^9.2.8",
"typescript": "^4.6.3",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2"
"webpack-cli": "^4.9.2"
},
"source": "./src/js/index.ts",
"main": "./dist/bundle.js",

1153
yarn.lock

File diff suppressed because it is too large Load Diff