Fixed bug with namespaces
This commit is contained in:
parent
d3a12eb4e9
commit
223ddf6a3e
|
@ -60,14 +60,14 @@ describe("FunctionRegistry Library", () => {
|
||||||
)
|
)
|
||||||
testEvalToBe("Dist.logScore({estimate: normal(5,2), answer: 4.5})", "Ok(1.6433360626394853)")
|
testEvalToBe("Dist.logScore({estimate: normal(5,2), answer: 4.5})", "Ok(1.6433360626394853)")
|
||||||
testEvalToBe("Dist.klDivergence(normal(5,2), normal(5,1.5))", "Ok(0.06874342818671068)")
|
testEvalToBe("Dist.klDivergence(normal(5,2), normal(5,1.5))", "Ok(0.06874342818671068)")
|
||||||
testEvalToBe("Sampleset.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
|
testEvalToBe("SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
|
||||||
testEvalToBe("Sampleset.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
|
testEvalToBe("SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
|
||||||
testEvalToBe(
|
testEvalToBe(
|
||||||
"addOne(t)=t+1; Sampleset.toList(Sampleset.map(Sampleset.fromList([1,2,3,4,5,6]), addOne))",
|
"addOne(t)=t+1; SampleSet.toList(SampleSet.map(SampleSet.fromList([1,2,3,4,5,6]), addOne))",
|
||||||
"Ok([2,3,4,5,6,7])",
|
"Ok([2,3,4,5,6,7])",
|
||||||
)
|
)
|
||||||
testEvalToBe(
|
testEvalToBe(
|
||||||
"toList(Sampleset.mapN([Sampleset.fromList([1,2,3,4,5,6]), Sampleset.fromList([6, 5, 4, 3, 2, 1])], {|x| x[0] > x[1] ? x[0] : x[1]}))",
|
"toList(SampleSet.mapN([SampleSet.fromList([1,2,3,4,5,6]), SampleSet.fromList([6, 5, 4, 3, 2, 1])], {|x| x[0] > x[1] ? x[0] : x[1]}))",
|
||||||
"Ok([6,5,4,4,5,6])",
|
"Ok([6,5,4,4,5,6])",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
open FunctionRegistry_Core
|
open FunctionRegistry_Core
|
||||||
open FunctionRegistry_Helpers
|
open FunctionRegistry_Helpers
|
||||||
|
|
||||||
let nameSpace = "Pointset"
|
let nameSpace = "PointSet"
|
||||||
let requiresNamespace = true
|
let requiresNamespace = true
|
||||||
|
|
||||||
let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
|
let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
|
||||||
|
@ -24,57 +24,11 @@ let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
|
||||||
~name="makeContinuous",
|
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
|
||||||
~examples=[
|
|
||||||
`Pointset.makeContinuous([
|
|
||||||
{x: 0, y: 0.2},
|
|
||||||
{x: 1, y: 0.7},
|
|
||||||
{x: 2, y: 0.8},
|
|
||||||
{x: 3, y: 0.2}
|
|
||||||
])`,
|
|
||||||
],
|
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
|
||||||
~definitions=[
|
|
||||||
FnDefinition.make(
|
|
||||||
~name="makeContinuous",
|
|
||||||
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
|
||||||
~run=(_, inputs, _, _) => inputsTodist(inputs, r => Continuous(Continuous.make(r))),
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
Function.make(
|
|
||||||
~name="makeDiscrete",
|
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
|
||||||
~examples=[
|
|
||||||
`Pointset.makeDiscrete([
|
|
||||||
{x: 0, y: 0.2},
|
|
||||||
{x: 1, y: 0.7},
|
|
||||||
{x: 2, y: 0.8},
|
|
||||||
{x: 3, y: 0.2}
|
|
||||||
])`,
|
|
||||||
],
|
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
|
||||||
~definitions=[
|
|
||||||
FnDefinition.make(
|
|
||||||
~name="makeDiscrete",
|
|
||||||
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
|
||||||
~run=(_, inputs, _, _) => inputsTodist(inputs, r => Discrete(Discrete.make(r))),
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="fromDist",
|
~name="fromDist",
|
||||||
~nameSpace,
|
~nameSpace,
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~examples=[`Pointset.fromDist(normal(5,2))`],
|
~examples=[`PointSet.fromDist(normal(5,2))`],
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
|
@ -99,4 +53,50 @@ let library = [
|
||||||
],
|
],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
|
Function.make(
|
||||||
|
~name="makeContinuous",
|
||||||
|
~nameSpace,
|
||||||
|
~requiresNamespace,
|
||||||
|
~examples=[
|
||||||
|
`PointSet.makeContinuous([
|
||||||
|
{x: 0, y: 0.2},
|
||||||
|
{x: 1, y: 0.7},
|
||||||
|
{x: 2, y: 0.8},
|
||||||
|
{x: 3, y: 0.2}
|
||||||
|
])`,
|
||||||
|
],
|
||||||
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
|
~definitions=[
|
||||||
|
FnDefinition.make(
|
||||||
|
~name="makeContinuous",
|
||||||
|
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
||||||
|
~run=(_, inputs, _, _) => inputsTodist(inputs, r => Continuous(Continuous.make(r))),
|
||||||
|
(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
(),
|
||||||
|
),
|
||||||
|
Function.make(
|
||||||
|
~name="makeDiscrete",
|
||||||
|
~nameSpace,
|
||||||
|
~requiresNamespace,
|
||||||
|
~examples=[
|
||||||
|
`PointSet.makeDiscrete([
|
||||||
|
{x: 0, y: 0.2},
|
||||||
|
{x: 1, y: 0.7},
|
||||||
|
{x: 2, y: 0.8},
|
||||||
|
{x: 3, y: 0.2}
|
||||||
|
])`,
|
||||||
|
],
|
||||||
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
|
~definitions=[
|
||||||
|
FnDefinition.make(
|
||||||
|
~name="makeDiscrete",
|
||||||
|
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
||||||
|
~run=(_, inputs, _, _) => inputsTodist(inputs, r => Discrete(Discrete.make(r))),
|
||||||
|
(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
(),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
open FunctionRegistry_Core
|
open FunctionRegistry_Core
|
||||||
open FunctionRegistry_Helpers
|
open FunctionRegistry_Helpers
|
||||||
|
|
||||||
let nameSpace = "Sampleset"
|
let nameSpace = "SampleSet"
|
||||||
let requiresNamespace = true
|
let requiresNamespace = true
|
||||||
|
|
||||||
module Internal = {
|
module Internal = {
|
||||||
|
@ -69,7 +69,7 @@ let library = [
|
||||||
~name="fromDist",
|
~name="fromDist",
|
||||||
~nameSpace,
|
~nameSpace,
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~examples=[`Sampleset.fromDist(normal(5,2))`],
|
~examples=[`SampleSet.fromDist(normal(5,2))`],
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
|
@ -93,7 +93,7 @@ let library = [
|
||||||
~name="fromList",
|
~name="fromList",
|
||||||
~nameSpace,
|
~nameSpace,
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~examples=[`Sampleset.fromList([3,5,2,3,5,2,3,5,2,3,3,5,3,2,3,1,1,3])`],
|
~examples=[`SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5,3,2,3,1,1,3])`],
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
|
@ -115,7 +115,7 @@ let library = [
|
||||||
~name="toList",
|
~name="toList",
|
||||||
~nameSpace,
|
~nameSpace,
|
||||||
~requiresNamespace=false,
|
~requiresNamespace=false,
|
||||||
~examples=[`Sampleset.toList(Sampleset.fromDist(normal(5,2)))`],
|
~examples=[`SampleSet.toList(SampleSet.fromDist(normal(5,2)))`],
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtArray,
|
~output=ReducerInterface_InternalExpressionValue.EvtArray,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
|
@ -136,7 +136,7 @@ let library = [
|
||||||
~name="map",
|
~name="map",
|
||||||
~nameSpace,
|
~nameSpace,
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~examples=[`Sampleset.map(Sampleset.fromDist(normal(5,2)), {|x| x + 1})`],
|
~examples=[`SampleSet.map(SampleSet.fromDist(normal(5,2)), {|x| x + 1})`],
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
|
@ -158,7 +158,7 @@ let library = [
|
||||||
~nameSpace,
|
~nameSpace,
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~examples=[
|
~examples=[
|
||||||
`Sampleset.map2(Sampleset.fromDist(normal(5,2)), Sampleset.fromDist(normal(5,2)), {|x, y| x + y})`,
|
`SampleSet.map2(SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y| x + y})`,
|
||||||
],
|
],
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
|
@ -186,7 +186,7 @@ let library = [
|
||||||
~nameSpace,
|
~nameSpace,
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~examples=[
|
~examples=[
|
||||||
`Sampleset.map3(Sampleset.fromDist(normal(5,2)), Sampleset.fromDist(normal(5,2)), Sampleset.fromDist(normal(5,2)), {|x, y, z| max([x,y,z])})`,
|
`SampleSet.map3(SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y, z| max([x,y,z])})`,
|
||||||
],
|
],
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
|
@ -214,7 +214,7 @@ let library = [
|
||||||
~nameSpace,
|
~nameSpace,
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~examples=[
|
~examples=[
|
||||||
`Sampleset.mapN([Sampleset.fromDist(normal(5,2)), Sampleset.fromDist(normal(5,2)), Sampleset.fromDist(normal(5,2))], {|x| max(x)})`,
|
`SampleSet.mapN([SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2))], {|x| max(x)})`,
|
||||||
],
|
],
|
||||||
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
~output=ReducerInterface_InternalExpressionValue.EvtDistribution,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user