fixes #904. E.O.default performance
This commit is contained in:
parent
f7e6061f17
commit
5576bf2ef3
|
@ -250,7 +250,7 @@ module T = Dist({
|
||||||
|
|
||||||
let downsample = (length, t): t =>
|
let downsample = (length, t): t =>
|
||||||
t |> shapeMap(XYShape.XsConversion.proportionByProbabilityMass(length, integral(t).xyShape))
|
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 integralXtoY = (f, t: t) => t |> integral |> shapeFn(XYShape.XtoY.linear(f))
|
||||||
let integralYtoX = (f, t: t) => t |> integral |> shapeFn(XYShape.YtoX.linear(f))
|
let integralYtoX = (f, t: t) => t |> integral |> shapeFn(XYShape.YtoX.linear(f))
|
||||||
let toContinuous = t => Some(t)
|
let toContinuous = t => Some(t)
|
||||||
|
|
|
@ -158,7 +158,8 @@ module T = Dist({
|
||||||
Continuous.make(~interpolation=#Stepwise, integralShape)
|
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 minX = shapeFn(XYShape.T.minX)
|
||||||
let maxX = shapeFn(XYShape.T.maxX)
|
let maxX = shapeFn(XYShape.T.maxX)
|
||||||
let toDiscreteProbabilityMassFraction = _ => 1.0
|
let toDiscreteProbabilityMassFraction = _ => 1.0
|
||||||
|
|
|
@ -13,9 +13,11 @@ let buildSimple = (
|
||||||
~discrete: option<PointSetTypes.discreteShape>,
|
~discrete: option<PointSetTypes.discreteShape>,
|
||||||
): option<PointSetTypes.pointSetDist> => {
|
): option<PointSetTypes.pointSetDist> => {
|
||||||
let continuous =
|
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 =
|
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 cLength = continuous |> Continuous.getShape |> XYShape.T.xs |> E.A.length
|
||||||
let dLength = discrete |> Discrete.getShape |> XYShape.T.xs |> E.A.length
|
let dLength = discrete |> Discrete.getShape |> XYShape.T.xs |> E.A.length
|
||||||
switch (cLength, dLength) {
|
switch (cLength, dLength) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ let dispatch = (
|
||||||
() => ReducerInterface_Duration.dispatch(call, environment),
|
() => ReducerInterface_Duration.dispatch(call, environment),
|
||||||
() => ReducerInterface_Number.dispatch(call, environment),
|
() => ReducerInterface_Number.dispatch(call, environment),
|
||||||
() => FunctionRegistry_Library.dispatch(call, environment, reducer),
|
() => 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
|
| None => d
|
||||||
| Some(a) => a
|
| Some(a) => a
|
||||||
}
|
}
|
||||||
|
let defaultFn = (d, o) =>
|
||||||
|
switch o {
|
||||||
|
| None => d()
|
||||||
|
| Some(a) => a
|
||||||
|
}
|
||||||
let isSome = o =>
|
let isSome = o =>
|
||||||
switch o {
|
switch o {
|
||||||
| Some(_) => true
|
| Some(_) => true
|
||||||
|
@ -158,6 +163,7 @@ module O = {
|
||||||
|
|
||||||
module O2 = {
|
module O2 = {
|
||||||
let default = (a, b) => O.default(b, a)
|
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 toExn = (a, b) => O.toExn(b, a)
|
||||||
let fmap = (a, b) => O.fmap(b, a)
|
let fmap = (a, b) => O.fmap(b, a)
|
||||||
let toResult = (a, b) => O.toResult(b, a)
|
let toResult = (a, b) => O.toResult(b, a)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user