@sjcrh/proteinpaint-shared 2.190.0 → 2.190.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/termdb.bins.js
CHANGED
|
@@ -90,10 +90,13 @@ function validate_bins(binconfig) {
|
|
|
90
90
|
throw `invalid binconfig.type="${bc.type}"`;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
const maxNumBins = 100;
|
|
93
94
|
function compute_bins(binconfig, summaryfxn, valueConversion) {
|
|
94
95
|
const bc = binconfig;
|
|
95
96
|
validate_bins(bc);
|
|
96
97
|
if (bc.lst) {
|
|
98
|
+
if (!Array.isArray(bc.lst)) throw `bc.lst is not an array`;
|
|
99
|
+
if (bc.lst.length > maxNumBins) throw `bc.lst exceed the maximum of ${maxNumBins} allowed entries`;
|
|
97
100
|
const k2c2 = getColors(bc.lst.length);
|
|
98
101
|
for (const bin of bc.lst) bin.color = k2c2(bin.label);
|
|
99
102
|
}
|
|
@@ -134,7 +137,6 @@ function compute_bins(binconfig, summaryfxn, valueConversion) {
|
|
|
134
137
|
stopinclusive: bc.stopinclusive
|
|
135
138
|
};
|
|
136
139
|
if (!isStrictNumeric(currBin.stop)) throw "the computed first_bin.stop is non-numeric" + currBin.stop;
|
|
137
|
-
const maxNumBins = 100;
|
|
138
140
|
while (numericMax && currBin.stop <= max || currBin.startunbounded && !bins.length || currBin.stopunbounded) {
|
|
139
141
|
bins.push(currBin);
|
|
140
142
|
if (currBin.stop >= max) {
|
|
@@ -167,7 +169,12 @@ function compute_bins(binconfig, summaryfxn, valueConversion) {
|
|
|
167
169
|
else break;
|
|
168
170
|
}
|
|
169
171
|
if (bins.length + 1 >= maxNumBins) {
|
|
170
|
-
|
|
172
|
+
delete currBin.stop;
|
|
173
|
+
currBin.stopunbounded = true;
|
|
174
|
+
currBin.label = get_bin_label(currBin, bc, valueConversion);
|
|
175
|
+
if (!bins.includes(currBin)) bins.push(currBin);
|
|
176
|
+
const hint = "Please increase the bin_size or first bin stop, or have a lower last bin start.";
|
|
177
|
+
bc.error = hint + " (max_num_bins_reached)";
|
|
171
178
|
break;
|
|
172
179
|
}
|
|
173
180
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/termdb.bins.ts"],
|
|
4
|
-
"sourcesContent": ["import { format } from 'd3-format'\nimport { getColors } from './common.js'\nimport { isNumeric, isStrictNumeric, convertUnits } from './helpers.js'\n\nexport default function validate_bins(binconfig) {\n\t// Number.isFinite('1') returns false, which is desired\n\n\tconst bc = binconfig\n\tif (!bc || typeof bc !== 'object') throw 'bin schema must be an object'\n\t// assign default type\n\tif (!('type' in bc)) bc.type = 'regular-bin'\n\n\tif (bc.type == 'custom-bin') {\n\t\tif (!Array.isArray(bc.lst)) throw 'binconfig.lst must be an array'\n\t\tif (!bc.lst.length) throw 'binconfig.lst must have entries'\n\t\tconst first_bin = bc.lst[0]\n\t\tconst last_bin = bc.lst[bc.lst.length - 1]\n\n\t\tfor (const bin of bc.lst) {\n\t\t\tif (!('startinclusive' in bin) && !('stopinclusive' in bin)) {\n\t\t\t\tthrow 'custom bin.startinclusive and/or bin.stopinclusive must be defined'\n\t\t\t}\n\n\t\t\tif (bin == first_bin) {\n\t\t\t\tif ('startunbounded' in bin && !bin.startunbounded) {\n\t\t\t\t\tthrow `a custom first bin must not set bin.startunbounded to false`\n\t\t\t\t}\n\t\t\t\tbin.startunbounded = true\n\t\t\t\tif ('start' in bin) {\n\t\t\t\t\tthrow 'a custom first bin must not set a bin.start value'\n\t\t\t\t}\n\t\t\t\tif ('start_percentile' in bin) {\n\t\t\t\t\tthrow 'the first bin must not set a bin.start_percentile value'\n\t\t\t\t}\n\t\t\t\tif (!('stop' in bin)) {\n\t\t\t\t\tthrow `a custom first bin must define a bin.stop value`\n\t\t\t\t}\n\t\t\t\tif (!isStrictNumeric(bin.stop)) {\n\t\t\t\t\tthrow `a custom first bin.stop value should be numeric`\n\t\t\t\t}\n\t\t\t} else if (bin == last_bin) {\n\t\t\t\tif (!('start' in bin)) {\n\t\t\t\t\tthrow `a custom last bin must define a bin.start value`\n\t\t\t\t}\n\t\t\t\tif (!isStrictNumeric(bin.start)) {\n\t\t\t\t\tthrow `a custom last bin.start must be numeric`\n\t\t\t\t}\n\t\t\t\tif ('stopunbounded' in bin && !bin.stopunbounded) {\n\t\t\t\t\tthrow 'a custom last bin must not set bin.stopunbounded to false'\n\t\t\t\t}\n\t\t\t\tbin.stopunbounded = true\n\t\t\t\tif ('stop' in bin) {\n\t\t\t\t\tthrow 'a custom last bin must not set a bin.stop value'\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (bin.startunbounded || bin.stopunbounded) {\n\t\t\t\t\tthrow 'bin.startunbounded and bin.stopunbounded must not be set for non-first/non-last bins'\n\t\t\t\t}\n\t\t\t\tif (!isStrictNumeric(bin.start)) throw 'bin.start must be numeric for a non-first bin'\n\t\t\t\tif (!isStrictNumeric(bin.stop)) throw 'bin.stop must be numeric for a non-last bin'\n\t\t\t}\n\t\t}\n\t} else if (bc.type == 'regular-bin') {\n\t\t// required custom_bin parameter\n\t\tif (!Number.isFinite(bc.bin_size)) throw 'non-numeric bin_size'\n\t\tif (bc.bin_size <= 0) throw 'bin_size must be greater than 0'\n\n\t\tif (!bc.startinclusive && !bc.stopinclusive) {\n\t\t\tbc.startinclusive = 1\n\t\t\tbc.stopinclusive = 0\n\t\t}\n\n\t\tif (!bc.first_bin) throw 'first_bin{} missing'\n\t\tif (typeof bc.first_bin != 'object') throw 'first_bin{} is not an object'\n\t\tif (!Object.keys(bc.first_bin).length) throw 'first_bin is an empty object'\n\n\t\t{\n\t\t\tconst b = bc.first_bin\n\t\t\tb.startunbounded = true\n\t\t\t// requires stop_percentile, or stop\n\t\t\tif (b.stop_percentile) {\n\t\t\t\tif (!Number.isInteger(b.stop_percentile)) throw 'first_bin.stop_percentile should be integer'\n\t\t\t\tif (b.stop_percentile <= 0 || b.stop_percentile >= 100) throw 'first_bin.stop_percentile out of bound (0-100)'\n\t\t\t} else if (!Number.isFinite(b.stop)) {\n\t\t\t\tthrow 'first_bin.stop not a number when stop_percentile is not set'\n\t\t\t}\n\t\t}\n\n\t\tif (bc.last_bin) {\n\t\t\tconst b = bc.last_bin\n\t\t\t// requires start_percentile or start\n\t\t\tif (b.start_percentile) {\n\t\t\t\tif (!Number.isInteger(b.start_percentile)) throw 'last_bin.start_percentile should be integer'\n\t\t\t\tif (b.start_percentile <= 0 || b.start_percentile >= 100) throw 'last_bin.start_percentile out of bound (0-100)'\n\t\t\t} else if (!Number.isFinite(b.start)) {\n\t\t\t\tthrow 'last_bin.start not a number when start_percentile is not set'\n\t\t\t}\n\n\t\t\tb.stopunbounded = true\n\t\t\tif ('stop' in b) {\n\t\t\t\tthrow 'a regular last bin must not set a bin.stop value'\n\t\t\t}\n\t\t}\n\t} else {\n\t\tthrow `invalid binconfig.type=\"${bc.type}\"`\n\t}\n}\n\nexport function compute_bins(binconfig, summaryfxn, valueConversion) {\n\t/*\n\t Bins generator\n\t \n\tbinconfig \n\t configuration of bins per the Numerical Binning Scheme\n\n\tsummaryfxn (percentiles)=> return {min, max, pX, pY, ...}\n\t - required function\n\n\t - must accept an array of desired percentile values\n\t and returns an object of computed properties\n\t {\n\t min: minimum value\n\t max: maximum value\n\t pX: percentile at X value, so p10 will be 10th percentile value\n\t pY: .. corresponding to the desired percentile values \n\t }\n\t*/\n\tconst bc = binconfig\n\n\tvalidate_bins(bc)\n\tif (bc.lst) {\n\t\tconst k2c = getColors(bc.lst.length) //to color bins\n\t\tfor (const bin of bc.lst) bin.color = k2c(bin.label)\n\t}\n\tif (bc.type == 'custom-bin') return JSON.parse(JSON.stringify(bc.lst))\n\tif (typeof summaryfxn != 'function') throw 'summaryfxn required for modules/termdb.bins.js compute_bins()'\n\tconst percentiles = target_percentiles(bc)\n\tconst summary = summaryfxn(percentiles)\n\tif (!summary || typeof summary !== 'object') throw 'invalid returned value by summaryfxn'\n\tbc.results = { summary }\n\tif (!bc.binLabelFormatter) bc.binLabelFormatter = getNumDecimalsFormatter(bc)\n\n\t// round the min and max values for use as bin start and stop\n\t// in the first and last bins, respectively\n\tconst minFloor = Math.floor(summary.min * 100) / 100\n\tconst maxCeil = Math.ceil(summary.max * 100) / 100\n\tconst min = bc.first_bin.startunbounded\n\t\t? minFloor\n\t\t: bc.first_bin.start_percentile\n\t\t? summary['p' + bc.first_bin.start_percentile]\n\t\t: bc.first_bin.start\n\tlet max = maxCeil, // in order to include the max value in the last bin\n\t\tlast_start,\n\t\tlast_stop\n\n\tif (bc.last_bin) {\n\t\tmax = bc.last_bin.stopunbounded\n\t\t\t? maxCeil // in order to include the max value in the last bin\n\t\t\t: bc.last_bin.stop_percentile\n\t\t\t? summary['p' + bc.last_bin.stop_percentile]\n\t\t\t: isNumeric(bc.last_bin.stop) && bc.last_bin.stop <= summary.max // '0.0088' < 0.0088\n\t\t\t? bc.last_bin.stop\n\t\t\t: maxCeil // in order to include the max value in the last bin\n\t\tlast_start = isStrictNumeric(bc.last_bin.start_percentile)\n\t\t\t? summary['p' + bc.last_bin.start_percentile]\n\t\t\t: isStrictNumeric(bc.last_bin.start)\n\t\t\t? bc.last_bin.start\n\t\t\t: undefined\n\t\tlast_stop = bc.last_bin.stopunbounded\n\t\t\t? null\n\t\t\t: bc.last_bin.stop_percentile\n\t\t\t? summary['p' + bc.last_bin.stop_percentile]\n\t\t\t: isStrictNumeric(bc.last_bin.stop)\n\t\t\t? bc.last_bin.stop\n\t\t\t: null\n\t} else if (bc.lst) {\n\t\tconst last_bin = bc.lst[bc.lst.length - 1]\n\t\tlast_start = last_bin.start\n\t\tlast_stop = 'stop' in last_bin && !last_bin.stopunbounded ? last_bin.stop : maxCeil\n\t\tmax = last_stop\n\t} else {\n\t\tlast_start = maxCeil\n\t\tlast_stop = maxCeil\n\t}\n\n\tconst numericMax = isStrictNumeric(max)\n\tconst numericLastStart = isStrictNumeric(last_start)\n\tconst numericLastStop = isStrictNumeric(last_stop)\n\n\tif (!numericMax && !numericLastStart) return [] //throw 'unable to compute the last bin start or stop'\n\n\tconst bins: any[] = []\n\tlet currBin: Record<string, any> = {\n\t\tstartunbounded: bc.first_bin.startunbounded,\n\t\tstart: bc.first_bin.startunbounded ? undefined : min,\n\t\tstop: isStrictNumeric(bc.first_bin.stop_percentile)\n\t\t\t? +summary['p' + bc.first_bin.stop_percentile]\n\t\t\t: isStrictNumeric(bc.first_bin.stop)\n\t\t\t? +bc.first_bin.stop\n\t\t\t: min + bc.bin_size,\n\t\tstartinclusive: bc.startinclusive,\n\t\tstopinclusive: bc.stopinclusive\n\t}\n\n\tif (!isStrictNumeric(currBin.stop)) throw 'the computed first_bin.stop is non-numeric' + currBin.stop\n\tconst maxNumBins = 100 // harcoded limit for now to not stress sqlite\n\n\twhile ((numericMax && currBin.stop <= max) || (currBin.startunbounded && !bins.length) || currBin.stopunbounded) {\n\t\tbins.push(currBin)\n\t\t// force a computed last bin to have stopunbounded true\n\t\tif (currBin.stop >= max) {\n\t\t\tcurrBin.stopunbounded = true\n\t\t\tif (bins.length > 1) {\n\t\t\t\tdelete currBin.stop\n\t\t\t}\n\t\t}\n\t\tcurrBin.label = get_bin_label(currBin, bc, valueConversion)\n\t\tif (currBin.stopunbounded) break\n\n\t\tconst upper = currBin.stop + bc.bin_size\n\t\tconst previousStop = currBin.stop\n\t\tcurrBin = {\n\t\t\tstartinclusive: bc.startinclusive,\n\t\t\tstopinclusive: bc.stopinclusive,\n\t\t\tstart: previousStop,\n\t\t\tstop:\n\t\t\t\tnumericLastStop && (previousStop == last_start || upper > last_stop)\n\t\t\t\t\t? last_stop\n\t\t\t\t\t: numericLastStart && upper > last_start && previousStop != last_start\n\t\t\t\t\t? last_start\n\t\t\t\t\t: upper\n\t\t}\n\n\t\tif (currBin.stop >= max) {\n\t\t\tcurrBin.stop = max\n\t\t\tif (bc.last_bin && bc.last_bin.stopunbounded) currBin.stopunbounded = 1\n\t\t\tif (bc.last_bin && bc.last_bin.stopinclusive) currBin.stopinclusive = 1\n\t\t}\n\t\tif (numericLastStart && currBin.start == last_start) {\n\t\t\tif (bc.last_bin && bc.last_bin.stopunbounded) currBin.stopunbounded = 1\n\t\t}\n\t\tif (currBin.start > currBin.stop) {\n\t\t\tif (numericLastStart && currBin.stop == last_start && bc.last_bin && bc.last_bin.stopunbounded)\n\t\t\t\tcurrBin.stopunbounded = true\n\t\t\telse break\n\t\t}\n\t\tif (bins.length + 1 >= maxNumBins) {\n\t\t\tbc.error = 'max_num_bins_reached'\n\t\t\tbreak\n\t\t}\n\t}\n\tdelete bc.binLabelFormatter\n\tif (bins.length > 1) {\n\t\tdelete bins[bins.length - 1].stop\n\t}\n\tconst k2c = getColors(bins.length) //to color bins\n\tfor (const bin of bins) bin.color = k2c(bin.label)\n\treturn bins\n}\n\nfunction getNumDecimalsFormatter(bc) {\n\t//return format('rounding' in bc ? bc.rounding : '')\n\treturn 'rounding' in bc ? format(bc.rounding) : d => d // default to labeling using the start/stop value as-is\n}\n\nexport function get_bin_label(bin, binconfig, valueConversion?: any) {\n\t/*\n\t Generate a numeric bin label given a bin configuration and an optional term valueConversion object\n\t*/\n\tif (!bin) return 'missing bin.label'\n\tif (bin.label) return bin.label\n\n\tconst bc = binconfig\n\tif (!bc.binLabelFormatter) bc.binLabelFormatter = getNumDecimalsFormatter(bc)\n\tif (!bin.startunbounded && !bin.stopunbounded && !('startinclusive' in bin) && !('stopinclusive' in bin)) {\n\t\tif (bc.startinclusive) bin.startinclusive = true\n\t\telse if (bc.stopinclusive) bin.stopinclusive = true\n\t}\n\n\tconst start = bc.use_as == 'bins' || bin.start\n\tconst stop = bc.use_as == 'bins' || bin.stop\n\n\tlet label_offset = 0\n\tif ('label_offset' in bc) {\n\t\tbc.label_offset_ignored = 'bin_size' in bc && bc.bin_size < bc.label_offset\n\t\tif (!bc.label_offset_ignored) label_offset = bc.label_offset\n\t} else if (bc.bin_size === 1 && bc.termtype == 'integer') {\n\t\tlabel_offset = 1\n\t}\n\n\t// one side-unbounded bins\n\t// label will be \">v\" or \"<v\"\n\tif (bin.startunbounded) {\n\t\tconst oper = bin.stopinclusive ? '\u2264' : '<' // \\u2264\n\t\tconst v1 = valueConversion\n\t\t\t? convertUnits(stop, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t: bc.binLabelFormatter(stop) //bin.startinclusive && label_offset ? stop - label_offset : stop)\n\t\treturn oper + v1\n\t}\n\t// a data value may coincide with the last bin's start\n\tif (bin.stopunbounded || start === stop) {\n\t\tconst oper = bin.startinclusive /*|| label_offset*/ ? '\u2265' : '>' // \\u2265\n\t\tconst v0 = valueConversion\n\t\t\t? convertUnits(start, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t: bc.binLabelFormatter(start) //bin.startinclusive || start == min ? start : start + label_offset)\n\t\treturn oper + v0\n\t}\n\n\t// two-sided bins\n\tif (label_offset && bin.startinclusive && !bin.stopinclusive) {\n\t\tif (Number.isInteger(bc.bin_size) && Math.abs(start - stop) === label_offset) {\n\t\t\t// make a simpler label when the range simply spans the bin_size\n\t\t\treturn (\n\t\t\t\t'' +\n\t\t\t\t(valueConversion\n\t\t\t\t\t? convertUnits(start, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t\t\t: bc.binLabelFormatter(start))\n\t\t\t)\n\t\t} else {\n\t\t\tconst v0 = valueConversion\n\t\t\t\t? convertUnits(start, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t\t: bc.binLabelFormatter(start)\n\t\t\tconst v1 = valueConversion\n\t\t\t\t? convertUnits(\n\t\t\t\t\t\tstop - label_offset,\n\t\t\t\t\t\tvalueConversion.fromUnit,\n\t\t\t\t\t\tvalueConversion.toUnit,\n\t\t\t\t\t\tvalueConversion.scaleFactor,\n\t\t\t\t\t\ttrue\n\t\t\t\t )\n\t\t\t\t: bc.binLabelFormatter(stop - label_offset)\n\t\t\t// ensure that last two bin labels make sense (the last is stopunbounded)\n\t\t\treturn +v0 >= +v1 ? v0.toString() : v0 + ' to ' + v1\n\t\t}\n\t} else {\n\t\t// stop_inclusive || label_offset == 0\n\t\tconst oper0 = bin.startinclusive ? '' : '>'\n\t\tconst oper1 = bin.stopinclusive ? '' : '<'\n\t\tconst v0 = valueConversion\n\t\t\t? convertUnits(start, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t: Number.isInteger(start)\n\t\t\t? start\n\t\t\t: bc.binLabelFormatter(start)\n\t\tconst v1 = valueConversion\n\t\t\t? convertUnits(stop, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t: Number.isInteger(stop)\n\t\t\t? stop\n\t\t\t: bc.binLabelFormatter(stop)\n\t\t// after rounding the bin labels, the bin start may equal the last bin stop as derived from actual data\n\t\tif (+v0 >= +v1) {\n\t\t\tconst oper = bin.startinclusive ? '\u2265' : '>' // \\u2265\n\t\t\treturn oper + v0\n\t\t} else {\n\t\t\treturn oper0 + v0 + ' to ' + oper1 + v1\n\t\t}\n\t}\n}\n\n// get bin range equation from bin label and bin properties\nexport function get_bin_range_equation(bin, binconfig) {\n\tconst x = '<span style=\"font-family:Times;font-style:italic;\">x</span>'\n\tlet range_eq\n\t// should always use computed (not user-customized) bin label to determine bin range text\n\tconst copy = structuredClone(bin)\n\tcopy.label = '' // mutate only the copy, and not the original bin argument\n\tconst bin_label = get_bin_label(copy, binconfig, undefined)\n\tif (bin.startunbounded || bin.stopunbounded) {\n\t\t// first or last bins, e.g. x \u2264 14 and x > 16\n\t\trange_eq = x + ' ' + bin_label\n\t} else if (bin.startinclusive) {\n\t\t// bins with startinclusive, e.g. 14 \u2264 x < 16\n\t\trange_eq = bin_label.replace('to <', '\u2264 ' + x + ' <')\n\t} else if (bin.stopinclusive) {\n\t\t// bins with stopinclusive, e.g. 14 < x \u2264 16\n\t\trange_eq = bin_label.replace('>', '').replace('to', '< ' + x + ' \u2264')\n\t}\n\treturn range_eq\n}\n\nexport function target_percentiles(binconfig) {\n\tconst percentiles: any[] = []\n\tconst f = binconfig.first_bin\n\tif (f && isStrictNumeric(f.start_percentile)) percentiles.push(f.start_percentile)\n\tif (f && isStrictNumeric(f.stop_percentile)) percentiles.push(f.stop_percentile)\n\tconst l = binconfig.last_bin\n\tif (l && isStrictNumeric(l.start_percentile)) percentiles.push(l.start_percentile)\n\tif (l && isStrictNumeric(l.stop_percentile)) percentiles.push(l.stop_percentile)\n\treturn percentiles\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,WAAW,iBAAiB,oBAAoB;AAE1C,SAAR,cAA+B,WAAW;AAGhD,QAAM,KAAK;AACX,MAAI,CAAC,MAAM,OAAO,OAAO,SAAU,OAAM;AAEzC,MAAI,EAAE,UAAU,IAAK,IAAG,OAAO;AAE/B,MAAI,GAAG,QAAQ,cAAc;AAC5B,QAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAG,OAAM;AAClC,QAAI,CAAC,GAAG,IAAI,OAAQ,OAAM;AAC1B,UAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,UAAM,WAAW,GAAG,IAAI,GAAG,IAAI,SAAS,CAAC;AAEzC,eAAW,OAAO,GAAG,KAAK;AACzB,UAAI,EAAE,oBAAoB,QAAQ,EAAE,mBAAmB,MAAM;AAC5D,cAAM;AAAA,MACP;AAEA,UAAI,OAAO,WAAW;AACrB,YAAI,oBAAoB,OAAO,CAAC,IAAI,gBAAgB;AACnD,gBAAM;AAAA,QACP;AACA,YAAI,iBAAiB;AACrB,YAAI,WAAW,KAAK;AACnB,gBAAM;AAAA,QACP;AACA,YAAI,sBAAsB,KAAK;AAC9B,gBAAM;AAAA,QACP;AACA,YAAI,EAAE,UAAU,MAAM;AACrB,gBAAM;AAAA,QACP;AACA,YAAI,CAAC,gBAAgB,IAAI,IAAI,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I,EAAE,kBAAkB;AACvB,YAAI,CAAC,OAAO,UAAU,EAAE,gBAAgB,EAAG,OAAM;AACjD,YAAI,EAAE,oBAAoB,KAAK,EAAE,oBAAoB,IAAK,OAAM;AAAA,MACjE,WAAW,CAAC,OAAO,SAAS,EAAE,KAAK,GAAG;AACrC,cAAM;AAAA,MACP;AAEA,QAAE,gBAAgB;AAClB,UAAI,UAAU,GAAG;AAChB,cAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD,OAAO;AACN,UAAM,2BAA2B,GAAG,IAAI;AAAA,EACzC;AACD;
|
|
4
|
+
"sourcesContent": ["import { format } from 'd3-format'\nimport { getColors } from './common.js'\nimport { isNumeric, isStrictNumeric, convertUnits } from './helpers.js'\n\nexport default function validate_bins(binconfig) {\n\t// Number.isFinite('1') returns false, which is desired\n\n\tconst bc = binconfig\n\tif (!bc || typeof bc !== 'object') throw 'bin schema must be an object'\n\t// assign default type\n\tif (!('type' in bc)) bc.type = 'regular-bin'\n\n\tif (bc.type == 'custom-bin') {\n\t\tif (!Array.isArray(bc.lst)) throw 'binconfig.lst must be an array'\n\t\tif (!bc.lst.length) throw 'binconfig.lst must have entries'\n\t\tconst first_bin = bc.lst[0]\n\t\tconst last_bin = bc.lst[bc.lst.length - 1]\n\n\t\tfor (const bin of bc.lst) {\n\t\t\tif (!('startinclusive' in bin) && !('stopinclusive' in bin)) {\n\t\t\t\tthrow 'custom bin.startinclusive and/or bin.stopinclusive must be defined'\n\t\t\t}\n\n\t\t\tif (bin == first_bin) {\n\t\t\t\tif ('startunbounded' in bin && !bin.startunbounded) {\n\t\t\t\t\tthrow `a custom first bin must not set bin.startunbounded to false`\n\t\t\t\t}\n\t\t\t\tbin.startunbounded = true\n\t\t\t\tif ('start' in bin) {\n\t\t\t\t\tthrow 'a custom first bin must not set a bin.start value'\n\t\t\t\t}\n\t\t\t\tif ('start_percentile' in bin) {\n\t\t\t\t\tthrow 'the first bin must not set a bin.start_percentile value'\n\t\t\t\t}\n\t\t\t\tif (!('stop' in bin)) {\n\t\t\t\t\tthrow `a custom first bin must define a bin.stop value`\n\t\t\t\t}\n\t\t\t\tif (!isStrictNumeric(bin.stop)) {\n\t\t\t\t\tthrow `a custom first bin.stop value should be numeric`\n\t\t\t\t}\n\t\t\t} else if (bin == last_bin) {\n\t\t\t\tif (!('start' in bin)) {\n\t\t\t\t\tthrow `a custom last bin must define a bin.start value`\n\t\t\t\t}\n\t\t\t\tif (!isStrictNumeric(bin.start)) {\n\t\t\t\t\tthrow `a custom last bin.start must be numeric`\n\t\t\t\t}\n\t\t\t\tif ('stopunbounded' in bin && !bin.stopunbounded) {\n\t\t\t\t\tthrow 'a custom last bin must not set bin.stopunbounded to false'\n\t\t\t\t}\n\t\t\t\tbin.stopunbounded = true\n\t\t\t\tif ('stop' in bin) {\n\t\t\t\t\tthrow 'a custom last bin must not set a bin.stop value'\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (bin.startunbounded || bin.stopunbounded) {\n\t\t\t\t\tthrow 'bin.startunbounded and bin.stopunbounded must not be set for non-first/non-last bins'\n\t\t\t\t}\n\t\t\t\tif (!isStrictNumeric(bin.start)) throw 'bin.start must be numeric for a non-first bin'\n\t\t\t\tif (!isStrictNumeric(bin.stop)) throw 'bin.stop must be numeric for a non-last bin'\n\t\t\t}\n\t\t}\n\t} else if (bc.type == 'regular-bin') {\n\t\t// required custom_bin parameter\n\t\tif (!Number.isFinite(bc.bin_size)) throw 'non-numeric bin_size'\n\t\tif (bc.bin_size <= 0) throw 'bin_size must be greater than 0'\n\n\t\tif (!bc.startinclusive && !bc.stopinclusive) {\n\t\t\tbc.startinclusive = 1\n\t\t\tbc.stopinclusive = 0\n\t\t}\n\n\t\tif (!bc.first_bin) throw 'first_bin{} missing'\n\t\tif (typeof bc.first_bin != 'object') throw 'first_bin{} is not an object'\n\t\tif (!Object.keys(bc.first_bin).length) throw 'first_bin is an empty object'\n\n\t\t{\n\t\t\tconst b = bc.first_bin\n\t\t\tb.startunbounded = true\n\t\t\t// requires stop_percentile, or stop\n\t\t\tif (b.stop_percentile) {\n\t\t\t\tif (!Number.isInteger(b.stop_percentile)) throw 'first_bin.stop_percentile should be integer'\n\t\t\t\tif (b.stop_percentile <= 0 || b.stop_percentile >= 100) throw 'first_bin.stop_percentile out of bound (0-100)'\n\t\t\t} else if (!Number.isFinite(b.stop)) {\n\t\t\t\tthrow 'first_bin.stop not a number when stop_percentile is not set'\n\t\t\t}\n\t\t}\n\n\t\tif (bc.last_bin) {\n\t\t\tconst b = bc.last_bin\n\t\t\t// requires start_percentile or start\n\t\t\tif (b.start_percentile) {\n\t\t\t\tif (!Number.isInteger(b.start_percentile)) throw 'last_bin.start_percentile should be integer'\n\t\t\t\tif (b.start_percentile <= 0 || b.start_percentile >= 100) throw 'last_bin.start_percentile out of bound (0-100)'\n\t\t\t} else if (!Number.isFinite(b.start)) {\n\t\t\t\tthrow 'last_bin.start not a number when start_percentile is not set'\n\t\t\t}\n\n\t\t\tb.stopunbounded = true\n\t\t\tif ('stop' in b) {\n\t\t\t\tthrow 'a regular last bin must not set a bin.stop value'\n\t\t\t}\n\t\t}\n\t} else {\n\t\tthrow `invalid binconfig.type=\"${bc.type}\"`\n\t}\n}\n\nconst maxNumBins = 100 // hardcoded limit for now to not stress sqlite\n\nexport function compute_bins(binconfig, summaryfxn, valueConversion) {\n\t/*\n\t Bins generator\n\t \n\tbinconfig \n\t configuration of bins per the Numerical Binning Scheme\n\n\tsummaryfxn (percentiles)=> return {min, max, pX, pY, ...}\n\t - required function\n\n\t - must accept an array of desired percentile values\n\t and returns an object of computed properties\n\t {\n\t min: minimum value\n\t max: maximum value\n\t pX: percentile at X value, so p10 will be 10th percentile value\n\t pY: .. corresponding to the desired percentile values \n\t }\n\t*/\n\tconst bc = binconfig\n\n\tvalidate_bins(bc)\n\tif (bc.lst) {\n\t\tif (!Array.isArray(bc.lst)) throw `bc.lst is not an array`\n\t\tif (bc.lst.length > maxNumBins) throw `bc.lst exceed the maximum of ${maxNumBins} allowed entries`\n\t\tconst k2c = getColors(bc.lst.length) //to color bins\n\t\tfor (const bin of bc.lst) bin.color = k2c(bin.label)\n\t}\n\tif (bc.type == 'custom-bin') return JSON.parse(JSON.stringify(bc.lst))\n\tif (typeof summaryfxn != 'function') throw 'summaryfxn required for modules/termdb.bins.js compute_bins()'\n\tconst percentiles = target_percentiles(bc)\n\tconst summary = summaryfxn(percentiles)\n\tif (!summary || typeof summary !== 'object') throw 'invalid returned value by summaryfxn'\n\tbc.results = { summary }\n\tif (!bc.binLabelFormatter) bc.binLabelFormatter = getNumDecimalsFormatter(bc)\n\n\t// round the min and max values for use as bin start and stop\n\t// in the first and last bins, respectively\n\tconst minFloor = Math.floor(summary.min * 100) / 100\n\tconst maxCeil = Math.ceil(summary.max * 100) / 100\n\tconst min = bc.first_bin.startunbounded\n\t\t? minFloor\n\t\t: bc.first_bin.start_percentile\n\t\t? summary['p' + bc.first_bin.start_percentile]\n\t\t: bc.first_bin.start\n\tlet max = maxCeil, // in order to include the max value in the last bin\n\t\tlast_start,\n\t\tlast_stop\n\n\tif (bc.last_bin) {\n\t\tmax = bc.last_bin.stopunbounded\n\t\t\t? maxCeil // in order to include the max value in the last bin\n\t\t\t: bc.last_bin.stop_percentile\n\t\t\t? summary['p' + bc.last_bin.stop_percentile]\n\t\t\t: isNumeric(bc.last_bin.stop) && bc.last_bin.stop <= summary.max // '0.0088' < 0.0088\n\t\t\t? bc.last_bin.stop\n\t\t\t: maxCeil // in order to include the max value in the last bin\n\t\tlast_start = isStrictNumeric(bc.last_bin.start_percentile)\n\t\t\t? summary['p' + bc.last_bin.start_percentile]\n\t\t\t: isStrictNumeric(bc.last_bin.start)\n\t\t\t? bc.last_bin.start\n\t\t\t: undefined\n\t\tlast_stop = bc.last_bin.stopunbounded\n\t\t\t? null\n\t\t\t: bc.last_bin.stop_percentile\n\t\t\t? summary['p' + bc.last_bin.stop_percentile]\n\t\t\t: isStrictNumeric(bc.last_bin.stop)\n\t\t\t? bc.last_bin.stop\n\t\t\t: null\n\t} else if (bc.lst) {\n\t\tconst last_bin = bc.lst[bc.lst.length - 1]\n\t\tlast_start = last_bin.start\n\t\tlast_stop = 'stop' in last_bin && !last_bin.stopunbounded ? last_bin.stop : maxCeil\n\t\tmax = last_stop\n\t} else {\n\t\tlast_start = maxCeil\n\t\tlast_stop = maxCeil\n\t}\n\n\tconst numericMax = isStrictNumeric(max)\n\tconst numericLastStart = isStrictNumeric(last_start)\n\tconst numericLastStop = isStrictNumeric(last_stop)\n\n\tif (!numericMax && !numericLastStart) return [] //throw 'unable to compute the last bin start or stop'\n\n\tconst bins: any[] = []\n\tlet currBin: Record<string, any> = {\n\t\tstartunbounded: bc.first_bin.startunbounded,\n\t\tstart: bc.first_bin.startunbounded ? undefined : min,\n\t\tstop: isStrictNumeric(bc.first_bin.stop_percentile)\n\t\t\t? +summary['p' + bc.first_bin.stop_percentile]\n\t\t\t: isStrictNumeric(bc.first_bin.stop)\n\t\t\t? +bc.first_bin.stop\n\t\t\t: min + bc.bin_size,\n\t\tstartinclusive: bc.startinclusive,\n\t\tstopinclusive: bc.stopinclusive\n\t}\n\n\tif (!isStrictNumeric(currBin.stop)) throw 'the computed first_bin.stop is non-numeric' + currBin.stop\n\n\twhile ((numericMax && currBin.stop <= max) || (currBin.startunbounded && !bins.length) || currBin.stopunbounded) {\n\t\tbins.push(currBin)\n\t\t// force a computed last bin to have stopunbounded true\n\t\tif (currBin.stop >= max) {\n\t\t\tcurrBin.stopunbounded = true\n\t\t\tif (bins.length > 1) {\n\t\t\t\tdelete currBin.stop\n\t\t\t}\n\t\t}\n\t\tcurrBin.label = get_bin_label(currBin, bc, valueConversion)\n\t\tif (currBin.stopunbounded) break\n\n\t\tconst upper = currBin.stop + bc.bin_size\n\t\tconst previousStop = currBin.stop\n\t\tcurrBin = {\n\t\t\tstartinclusive: bc.startinclusive,\n\t\t\tstopinclusive: bc.stopinclusive,\n\t\t\tstart: previousStop,\n\t\t\tstop:\n\t\t\t\tnumericLastStop && (previousStop == last_start || upper > last_stop)\n\t\t\t\t\t? last_stop\n\t\t\t\t\t: numericLastStart && upper > last_start && previousStop != last_start\n\t\t\t\t\t? last_start\n\t\t\t\t\t: upper\n\t\t}\n\n\t\tif (currBin.stop >= max) {\n\t\t\tcurrBin.stop = max\n\t\t\tif (bc.last_bin && bc.last_bin.stopunbounded) currBin.stopunbounded = 1\n\t\t\tif (bc.last_bin && bc.last_bin.stopinclusive) currBin.stopinclusive = 1\n\t\t}\n\t\tif (numericLastStart && currBin.start == last_start) {\n\t\t\tif (bc.last_bin && bc.last_bin.stopunbounded) currBin.stopunbounded = 1\n\t\t}\n\t\tif (currBin.start > currBin.stop) {\n\t\t\tif (numericLastStart && currBin.stop == last_start && bc.last_bin && bc.last_bin.stopunbounded)\n\t\t\t\tcurrBin.stopunbounded = true\n\t\t\telse break\n\t\t}\n\t\tif (bins.length + 1 >= maxNumBins) {\n\t\t\tdelete currBin.stop\n\t\t\tcurrBin.stopunbounded = true\n\t\t\tcurrBin.label = get_bin_label(currBin, bc, valueConversion)\n\t\t\tif (!bins.includes(currBin)) bins.push(currBin)\n\t\t\tconst hint = 'Please increase the bin_size or first bin stop, or have a lower last bin start.'\n\t\t\tbc.error = hint + ' (max_num_bins_reached)'\n\t\t\tbreak\n\t\t}\n\t}\n\tdelete bc.binLabelFormatter\n\tif (bins.length > 1) {\n\t\tdelete bins[bins.length - 1].stop\n\t}\n\tconst k2c = getColors(bins.length) //to color bins\n\tfor (const bin of bins) bin.color = k2c(bin.label)\n\treturn bins\n}\n\nfunction getNumDecimalsFormatter(bc) {\n\t//return format('rounding' in bc ? bc.rounding : '')\n\treturn 'rounding' in bc ? format(bc.rounding) : d => d // default to labeling using the start/stop value as-is\n}\n\nexport function get_bin_label(bin, binconfig, valueConversion?: any) {\n\t/*\n\t Generate a numeric bin label given a bin configuration and an optional term valueConversion object\n\t*/\n\tif (!bin) return 'missing bin.label'\n\tif (bin.label) return bin.label\n\n\tconst bc = binconfig\n\tif (!bc.binLabelFormatter) bc.binLabelFormatter = getNumDecimalsFormatter(bc)\n\tif (!bin.startunbounded && !bin.stopunbounded && !('startinclusive' in bin) && !('stopinclusive' in bin)) {\n\t\tif (bc.startinclusive) bin.startinclusive = true\n\t\telse if (bc.stopinclusive) bin.stopinclusive = true\n\t}\n\n\tconst start = bc.use_as == 'bins' || bin.start\n\tconst stop = bc.use_as == 'bins' || bin.stop\n\n\tlet label_offset = 0\n\tif ('label_offset' in bc) {\n\t\tbc.label_offset_ignored = 'bin_size' in bc && bc.bin_size < bc.label_offset\n\t\tif (!bc.label_offset_ignored) label_offset = bc.label_offset\n\t} else if (bc.bin_size === 1 && bc.termtype == 'integer') {\n\t\tlabel_offset = 1\n\t}\n\n\t// one side-unbounded bins\n\t// label will be \">v\" or \"<v\"\n\tif (bin.startunbounded) {\n\t\tconst oper = bin.stopinclusive ? '\u2264' : '<' // \\u2264\n\t\tconst v1 = valueConversion\n\t\t\t? convertUnits(stop, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t: bc.binLabelFormatter(stop) //bin.startinclusive && label_offset ? stop - label_offset : stop)\n\t\treturn oper + v1\n\t}\n\t// a data value may coincide with the last bin's start\n\tif (bin.stopunbounded || start === stop) {\n\t\tconst oper = bin.startinclusive /*|| label_offset*/ ? '\u2265' : '>' // \\u2265\n\t\tconst v0 = valueConversion\n\t\t\t? convertUnits(start, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t: bc.binLabelFormatter(start) //bin.startinclusive || start == min ? start : start + label_offset)\n\t\treturn oper + v0\n\t}\n\n\t// two-sided bins\n\tif (label_offset && bin.startinclusive && !bin.stopinclusive) {\n\t\tif (Number.isInteger(bc.bin_size) && Math.abs(start - stop) === label_offset) {\n\t\t\t// make a simpler label when the range simply spans the bin_size\n\t\t\treturn (\n\t\t\t\t'' +\n\t\t\t\t(valueConversion\n\t\t\t\t\t? convertUnits(start, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t\t\t: bc.binLabelFormatter(start))\n\t\t\t)\n\t\t} else {\n\t\t\tconst v0 = valueConversion\n\t\t\t\t? convertUnits(start, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t\t: bc.binLabelFormatter(start)\n\t\t\tconst v1 = valueConversion\n\t\t\t\t? convertUnits(\n\t\t\t\t\t\tstop - label_offset,\n\t\t\t\t\t\tvalueConversion.fromUnit,\n\t\t\t\t\t\tvalueConversion.toUnit,\n\t\t\t\t\t\tvalueConversion.scaleFactor,\n\t\t\t\t\t\ttrue\n\t\t\t\t )\n\t\t\t\t: bc.binLabelFormatter(stop - label_offset)\n\t\t\t// ensure that last two bin labels make sense (the last is stopunbounded)\n\t\t\treturn +v0 >= +v1 ? v0.toString() : v0 + ' to ' + v1\n\t\t}\n\t} else {\n\t\t// stop_inclusive || label_offset == 0\n\t\tconst oper0 = bin.startinclusive ? '' : '>'\n\t\tconst oper1 = bin.stopinclusive ? '' : '<'\n\t\tconst v0 = valueConversion\n\t\t\t? convertUnits(start, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t: Number.isInteger(start)\n\t\t\t? start\n\t\t\t: bc.binLabelFormatter(start)\n\t\tconst v1 = valueConversion\n\t\t\t? convertUnits(stop, valueConversion.fromUnit, valueConversion.toUnit, valueConversion.scaleFactor, true)\n\t\t\t: Number.isInteger(stop)\n\t\t\t? stop\n\t\t\t: bc.binLabelFormatter(stop)\n\t\t// after rounding the bin labels, the bin start may equal the last bin stop as derived from actual data\n\t\tif (+v0 >= +v1) {\n\t\t\tconst oper = bin.startinclusive ? '\u2265' : '>' // \\u2265\n\t\t\treturn oper + v0\n\t\t} else {\n\t\t\treturn oper0 + v0 + ' to ' + oper1 + v1\n\t\t}\n\t}\n}\n\n// get bin range equation from bin label and bin properties\nexport function get_bin_range_equation(bin, binconfig) {\n\tconst x = '<span style=\"font-family:Times;font-style:italic;\">x</span>'\n\tlet range_eq\n\t// should always use computed (not user-customized) bin label to determine bin range text\n\tconst copy = structuredClone(bin)\n\tcopy.label = '' // mutate only the copy, and not the original bin argument\n\tconst bin_label = get_bin_label(copy, binconfig, undefined)\n\tif (bin.startunbounded || bin.stopunbounded) {\n\t\t// first or last bins, e.g. x \u2264 14 and x > 16\n\t\trange_eq = x + ' ' + bin_label\n\t} else if (bin.startinclusive) {\n\t\t// bins with startinclusive, e.g. 14 \u2264 x < 16\n\t\trange_eq = bin_label.replace('to <', '\u2264 ' + x + ' <')\n\t} else if (bin.stopinclusive) {\n\t\t// bins with stopinclusive, e.g. 14 < x \u2264 16\n\t\trange_eq = bin_label.replace('>', '').replace('to', '< ' + x + ' \u2264')\n\t}\n\treturn range_eq\n}\n\nexport function target_percentiles(binconfig) {\n\tconst percentiles: any[] = []\n\tconst f = binconfig.first_bin\n\tif (f && isStrictNumeric(f.start_percentile)) percentiles.push(f.start_percentile)\n\tif (f && isStrictNumeric(f.stop_percentile)) percentiles.push(f.stop_percentile)\n\tconst l = binconfig.last_bin\n\tif (l && isStrictNumeric(l.start_percentile)) percentiles.push(l.start_percentile)\n\tif (l && isStrictNumeric(l.stop_percentile)) percentiles.push(l.stop_percentile)\n\treturn percentiles\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,WAAW,iBAAiB,oBAAoB;AAE1C,SAAR,cAA+B,WAAW;AAGhD,QAAM,KAAK;AACX,MAAI,CAAC,MAAM,OAAO,OAAO,SAAU,OAAM;AAEzC,MAAI,EAAE,UAAU,IAAK,IAAG,OAAO;AAE/B,MAAI,GAAG,QAAQ,cAAc;AAC5B,QAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAG,OAAM;AAClC,QAAI,CAAC,GAAG,IAAI,OAAQ,OAAM;AAC1B,UAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,UAAM,WAAW,GAAG,IAAI,GAAG,IAAI,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