fmap -> outputmap

This commit is contained in:
Ozzie Gooen 2022-03-31 08:41:50 -04:00
parent dbac693607
commit d61f521a0e
3 changed files with 10 additions and 10 deletions

View File

@ -12,9 +12,9 @@ let normalDist20: GenericDist_Types.genericDist = #Symbolic(#Normal({mean: 20.0,
let uniformDist: GenericDist_Types.genericDist = #Symbolic(#Uniform({low: 9.0, high: 10.0}))
let {toFloat, toDist, toString, toError} = module(GenericDist_GenericOperation.Output)
let {run, fmap} = module(GenericDist_GenericOperation)
let {run, outputMap} = module(GenericDist_GenericOperation)
let run = run(params)
let fmap = fmap(params)
let outputMap = outputMap(params)
let toExt: option<'a> => 'a = E.O.toExt(
"Should be impossible to reach (This error is in test file)",
)
@ -37,7 +37,7 @@ describe("mixture", () => {
test("on two normal distributions", () => {
let result =
run(#mixture([(normalDist10, 0.5), (normalDist20, 0.5)]))
->fmap(#fromDist(#toFloat(#Mean)))
->outputMap(#fromDist(#toFloat(#Mean)))
->toFloat
->toExt
expect(result)->toBeCloseTo(15.28)
@ -48,7 +48,7 @@ describe("toPointSet", () => {
test("on symbolic normal distribution", () => {
let result =
run(#fromDist(#toDist(#toPointSet), normalDist))
->fmap(#fromDist(#toFloat(#Mean)))
->outputMap(#fromDist(#toFloat(#Mean)))
->toFloat
->toExt
expect(result)->toBeCloseTo(5.09)
@ -56,7 +56,7 @@ describe("toPointSet", () => {
test("on sample set distribution with under 4 points", () => {
let result =
run(#fromDist(#toDist(#toPointSet), #SampleSet([0.0, 1.0, 2.0, 3.0])))->fmap(
run(#fromDist(#toDist(#toPointSet), #SampleSet([0.0, 1.0, 2.0, 3.0])))->outputMap(
#fromDist(#toFloat(#Mean)),
)
expect(result)->toEqual(#GenDistError(Other("Converting sampleSet to pointSet failed")))
@ -65,9 +65,9 @@ describe("toPointSet", () => {
Skip.test("on sample set", () => {
let result =
run(#fromDist(#toDist(#toPointSet), normalDist))
->fmap(#fromDist(#toDist(#toSampleSet(1000))))
->fmap(#fromDist(#toDist(#toPointSet)))
->fmap(#fromDist(#toFloat(#Mean)))
->outputMap(#fromDist(#toDist(#toSampleSet(1000))))
->outputMap(#fromDist(#toDist(#toPointSet)))
->outputMap(#fromDist(#toFloat(#Mean)))
->toFloat
->toExt
expect(result)->toBeCloseTo(5.09)

View File

@ -135,7 +135,7 @@ let rec run = (extra, fnName: operation): outputType => {
let runFromDist = (extra, fnName, dist) => run(extra, #fromDist(fnName, dist))
let runFromFloat = (extra, fnName, float) => run(extra, #fromFloat(fnName, float))
let fmap = (
let outputMap = (
extra,
input: outputType,
fn: GenericDist_Types.Operation.singleParamaterFunction,

View File

@ -17,7 +17,7 @@ let runFromDist: (
GenericDist_Types.genericDist,
) => outputType
let runFromFloat: (params, GenericDist_Types.Operation.fromDist, float) => outputType
let fmap: (params, outputType, GenericDist_Types.Operation.singleParamaterFunction) => outputType
let outputMap: (params, outputType, GenericDist_Types.Operation.singleParamaterFunction) => outputType
module Output: {
let toDist: outputType => option<GenericDist_Types.genericDist>