mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-03 15:38:12 +08:00
Performance work (#334)
* range encode filter range lists * speed up data load * add comment on scanpy read params * update to latest scanpy/anndata * performance improvments in data loading * fix typo * work around scanpy bug * remove debugging print statements
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { rangeEncodeIndices } from "../../src/util/actionHelpers";
|
||||
|
||||
describe("rangeEncodeIndices", () => {
|
||||
test("small array edge cases", () => {
|
||||
expect(rangeEncodeIndices([])).toMatchObject([]);
|
||||
expect(rangeEncodeIndices([1])).toMatchObject([1]);
|
||||
expect(rangeEncodeIndices([1, 99])).toMatchObject([1, 99]);
|
||||
expect(rangeEncodeIndices([99, 1])).toMatchObject([1, 99]);
|
||||
expect(rangeEncodeIndices([1, 100, 4])).toMatchObject([1, 4, 100]);
|
||||
});
|
||||
|
||||
test("sorted flag", () => {
|
||||
expect(rangeEncodeIndices([1, 9, 432], 10, true)).toMatchObject([
|
||||
1,
|
||||
9,
|
||||
432
|
||||
]);
|
||||
expect(rangeEncodeIndices([1, 9, 432], 10, false)).toMatchObject([
|
||||
1,
|
||||
9,
|
||||
432
|
||||
]);
|
||||
expect(rangeEncodeIndices([0, 1, 2, 3, 9, 10, 432], 2, true)).toMatchObject(
|
||||
[[0, 3], [9, 10], 432]
|
||||
);
|
||||
expect(
|
||||
rangeEncodeIndices([0, 1, 2, 3, 9, 10, 432], 2, false)
|
||||
).toMatchObject([[0, 3], [9, 10], 432]);
|
||||
});
|
||||
|
||||
test("begin or end edge cases", () => {
|
||||
expect(
|
||||
rangeEncodeIndices([3, 4, 5, 6, 7, 10, 11, 12, 99], 3, false)
|
||||
).toMatchObject([[3, 7], [10, 12], 99]);
|
||||
expect(
|
||||
rangeEncodeIndices([3, 4, 5, 6, 7, 10, 11, 12], 3, false)
|
||||
).toMatchObject([[3, 7], [10, 12]]);
|
||||
expect(
|
||||
rangeEncodeIndices([0, 3, 4, 5, 6, 7, 10, 11, 12], 3, false)
|
||||
).toMatchObject([0, [3, 7], [10, 12]]);
|
||||
expect(
|
||||
rangeEncodeIndices([0, 3, 4, 5, 6, 7, 10, 11, 12, 99], 3, false)
|
||||
).toMatchObject([0, [3, 7], [10, 12], 99]);
|
||||
});
|
||||
|
||||
test("minRangeLength", () => {
|
||||
expect(
|
||||
rangeEncodeIndices([3, 4, 5, 6, 7, 10, 11, 12, 99], 4, false)
|
||||
).toMatchObject([[3, 7], 10, 11, 12, 99]);
|
||||
expect(
|
||||
rangeEncodeIndices([3, 4, 5, 6, 7, 10, 11, 12], 4, false)
|
||||
).toMatchObject([[3, 7], 10, 11, 12]);
|
||||
expect(
|
||||
rangeEncodeIndices([0, 3, 4, 5, 6, 7, 10, 11, 12], 4, false)
|
||||
).toMatchObject([0, [3, 7], 10, 11, 12]);
|
||||
expect(
|
||||
rangeEncodeIndices([0, 3, 4, 5, 6, 7, 10, 11, 12, 99], 4, false)
|
||||
).toMatchObject([0, [3, 7], 10, 11, 12, 99]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user