From 223ddf6a3e7f9518a9b9102ef7808eb6823507f8 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Thu, 21 Jul 2022 08:54:41 -0700 Subject: [PATCH] Fixed bug with namespaces --- ...leLibrary_FunctionRegistryLibrary_test.res | 8 +- .../FunctionRegistry/Library/FR_Pointset.res | 96 +++++++++---------- .../FunctionRegistry/Library/FR_Sampleset.res | 16 ++-- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res index 7a1564f7..da357653 100644 --- a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res +++ b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res @@ -60,14 +60,14 @@ describe("FunctionRegistry Library", () => { ) 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("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( - "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])", ) 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])", ) }) diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Pointset.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Pointset.res index 1a4569f4..4f4e1731 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Pointset.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Pointset.res @@ -1,7 +1,7 @@ open FunctionRegistry_Core open FunctionRegistry_Helpers -let nameSpace = "Pointset" +let nameSpace = "PointSet" let requiresNamespace = true let inputsTodist = (inputs: array, makeDist) => { @@ -24,57 +24,11 @@ let inputsTodist = (inputs: array, makeDist) => { } 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( ~name="fromDist", ~nameSpace, ~requiresNamespace=true, - ~examples=[`Pointset.fromDist(normal(5,2))`], + ~examples=[`PointSet.fromDist(normal(5,2))`], ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~definitions=[ 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))), + (), + ), + ], + (), + ), ] diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Sampleset.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Sampleset.res index 85497f8d..a13ff46c 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Sampleset.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Sampleset.res @@ -1,7 +1,7 @@ open FunctionRegistry_Core open FunctionRegistry_Helpers -let nameSpace = "Sampleset" +let nameSpace = "SampleSet" let requiresNamespace = true module Internal = { @@ -69,7 +69,7 @@ let library = [ ~name="fromDist", ~nameSpace, ~requiresNamespace=true, - ~examples=[`Sampleset.fromDist(normal(5,2))`], + ~examples=[`SampleSet.fromDist(normal(5,2))`], ~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~definitions=[ FnDefinition.make( @@ -93,7 +93,7 @@ let library = [ ~name="fromList", ~nameSpace, ~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, ~definitions=[ FnDefinition.make( @@ -115,7 +115,7 @@ let library = [ ~name="toList", ~nameSpace, ~requiresNamespace=false, - ~examples=[`Sampleset.toList(Sampleset.fromDist(normal(5,2)))`], + ~examples=[`SampleSet.toList(SampleSet.fromDist(normal(5,2)))`], ~output=ReducerInterface_InternalExpressionValue.EvtArray, ~definitions=[ FnDefinition.make( @@ -136,7 +136,7 @@ let library = [ ~name="map", ~nameSpace, ~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, ~definitions=[ FnDefinition.make( @@ -158,7 +158,7 @@ let library = [ ~nameSpace, ~requiresNamespace, ~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, ~definitions=[ @@ -186,7 +186,7 @@ let library = [ ~nameSpace, ~requiresNamespace, ~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, ~definitions=[ @@ -214,7 +214,7 @@ let library = [ ~nameSpace, ~requiresNamespace, ~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, ~definitions=[