mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-07 09:48:13 +08:00
revert the module change reversion
This commit is contained in:
@@ -251,4 +251,4 @@ class BitArray {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = BitArray;
|
export default BitArray;
|
||||||
|
|||||||
@@ -29,9 +29,15 @@ more complex API. In a few cases, elements of that API were incorporated.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var PositiveIntervals = require("./positiveIntervals");
|
import PositiveIntervals from "./positiveIntervals";
|
||||||
var BitArray = require("./bitArray");
|
import BitArray from "./bitArray";
|
||||||
var Util = require("./util");
|
import {
|
||||||
|
fillRange,
|
||||||
|
lowerBound,
|
||||||
|
lowerBoundIndirect,
|
||||||
|
upperBound,
|
||||||
|
upperBoundIndirect
|
||||||
|
} from "./util";
|
||||||
|
|
||||||
class NotImplementedError extends Error {
|
class NotImplementedError extends Error {
|
||||||
constructor(...params) {
|
constructor(...params) {
|
||||||
@@ -129,7 +135,7 @@ class ScalarDimension {
|
|||||||
this.value = array;
|
this.value = array;
|
||||||
|
|
||||||
// create sort index
|
// create sort index
|
||||||
this.index = Util.fillRange(new Uint32Array(this.crossfilter.data.length));
|
this.index = fillRange(new Uint32Array(this.crossfilter.data.length));
|
||||||
this.index.sort((a, b) => array[a] - array[b]);
|
this.index.sort((a, b) => array[a] - array[b]);
|
||||||
|
|
||||||
// groups, if any
|
// groups, if any
|
||||||
@@ -193,20 +199,8 @@ class ScalarDimension {
|
|||||||
// filter by value - exact match
|
// filter by value - exact match
|
||||||
filterExact(value) {
|
filterExact(value) {
|
||||||
const newFilter = [
|
const newFilter = [
|
||||||
Util.lowerBoundIndirect(
|
lowerBoundIndirect(this.value, this.index, value, 0, this.value.length),
|
||||||
this.value,
|
upperBoundIndirect(this.value, this.index, value, 0, this.value.length)
|
||||||
this.index,
|
|
||||||
value,
|
|
||||||
0,
|
|
||||||
this.value.length
|
|
||||||
),
|
|
||||||
Util.upperBoundIndirect(
|
|
||||||
this.value,
|
|
||||||
this.index,
|
|
||||||
value,
|
|
||||||
0,
|
|
||||||
this.value.length
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
if (newFilter[0] <= newFilter[1]) {
|
if (newFilter[0] <= newFilter[1]) {
|
||||||
this._updateFilters([newFilter]);
|
this._updateFilters([newFilter]);
|
||||||
@@ -221,14 +215,14 @@ class ScalarDimension {
|
|||||||
const newFilter = [];
|
const newFilter = [];
|
||||||
for (let v = 0, len = values.length; v < len; v++) {
|
for (let v = 0, len = values.length; v < len; v++) {
|
||||||
const intv = [
|
const intv = [
|
||||||
Util.lowerBoundIndirect(
|
lowerBoundIndirect(
|
||||||
this.value,
|
this.value,
|
||||||
this.index,
|
this.index,
|
||||||
values[v],
|
values[v],
|
||||||
0,
|
0,
|
||||||
this.value.length
|
this.value.length
|
||||||
),
|
),
|
||||||
Util.upperBoundIndirect(
|
upperBoundIndirect(
|
||||||
this.value,
|
this.value,
|
||||||
this.index,
|
this.index,
|
||||||
values[v],
|
values[v],
|
||||||
@@ -247,20 +241,14 @@ class ScalarDimension {
|
|||||||
filterRange(range) {
|
filterRange(range) {
|
||||||
const newFilter = [];
|
const newFilter = [];
|
||||||
const intv = [
|
const intv = [
|
||||||
Util.lowerBoundIndirect(
|
lowerBoundIndirect(
|
||||||
this.value,
|
this.value,
|
||||||
this.index,
|
this.index,
|
||||||
range[0],
|
range[0],
|
||||||
0,
|
0,
|
||||||
this.value.length
|
this.value.length
|
||||||
),
|
),
|
||||||
Util.upperBoundIndirect(
|
upperBoundIndirect(this.value, this.index, range[1], 0, this.value.length)
|
||||||
this.value,
|
|
||||||
this.index,
|
|
||||||
range[1],
|
|
||||||
0,
|
|
||||||
this.value.length
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
if (intv[0] < intv[1]) newFilter.push(intv);
|
if (intv[0] < intv[1]) newFilter.push(intv);
|
||||||
this._updateFilters(newFilter);
|
this._updateFilters(newFilter);
|
||||||
@@ -374,7 +362,7 @@ class EnumDimension extends ScalarDimension {
|
|||||||
const enumLen = this.enumIndex.length;
|
const enumLen = this.enumIndex.length;
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
const v = value(data[i]);
|
const v = value(data[i]);
|
||||||
const e = Util.lowerBound(this.enumIndex, v, 0, enumLen);
|
const e = lowerBound(this.enumIndex, v, 0, enumLen);
|
||||||
array[i] = e;
|
array[i] = e;
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
@@ -382,23 +370,19 @@ class EnumDimension extends ScalarDimension {
|
|||||||
|
|
||||||
filterExact(value) {
|
filterExact(value) {
|
||||||
return super.filterExact(
|
return super.filterExact(
|
||||||
Util.lowerBound(this.enumIndex, value, 0, this.enumIndex.length)
|
lowerBound(this.enumIndex, value, 0, this.enumIndex.length)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterEnum(values) {
|
filterEnum(values) {
|
||||||
return super.filterEnum(
|
return super.filterEnum(
|
||||||
values.map(v =>
|
values.map(v => lowerBound(this.enumIndex, v, 0, this.enumIndex.length))
|
||||||
Util.lowerBound(this.enumIndex, v, 0, this.enumIndex.length)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterRange(range) {
|
filterRange(range) {
|
||||||
return super.filterEnum(
|
return super.filterEnum(
|
||||||
range.map(v =>
|
range.map(v => lowerBound(this.enumIndex, v, 0, this.enumIndex.length))
|
||||||
Util.lowerBound(this.enumIndex, v, 0, this.enumIndex.length)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,4 +599,4 @@ crossfilter.TypedCrossfilter = TypedCrossfilter;
|
|||||||
crossfilter.ScalarDimension = ScalarDimension;
|
crossfilter.ScalarDimension = ScalarDimension;
|
||||||
crossfilter.EnumDimension = EnumDimension;
|
crossfilter.EnumDimension = EnumDimension;
|
||||||
|
|
||||||
module.exports = crossfilter;
|
export default crossfilter;
|
||||||
|
|||||||
@@ -129,4 +129,4 @@ class PositiveIntervals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PositiveIntervals;
|
export default PositiveIntervals;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
// fill an array or typedarray with a sequential range of numbers,
|
// fill an array or typedarray with a sequential range of numbers,
|
||||||
// starting with `start`
|
// starting with `start`
|
||||||
//
|
//
|
||||||
function fillRange(arr, start = 0) {
|
export function fillRange(arr, start = 0) {
|
||||||
for (let i = 0, len = arr.length; i < len; i++) {
|
for (let i = 0, len = arr.length; i < len; i++) {
|
||||||
arr[i] = i + start;
|
arr[i] = i + start;
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ function fillRange(arr, start = 0) {
|
|||||||
// a factory version of lowerBound that takes an accessor (rather than having
|
// a factory version of lowerBound that takes an accessor (rather than having
|
||||||
// a special-cased version for lining the indirection).
|
// a special-cased version for lining the indirection).
|
||||||
//
|
//
|
||||||
function lowerBound(valueArray, value, first, last) {
|
export function lowerBound(valueArray, value, first, last) {
|
||||||
// this is just a binary search
|
// this is just a binary search
|
||||||
while (first < last) {
|
while (first < last) {
|
||||||
const middle = (first + last) >>> 1;
|
const middle = (first + last) >>> 1;
|
||||||
@@ -45,7 +45,7 @@ function lowerBound(valueArray, value, first, last) {
|
|||||||
|
|
||||||
// Inlined performance optimization - used to indirect through a sort map.
|
// Inlined performance optimization - used to indirect through a sort map.
|
||||||
//
|
//
|
||||||
function lowerBoundIndirect(valueArray, indexArray, value, first, last) {
|
export function lowerBoundIndirect(valueArray, indexArray, value, first, last) {
|
||||||
// this is just a binary search
|
// this is just a binary search
|
||||||
while (first < last) {
|
while (first < last) {
|
||||||
const middle = (first + last) >>> 1;
|
const middle = (first + last) >>> 1;
|
||||||
@@ -69,7 +69,7 @@ function lowerBoundIndirect(valueArray, indexArray, value, first, last) {
|
|||||||
// C++: upper_bound()
|
// C++: upper_bound()
|
||||||
// Python: bisect.bisect_right()
|
// Python: bisect.bisect_right()
|
||||||
//
|
//
|
||||||
function upperBound(valueArray, value, first, last) {
|
export function upperBound(valueArray, value, first, last) {
|
||||||
// this is just a binary search
|
// this is just a binary search
|
||||||
while (first < last) {
|
while (first < last) {
|
||||||
const middle = (first + last) >>> 1;
|
const middle = (first + last) >>> 1;
|
||||||
@@ -84,7 +84,7 @@ function upperBound(valueArray, value, first, last) {
|
|||||||
|
|
||||||
// Inline performance optimization
|
// Inline performance optimization
|
||||||
//
|
//
|
||||||
function upperBoundIndirect(valueArray, indexArray, value, first, last) {
|
export function upperBoundIndirect(valueArray, indexArray, value, first, last) {
|
||||||
// this is just a binary search
|
// this is just a binary search
|
||||||
while (first < last) {
|
while (first < last) {
|
||||||
const middle = (first + last) >>> 1;
|
const middle = (first + last) >>> 1;
|
||||||
@@ -96,11 +96,3 @@ function upperBoundIndirect(valueArray, indexArray, value, first, last) {
|
|||||||
}
|
}
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
fillRange,
|
|
||||||
lowerBound,
|
|
||||||
lowerBoundIndirect,
|
|
||||||
upperBound,
|
|
||||||
upperBoundIndirect
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user