From 2ab2faf5e91074343c7fa3d76c29d9e563ad63a7 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Thu, 30 Apr 2020 11:34:59 +0100 Subject: [PATCH] Only allow for finite samples from sampling library --- bsconfig.json | 2 +- src/distPlus/renderers/ShapeRenderer.re | 1 + .../samplesRenderer/GuesstimatorLibrary.js | 26 ++++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/bsconfig.json b/bsconfig.json index 7661e312..8de81a25 100644 --- a/bsconfig.json +++ b/bsconfig.json @@ -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", diff --git a/src/distPlus/renderers/ShapeRenderer.re b/src/distPlus/renderers/ShapeRenderer.re index 183bd6fa..c6f3dc0e 100644 --- a/src/distPlus/renderers/ShapeRenderer.re +++ b/src/distPlus/renderers/ShapeRenderer.re @@ -41,5 +41,6 @@ let run = (), ) }; + Js.log3("IS SOME?", symbolic |> E.R.toOption |> E.O.isSome, symbolic); {symbolic: Some(symbolic), sampling}; }; \ No newline at end of file diff --git a/src/distPlus/renderers/samplesRenderer/GuesstimatorLibrary.js b/src/distPlus/renderers/samplesRenderer/GuesstimatorLibrary.js index 4e8e7b09..4db90a59 100644 --- a/src/distPlus/renderers/samplesRenderer/GuesstimatorLibrary.js +++ b/src/distPlus/renderers/samplesRenderer/GuesstimatorLibrary.js @@ -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, -}; +}; \ No newline at end of file