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
}
],
"bsc-flags": ["-bs-super-errors", "-bs-no-version-header"],
"bsc-flags": ["-bs-super-errors", "-bs-no-version-header", "-bs-g"],
"package-specs": [
{
"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};
};

View File

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