mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-21 06:48:12 +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");
|
||||
var BitArray = require("./bitArray");
|
||||
var Util = require("./util");
|
||||
import PositiveIntervals from "./positiveIntervals";
|
||||
import BitArray from "./bitArray";
|
||||
import {
|
||||
fillRange,
|
||||
lowerBound,
|
||||
lowerBoundIndirect,
|
||||
upperBound,
|
||||
upperBoundIndirect
|
||||
} from "./util";
|
||||
|
||||
class NotImplementedError extends Error {
|
||||
constructor(...params) {
|
||||
@@ -129,7 +135,7 @@ class ScalarDimension {
|
||||
this.value = array;
|
||||
|
||||
// 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]);
|
||||
|
||||
// groups, if any
|
||||
@@ -193,20 +199,8 @@ class ScalarDimension {
|
||||
// filter by value - exact match
|
||||
filterExact(value) {
|
||||
const newFilter = [
|
||||
Util.lowerBoundIndirect(
|
||||
this.value,
|
||||
this.index,
|
||||
value,
|
||||
0,
|
||||
this.value.length
|
||||
),
|
||||
Util.upperBoundIndirect(
|
||||
this.value,
|
||||
this.index,
|
||||
value,
|
||||
0,
|
||||
this.value.length
|
||||
)
|
||||
lowerBoundIndirect(this.value, this.index, value, 0, this.value.length),
|
||||
upperBoundIndirect(this.value, this.index, value, 0, this.value.length)
|
||||
];
|
||||
if (newFilter[0] <= newFilter[1]) {
|
||||
this._updateFilters([newFilter]);
|
||||
@@ -221,14 +215,14 @@ class ScalarDimension {
|
||||
const newFilter = [];
|
||||
for (let v = 0, len = values.length; v < len; v++) {
|
||||
const intv = [
|
||||
Util.lowerBoundIndirect(
|
||||
lowerBoundIndirect(
|
||||
this.value,
|
||||
this.index,
|
||||
values[v],
|
||||
0,
|
||||
this.value.length
|
||||
),
|
||||
Util.upperBoundIndirect(
|
||||
upperBoundIndirect(
|
||||
this.value,
|
||||
this.index,
|
||||
values[v],
|
||||
@@ -247,20 +241,14 @@ class ScalarDimension {
|
||||
filterRange(range) {
|
||||
const newFilter = [];
|
||||
const intv = [
|
||||
Util.lowerBoundIndirect(
|
||||
lowerBoundIndirect(
|
||||
this.value,
|
||||
this.index,
|
||||
range[0],
|
||||
0,
|
||||
this.value.length
|
||||
),
|
||||
Util.upperBoundIndirect(
|
||||
this.value,
|
||||
this.index,
|
||||
range[1],
|
||||
0,
|
||||
this.value.length
|
||||
)
|
||||
upperBoundIndirect(this.value, this.index, range[1], 0, this.value.length)
|
||||
];
|
||||
if (intv[0] < intv[1]) newFilter.push(intv);
|
||||
this._updateFilters(newFilter);
|
||||
@@ -374,7 +362,7 @@ class EnumDimension extends ScalarDimension {
|
||||
const enumLen = this.enumIndex.length;
|
||||
for (let i = 0; i < len; 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;
|
||||
}
|
||||
return array;
|
||||
@@ -382,23 +370,19 @@ class EnumDimension extends ScalarDimension {
|
||||
|
||||
filterExact(value) {
|
||||
return super.filterExact(
|
||||
Util.lowerBound(this.enumIndex, value, 0, this.enumIndex.length)
|
||||
lowerBound(this.enumIndex, value, 0, this.enumIndex.length)
|
||||
);
|
||||
}
|
||||
|
||||
filterEnum(values) {
|
||||
return super.filterEnum(
|
||||
values.map(v =>
|
||||
Util.lowerBound(this.enumIndex, v, 0, this.enumIndex.length)
|
||||
)
|
||||
values.map(v => lowerBound(this.enumIndex, v, 0, this.enumIndex.length))
|
||||
);
|
||||
}
|
||||
|
||||
filterRange(range) {
|
||||
return super.filterEnum(
|
||||
range.map(v =>
|
||||
Util.lowerBound(this.enumIndex, v, 0, this.enumIndex.length)
|
||||
)
|
||||
range.map(v => lowerBound(this.enumIndex, v, 0, this.enumIndex.length))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -615,4 +599,4 @@ crossfilter.TypedCrossfilter = TypedCrossfilter;
|
||||
crossfilter.ScalarDimension = ScalarDimension;
|
||||
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,
|
||||
// starting with `start`
|
||||
//
|
||||
function fillRange(arr, start = 0) {
|
||||
export function fillRange(arr, start = 0) {
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
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 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
|
||||
while (first < last) {
|
||||
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.
|
||||
//
|
||||
function lowerBoundIndirect(valueArray, indexArray, value, first, last) {
|
||||
export function lowerBoundIndirect(valueArray, indexArray, value, first, last) {
|
||||
// this is just a binary search
|
||||
while (first < last) {
|
||||
const middle = (first + last) >>> 1;
|
||||
@@ -69,7 +69,7 @@ function lowerBoundIndirect(valueArray, indexArray, value, first, last) {
|
||||
// C++: upper_bound()
|
||||
// Python: bisect.bisect_right()
|
||||
//
|
||||
function upperBound(valueArray, value, first, last) {
|
||||
export function upperBound(valueArray, value, first, last) {
|
||||
// this is just a binary search
|
||||
while (first < last) {
|
||||
const middle = (first + last) >>> 1;
|
||||
@@ -84,7 +84,7 @@ function upperBound(valueArray, value, first, last) {
|
||||
|
||||
// Inline performance optimization
|
||||
//
|
||||
function upperBoundIndirect(valueArray, indexArray, value, first, last) {
|
||||
export function upperBoundIndirect(valueArray, indexArray, value, first, last) {
|
||||
// this is just a binary search
|
||||
while (first < last) {
|
||||
const middle = (first + last) >>> 1;
|
||||
@@ -96,11 +96,3 @@ function upperBoundIndirect(valueArray, indexArray, value, first, last) {
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fillRange,
|
||||
lowerBound,
|
||||
lowerBoundIndirect,
|
||||
upperBound,
|
||||
upperBoundIndirect
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user