Clean up types from Samples.re
This commit is contained in:
parent
d2a17f9f1a
commit
9b7f2f246d
|
@ -61,16 +61,10 @@ let combineShapesUsingSampling =
|
||||||
samples
|
samples
|
||||||
|> E.O.fmap(
|
|> E.O.fmap(
|
||||||
Samples.T.fromSamples(
|
Samples.T.fromSamples(
|
||||||
~samplingInputs={
|
~samplingInputs=evaluationParams.samplingInputs,
|
||||||
sampleCount:
|
|
||||||
Some(evaluationParams.samplingInputs.sampleCount),
|
|
||||||
outputXYPoints:
|
|
||||||
Some(evaluationParams.samplingInputs.outputXYPoints),
|
|
||||||
kernelWidth: evaluationParams.samplingInputs.kernelWidth,
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|> E.O.bind(_, (r) => r.shape)
|
|> E.O.bind(_, r => r.shape)
|
||||||
|> E.O.toResult("No response");
|
|> E.O.toResult("No response");
|
||||||
shape |> E.R.fmap(r => `Normalize(`RenderedDist(r)));
|
shape |> E.R.fmap(r => `Normalize(`RenderedDist(r)));
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// TODO: This setup is more confusing than it should be, there's more work to do in cleanup here.
|
// TODO: This setup is more confusing than it should be, there's more work to do in cleanup here.
|
||||||
|
|
||||||
module Inputs = {
|
module Inputs = {
|
||||||
let defaultRecommendedLength = 10000;
|
let defaultRecommendedLength = 10000;
|
||||||
let defaultShouldDownsample = true;
|
let defaultShouldDownsample = true;
|
||||||
|
@ -30,9 +29,15 @@ module Inputs = {
|
||||||
recommendedLength: int,
|
recommendedLength: int,
|
||||||
inputVariables: Belt.Map.String.t(ExpressionTypes.ExpressionTree.node),
|
inputVariables: Belt.Map.String.t(ExpressionTypes.ExpressionTree.node),
|
||||||
};
|
};
|
||||||
|
let empty: RenderTypes.ShapeRenderer.Sampling.inputs = {
|
||||||
|
sampleCount: None,
|
||||||
|
outputXYPoints: None,
|
||||||
|
kernelWidth: None,
|
||||||
|
};
|
||||||
|
|
||||||
let make =
|
let make =
|
||||||
(
|
(
|
||||||
~samplingInputs=RenderTypes.ShapeRenderer.Sampling.Inputs.empty,
|
~samplingInputs=empty,
|
||||||
~recommendedLength=defaultRecommendedLength,
|
~recommendedLength=defaultRecommendedLength,
|
||||||
~distPlusIngredients,
|
~distPlusIngredients,
|
||||||
~inputVariables=[||]->Belt.Map.String.fromArray,
|
~inputVariables=[||]->Belt.Map.String.fromArray,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
module MS = Belt.Map.String;
|
|
||||||
|
|
||||||
module ShapeRenderer = {
|
module ShapeRenderer = {
|
||||||
module Sampling = {
|
module Sampling = {
|
||||||
type inputs = {
|
type inputs = {
|
||||||
|
@ -7,27 +5,12 @@ module ShapeRenderer = {
|
||||||
outputXYPoints: option(int),
|
outputXYPoints: option(int),
|
||||||
kernelWidth: option(float),
|
kernelWidth: option(float),
|
||||||
};
|
};
|
||||||
module Inputs = {
|
|
||||||
let defaultSampleCount = 10000;
|
|
||||||
let defaultOutputXYPoints = 10000;
|
|
||||||
let empty = {
|
|
||||||
sampleCount: None,
|
|
||||||
outputXYPoints: None,
|
|
||||||
kernelWidth: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
type fInputs = {
|
let defaults = {
|
||||||
sampleCount: int,
|
sampleCount: Some(10000),
|
||||||
outputXYPoints: int,
|
outputXYPoints: Some(1000),
|
||||||
kernelWidth: option(float),
|
kernelWidth: None
|
||||||
};
|
}
|
||||||
let toF = (i: inputs): fInputs => {
|
|
||||||
sampleCount: i.sampleCount |> E.O.default(defaultSampleCount),
|
|
||||||
outputXYPoints:
|
|
||||||
i.outputXYPoints |> E.O.default(defaultOutputXYPoints),
|
|
||||||
kernelWidth: i.kernelWidth,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module Symbolic = {
|
module Symbolic = {
|
||||||
|
|
|
@ -1,13 +1,4 @@
|
||||||
module Types = {
|
module Types = {
|
||||||
let defaultSampleCount = 5000;
|
|
||||||
let defaultOutputXYPoints = 10000;
|
|
||||||
|
|
||||||
type inputs = {
|
|
||||||
sampleCount: option(int),
|
|
||||||
outputXYPoints: option(int),
|
|
||||||
kernelWidth: option(float),
|
|
||||||
};
|
|
||||||
|
|
||||||
type samplingStats = {
|
type samplingStats = {
|
||||||
sampleCount: int,
|
sampleCount: int,
|
||||||
outputXYPoints: int,
|
outputXYPoints: int,
|
||||||
|
@ -21,20 +12,6 @@ module Types = {
|
||||||
continuousParseParams: option(samplingStats),
|
continuousParseParams: option(samplingStats),
|
||||||
shape: option(DistTypes.shape),
|
shape: option(DistTypes.shape),
|
||||||
};
|
};
|
||||||
|
|
||||||
let empty = {sampleCount: None, outputXYPoints: None, kernelWidth: None};
|
|
||||||
|
|
||||||
type fInputs = {
|
|
||||||
sampleCount: int,
|
|
||||||
outputXYPoints: int,
|
|
||||||
kernelWidth: option(float),
|
|
||||||
};
|
|
||||||
|
|
||||||
let toF = (i: inputs): fInputs => {
|
|
||||||
sampleCount: i.sampleCount |> E.O.default(defaultSampleCount),
|
|
||||||
outputXYPoints: i.outputXYPoints |> E.O.default(defaultOutputXYPoints),
|
|
||||||
kernelWidth: i.kernelWidth,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module JS = {
|
module JS = {
|
||||||
|
@ -112,12 +89,7 @@ module T = {
|
||||||
KDE.normalSampling(samples, outputXYPoints, width);
|
KDE.normalSampling(samples, outputXYPoints, width);
|
||||||
};
|
};
|
||||||
|
|
||||||
let toShape =
|
let toShape = (~samples: t, ~samplingInputs: ExpressionTypes.ExpressionTree.samplingInputs, ()) => {
|
||||||
(
|
|
||||||
~samples: t,
|
|
||||||
~samplingInputs: Types.fInputs,
|
|
||||||
(),
|
|
||||||
) => {
|
|
||||||
Array.fast_sort(compare, samples);
|
Array.fast_sort(compare, samples);
|
||||||
let (continuousPart, discretePart) = E.A.Sorted.Floats.split(samples);
|
let (continuousPart, discretePart) = E.A.Sorted.Floats.split(samples);
|
||||||
let length = samples |> E.A.length |> float_of_int;
|
let length = samples |> E.A.length |> float_of_int;
|
||||||
|
@ -143,7 +115,7 @@ module T = {
|
||||||
samplingInputs.outputXYPoints,
|
samplingInputs.outputXYPoints,
|
||||||
usedWidth,
|
usedWidth,
|
||||||
);
|
);
|
||||||
let foo: Types.samplingStats = {
|
let samplingStats: Types.samplingStats = {
|
||||||
sampleCount: samplingInputs.sampleCount,
|
sampleCount: samplingInputs.sampleCount,
|
||||||
outputXYPoints: samplingInputs.outputXYPoints,
|
outputXYPoints: samplingInputs.outputXYPoints,
|
||||||
bandwidthXSuggested: _suggestedXWidth,
|
bandwidthXSuggested: _suggestedXWidth,
|
||||||
|
@ -158,28 +130,25 @@ module T = {
|
||||||
formatUnitWidth(usedUnitWidth),
|
formatUnitWidth(usedUnitWidth),
|
||||||
)
|
)
|
||||||
|> Continuous.make
|
|> Continuous.make
|
||||||
|> (r => Some((r, foo)));
|
|> (r => Some((r, samplingStats)));
|
||||||
}
|
}
|
||||||
: None;
|
: None;
|
||||||
|
|
||||||
let shape =
|
let shape =
|
||||||
MixedShapeBuilder.buildSimple(
|
MixedShapeBuilder.buildSimple(
|
||||||
~continuous=pdf |> E.O.fmap(fst),
|
~continuous=pdf |> E.O.fmap(fst),
|
||||||
~discrete=Some(discrete),
|
~discrete=Some(discrete),
|
||||||
);
|
);
|
||||||
|
|
||||||
let samplesParse: Types.outputs = {
|
let samplesParse: Types.outputs = {
|
||||||
continuousParseParams: pdf |> E.O.fmap(snd),
|
continuousParseParams: pdf |> E.O.fmap(snd),
|
||||||
shape,
|
shape,
|
||||||
};
|
};
|
||||||
|
|
||||||
samplesParse;
|
samplesParse;
|
||||||
};
|
};
|
||||||
|
|
||||||
let fromSamples =
|
let fromSamples = (~samplingInputs, samples) => {
|
||||||
(
|
|
||||||
~samplingInputs=Types.empty,
|
|
||||||
samples,
|
|
||||||
) => {
|
|
||||||
let samplingInputs =
|
|
||||||
Types.toF(samplingInputs);
|
|
||||||
toShape(~samples, ~samplingInputs, ());
|
toShape(~samples, ~samplingInputs, ());
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user