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)
})
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", () => {
let result =
run(FromDist(ToDist(ToPointSet), normalDist5))

View File

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

View File

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

View File

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