mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-23 21:18:12 +08:00
* first flatbuffer schema * do not lint auto-generated files * add flatbuffers package * add flatbuffer module * wire up /data/X/T route * use flatbuffers for matrix data fetc * clarity and comments * add flatbuffer layout route * clean up obsolete code * fix tests * move flake8 config to setup.cfg * add comments * lint * rework layout routes for fbs * add more type support to fbs * lint * add flatbuffer support for annotations * function name improvements * fix botched merge with master * remove unused import * route cleanup for flatbuffers * rename function for clarity * add missing globals to Jest tests * fix client JS tests * fix routes for Python tests * comments for clarity * non-finite floating point hardening * more non-finite number handling * lint * fix tests for summarizeAnnotations * harden diffexp calculation against FP errors * cleanup unused code * lint * add encoding tests for flatbuffers * application type specified as strings * fix spelling error * improve variable names * add note about documentation gap * rename FBS DataFrame to Matrix
34 lines
685 B
JavaScript
34 lines
685 B
JavaScript
/*
|
|
Return the [minimum, maximum] extent, of the given typed array, ignoring
|
|
non-finite values (ie, +Infinity, -Infinity).
|
|
|
|
If undefined or empty array, or array contains only non-finite numbers,
|
|
will return [undefined, undefined]
|
|
*/
|
|
|
|
function finiteExtent(tarr) {
|
|
let min;
|
|
let max;
|
|
let i;
|
|
|
|
for (i = 0; i < tarr.length; i += 1) {
|
|
const val = tarr[i];
|
|
if (Number.isFinite(val)) {
|
|
min = val;
|
|
max = val;
|
|
i += 1;
|
|
break;
|
|
}
|
|
}
|
|
for (; i < tarr.length; i += 1) {
|
|
const val = tarr[i];
|
|
if (Number.isFinite(val)) {
|
|
if (min > val) min = val;
|
|
if (max < val) max = val;
|
|
}
|
|
}
|
|
return [min, max];
|
|
}
|
|
|
|
export default finiteExtent;
|