Cleanup from previous refactor

This commit is contained in:
Ozzie Gooen 2022-04-09 20:27:03 -04:00
parent fa3d874a4e
commit f17a842c52
4 changed files with 15 additions and 21 deletions

View File

@ -90,15 +90,6 @@ describe("toPointSet", () => {
expect(result)->toBeSoCloseTo(5.0, ~digits=0) expect(result)->toBeSoCloseTo(5.0, ~digits=0)
}) })
test("on sample set distribution with under 4 points", () => {
let sampleSet = SampleSetDist.make([0.0, 1.0, 2.0, 3.0]) -> E.R.toExn;
let result =
run(FromDist(ToDist(ToPointSet), SampleSet(sampleSet)))->outputMap(
FromDist(ToFloat(#Mean)),
)
expect(result)->toEqual(GenDistError(Other("Converting sampleSet to pointSet failed")))
})
test("on sample set", () => { test("on sample set", () => {
let result = let result =
run(FromDist(ToDist(ToPointSet), normalDist5)) run(FromDist(ToDist(ToPointSet), normalDist5))

View File

@ -65,7 +65,7 @@ let toPointSet = (
| PointSet(pointSet) => Ok(pointSet) | PointSet(pointSet) => Ok(pointSet)
| Symbolic(r) => Ok(SymbolicDist.T.toPointSetDist(~xSelection, xyPointLength, r)) | Symbolic(r) => Ok(SymbolicDist.T.toPointSetDist(~xSelection, xyPointLength, r))
| SampleSet(r) => | SampleSet(r) =>
SampleSetDist.toPointSetDist2( SampleSetDist.toPointSetDist(
~samples=r, ~samples=r,
~samplingInputs={ ~samplingInputs={
sampleCount: sampleCount, sampleCount: sampleCount,

View File

@ -15,14 +15,18 @@ module T: {
include T include T
let length = (t:t) => get(t) |> E.A.length; let length = (t: t) => get(t) |> E.A.length
// TODO: Refactor to raise correct error when not enough samples // TODO: Refactor to get error in the toPointSetDist function, instead of adding at very end.
let toPointSetDist = (~samples: t, ~samplingInputs: SamplingInputs.samplingInputs, ()) => let toPointSetDist = (~samples: t, ~samplingInputs: SamplingInputs.samplingInputs, ()): result<
SampleSetDist_ToPointSet.toPointSetDist(~samples=get(samples), ~samplingInputs, ()) PointSetTypes.pointSetDist,
string,
let toPointSetDist2 = (~samples: t, ~samplingInputs: SamplingInputs.samplingInputs, ()) => > =>
SampleSetDist_ToPointSet.toPointSetDist(~samples=get(samples), ~samplingInputs, ()).pointSetDist |> E.O.toResult("Failed to convert to PointSetDist") SampleSetDist_ToPointSet.toPointSetDist(
~samples=get(samples),
~samplingInputs,
(),
).pointSetDist |> E.O.toResult("Failed to convert to PointSetDist")
//Randomly get one sample from the distribution //Randomly get one sample from the distribution
let sample = (t: t): float => { let sample = (t: t): float => {

View File

@ -224,9 +224,8 @@ module SamplingDistribution = {
let pointSetDist = let pointSetDist =
sampleSetDist sampleSetDist
-> E.R2.fmap(r => -> E.R.bind(r =>
SampleSetDist.toPointSetDist(~samplingInputs=evaluationParams.samplingInputs, ~samples=r, ())) SampleSetDist.toPointSetDist(~samplingInputs=evaluationParams.samplingInputs, ~samples=r, ()));
-> E.R.bind(r => r.pointSetDist |> E.O.toResult("combineShapesUsingSampling Error"))
pointSetDist |> E.R.fmap(r => #Normalize(#RenderedDist(r))) pointSetDist |> E.R.fmap(r => #Normalize(#RenderedDist(r)))
}) })
} }