Only allow for finite samples from sampling library

This commit is contained in:
Ozzie Gooen 2020-04-30 11:34:59 +01:00
parent 5129ff20d5
commit 2ab2faf5e9
3 changed files with 21 additions and 8 deletions

View File

@ -19,7 +19,7 @@
"subdirs": true "subdirs": true
} }
], ],
"bsc-flags": ["-bs-super-errors", "-bs-no-version-header"], "bsc-flags": ["-bs-super-errors", "-bs-no-version-header", "-bs-g"],
"package-specs": [ "package-specs": [
{ {
"module": "commonjs", "module": "commonjs",

View File

@ -41,5 +41,6 @@ let run =
(), (),
) )
}; };
Js.log3("IS SOME?", symbolic |> E.R.toOption |> E.O.isSome, symbolic);
{symbolic: Some(symbolic), sampling}; {symbolic: Some(symbolic), sampling};
}; };

View File

@ -1,22 +1,34 @@
const _ = require("lodash"); const _ = require("lodash");
const { Guesstimator } = require('@foretold/guesstimator/src'); const {
Guesstimator
} = require('@foretold/guesstimator/src');
const stringToSamples = ( const stringToSamples = (
text, text,
sampleCount, sampleCount,
inputs = [], inputs = [],
) => { ) => {
const [_error, { parsedInput, parsedError }] = Guesstimator.parse({ text:"=" + text }); const [_error, {
parsedInput,
parsedError
}] = Guesstimator.parse({
text: "=" + text
});
const guesstimator = new Guesstimator({ parsedInput }); const guesstimator = new Guesstimator({
const {values, errors} = guesstimator.sample( parsedInput
});
const {
values,
errors
} = guesstimator.sample(
sampleCount, sampleCount,
inputs, inputs,
); );
if (errors.length > 0) { if (errors.length > 0) {
return [] return []
} else { } else {
return values return _.filter(values, _.isFinite)
} }
}; };