Only allow for finite samples from sampling library
This commit is contained in:
parent
5129ff20d5
commit
2ab2faf5e9
|
@ -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",
|
||||||
|
|
|
@ -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};
|
||||||
};
|
};
|
|
@ -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)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user