Merge pull request #1226 from skejeton/sampleset-fix-error-message
SampleSet.fromList fix error message
This commit is contained in:
commit
061d785996
|
@ -182,7 +182,7 @@ describe("Peggy parse", () => {
|
||||||
"a.p1 to a.p2",
|
"a.p1 to a.p2",
|
||||||
"{(:credibleIntervalToDistribution (:$_atIndex_$ :a 'p1') (:$_atIndex_$ :a 'p2'))}",
|
"{(:credibleIntervalToDistribution (:$_atIndex_$ :a 'p1') (:$_atIndex_$ :a 'p2'))}",
|
||||||
) // lower than post
|
) // lower than post
|
||||||
testParse("1 to 2 + 3", "{(:credibleIntervalToDistribution 1 (:add 2 3))}")
|
testParse("1 to 2 + 3", "{(:credibleIntervalToDistribution 1 (:add 2 3))}")
|
||||||
testParse(
|
testParse(
|
||||||
"1->add(2) to 3->add(4) -> add(4)",
|
"1->add(2) to 3->add(4) -> add(4)",
|
||||||
"{(:credibleIntervalToDistribution (:add 1 2) (:add (:add 3 4) 4))}",
|
"{(:credibleIntervalToDistribution (:add 1 2) (:add (:add 3 4) 4))}",
|
||||||
|
|
|
@ -82,6 +82,10 @@ describe("FunctionRegistry Library", () => {
|
||||||
"SampleSet.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]}))",
|
"SampleSet.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])",
|
||||||
)
|
)
|
||||||
|
testEvalToBe(
|
||||||
|
"SampleSet.fromList([1, 2, 3])",
|
||||||
|
"Error(Error: Too few samples when constructing sample set)",
|
||||||
|
)
|
||||||
|
|
||||||
testEvalToBe("Dict.merge({a: 1, b: 2}, {b: 3, c: 4, d: 5})", "Ok({a: 1,b: 3,c: 4,d: 5})")
|
testEvalToBe("Dict.merge({a: 1, b: 2}, {b: 3, c: 4, d: 5})", "Ok({a: 1,b: 3,c: 4,d: 5})")
|
||||||
testEvalToBe(
|
testEvalToBe(
|
||||||
|
|
|
@ -4,13 +4,6 @@ module Error = {
|
||||||
type sampleSetError =
|
type sampleSetError =
|
||||||
TooFewSamples | NonNumericInput(string) | OperationError(Operation.operationError)
|
TooFewSamples | NonNumericInput(string) | OperationError(Operation.operationError)
|
||||||
|
|
||||||
let sampleSetErrorToString = (err: sampleSetError): string =>
|
|
||||||
switch err {
|
|
||||||
| TooFewSamples => "Too few samples when constructing sample set"
|
|
||||||
| NonNumericInput(err) => `Found a non-number in input: ${err}`
|
|
||||||
| OperationError(err) => Operation.Error.toString(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
@genType
|
@genType
|
||||||
type pointsetConversionError = TooFewSamplesForConversionToPointSet
|
type pointsetConversionError = TooFewSamplesForConversionToPointSet
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ let libaryBase = [
|
||||||
~run=(inputs, _, _) => {
|
~run=(inputs, _, _) => {
|
||||||
let sampleSet =
|
let sampleSet =
|
||||||
inputs->Prepare.ToTypedArray.numbers
|
inputs->Prepare.ToTypedArray.numbers
|
||||||
|> E.R2.bind(r => SampleSetDist.make(r)->E.R2.errMap(_ => "AM I HERE? WHYERE AMI??"))
|
|> E.R2.bind(r => SampleSetDist.make(r)->E.R2.errMap(SampleSetDist.Error.toString))
|
||||||
sampleSet
|
sampleSet
|
||||||
->E.R2.fmap(Wrappers.sampleSet)
|
->E.R2.fmap(Wrappers.sampleSet)
|
||||||
->E.R2.fmap(Wrappers.evDistribution)
|
->E.R2.fmap(Wrappers.evDistribution)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user