Merge pull request #905 from quantified-uncertainty/issue-904
fixes #904. E.O.default performance
This commit is contained in:
commit
4e2f0d1413
|
@ -250,7 +250,7 @@ module T = Dist({
|
|||
|
||||
let downsample = (length, t): t =>
|
||||
t |> shapeMap(XYShape.XsConversion.proportionByProbabilityMass(length, integral(t).xyShape))
|
||||
let integralEndY = (t: t) => t.integralSumCache |> E.O.default(t |> integral |> lastY)
|
||||
let integralEndY = (t: t) => t.integralSumCache |> E.O.defaultFn(() => t |> integral |> lastY)
|
||||
let integralXtoY = (f, t: t) => t |> integral |> shapeFn(XYShape.XtoY.linear(f))
|
||||
let integralYtoX = (f, t: t) => t |> integral |> shapeFn(XYShape.YtoX.linear(f))
|
||||
let toContinuous = t => Some(t)
|
||||
|
|
|
@ -158,7 +158,8 @@ module T = Dist({
|
|||
Continuous.make(~interpolation=#Stepwise, integralShape)
|
||||
}
|
||||
|
||||
let integralEndY = (t: t) => t.integralSumCache |> E.O.default(t |> integral |> Continuous.lastY)
|
||||
let integralEndY = (t: t) =>
|
||||
t.integralSumCache |> E.O.defaultFn(() => t |> integral |> Continuous.lastY)
|
||||
let minX = shapeFn(XYShape.T.minX)
|
||||
let maxX = shapeFn(XYShape.T.maxX)
|
||||
let toDiscreteProbabilityMassFraction = _ => 1.0
|
||||
|
|
|
@ -13,9 +13,11 @@ let buildSimple = (
|
|||
~discrete: option<PointSetTypes.discreteShape>,
|
||||
): option<PointSetTypes.pointSetDist> => {
|
||||
let continuous =
|
||||
continuous |> E.O.default(Continuous.make(~integralSumCache=Some(0.0), {xs: [], ys: []}))
|
||||
continuous |> E.O.defaultFn(() =>
|
||||
Continuous.make(~integralSumCache=Some(0.0), {xs: [], ys: []})
|
||||
)
|
||||
let discrete =
|
||||
discrete |> E.O.default(Discrete.make(~integralSumCache=Some(0.0), {xs: [], ys: []}))
|
||||
discrete |> E.O.defaultFn(() => Discrete.make(~integralSumCache=Some(0.0), {xs: [], ys: []}))
|
||||
let cLength = continuous |> Continuous.getShape |> XYShape.T.xs |> E.A.length
|
||||
let dLength = discrete |> Discrete.getShape |> XYShape.T.xs |> E.A.length
|
||||
switch (cLength, dLength) {
|
||||
|
|
|
@ -16,7 +16,7 @@ let dispatch = (
|
|||
() => ReducerInterface_Duration.dispatch(call, environment),
|
||||
() => ReducerInterface_Number.dispatch(call, environment),
|
||||
() => FunctionRegistry_Library.dispatch(call, environment, reducer),
|
||||
])->E.O2.default(chain(call, environment, reducer))
|
||||
])->E.O2.defaultFn(() => chain(call, environment, reducer))
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -82,6 +82,11 @@ module O = {
|
|||
| None => d
|
||||
| Some(a) => a
|
||||
}
|
||||
let defaultFn = (d, o) =>
|
||||
switch o {
|
||||
| None => d()
|
||||
| Some(a) => a
|
||||
}
|
||||
let isSome = o =>
|
||||
switch o {
|
||||
| Some(_) => true
|
||||
|
@ -158,6 +163,7 @@ module O = {
|
|||
|
||||
module O2 = {
|
||||
let default = (a, b) => O.default(b, a)
|
||||
let defaultFn = (a, b) => O.defaultFn(b, a)
|
||||
let toExn = (a, b) => O.toExn(b, a)
|
||||
let fmap = (a, b) => O.fmap(b, a)
|
||||
let toResult = (a, b) => O.toResult(b, a)
|
||||
|
|
Loading…
Reference in New Issue
Block a user