From c5e30f068a1735d5cc7fb6a503a780fc2c0cb45c Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Tue, 11 Sep 2018 16:22:08 +0200 Subject: [PATCH] :sparkles: Added sampling of list options --- src/pattern.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/pattern.js b/src/pattern.js index b324591cd96..a4de07f2938 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -147,6 +147,10 @@ Pattern.prototype.sampleOption = function(optionName) { let anchors = {}; let parts = this.sampleParts(); let option = this.config.options[optionName]; + if (typeof option.list === "object") { + console.log("sampling list"); + return this.sampleListOption(optionName); + } if (typeof option.min === "undefined" || typeof option.max === "undefined") { let min = option * 0.9; let max = option * 1.1; @@ -169,6 +173,25 @@ Pattern.prototype.sampleOption = function(optionName) { return this; }; +Pattern.prototype.sampleListOption = function(optionName) { + let parts = this.sampleParts(); + let option = this.config.options[optionName]; + let anchors = {}; + let count = 1; + for (let val of option.list) { + this.options[optionName] = val; + this.debug( + debugStyle("info", "🔬 Sample run"), + `Sampling option ${optionName} with value ${round(val)}` + ); + this.sampleRun(parts, anchors, count); + count++; + } + this.parts = parts; + + return this; +}; + /** * Handles measurement sampling */