mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-30 21:18:12 +08:00
initial bug fixes and test improvements for the matrix refactor (#1503)
* initial bug fixes and test improvements for the matrix refactor * lint
This commit is contained in:
@@ -27,7 +27,7 @@ describe("encode/decode", () => {
|
||||
const dfWithColIdx = new Dataframe([3, 4], columns, null, colIndex);
|
||||
const dfB = decodeMatrixFBS(encodeMatrixFBS(dfWithColIdx));
|
||||
expect([dfB.nRows, dfB.nCols]).toEqual(dfWithColIdx.dims);
|
||||
expect(dfB.colIdx).toEqual(colIndex.keys());
|
||||
expect(dfB.colIdx).toEqual(colIndex.labels());
|
||||
expect(dfB.rowIdx).toBeNull();
|
||||
expect(dfB.columns).toEqual(columns);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as Universe from "../../../src/util/stateManager/universe";
|
||||
import { matrixFBSToDataframe } from "../../../src/util/stateManager/matrix";
|
||||
import * as Dataframe from "../../../src/util/dataframe";
|
||||
import * as REST from "./sampleResponses";
|
||||
|
||||
@@ -51,16 +52,13 @@ describe("createUniverseFromResponse", () => {
|
||||
...universe,
|
||||
...Universe.addObsAnnotations(
|
||||
universe,
|
||||
Universe.matrixFBSToDataframe(REST.annotationsObs)
|
||||
matrixFBSToDataframe(REST.annotationsObs)
|
||||
),
|
||||
...Universe.addVarAnnotations(
|
||||
universe,
|
||||
Universe.matrixFBSToDataframe(REST.annotationsVar)
|
||||
),
|
||||
...Universe.addObsLayout(
|
||||
universe,
|
||||
Universe.matrixFBSToDataframe(REST.layoutObs)
|
||||
matrixFBSToDataframe(REST.annotationsVar)
|
||||
),
|
||||
...Universe.addObsLayout(universe, matrixFBSToDataframe(REST.layoutObs)),
|
||||
};
|
||||
|
||||
expect(universe).toMatchObject(
|
||||
@@ -80,7 +78,7 @@ describe("createUniverseFromResponse", () => {
|
||||
REST.schema.schema.annotations.obs.columns.length,
|
||||
]);
|
||||
expect(universe.obsLayout.dims).toEqual([nObs, 2]);
|
||||
expect(universe.obsLayout.colIndex.keys()).toEqual(
|
||||
expect(universe.obsLayout.colIndex.labels()).toEqual(
|
||||
universe.schema.layout.obs[0].dims
|
||||
);
|
||||
expect(universe.varAnnotations.dims).toEqual([
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from "lodash";
|
||||
import * as Universe from "../../../src/util/stateManager/universe";
|
||||
import { matrixFBSToDataframe } from "../../../src/util/stateManager/matrix";
|
||||
import * as World from "../../../src/util/stateManager/world";
|
||||
import * as Dataframe from "../../../src/util/dataframe";
|
||||
import Crossfilter from "../../../src/util/typedCrossfilter";
|
||||
@@ -26,16 +27,13 @@ const defaultBigBang = () => {
|
||||
...universe,
|
||||
...Universe.addObsAnnotations(
|
||||
universe,
|
||||
Universe.matrixFBSToDataframe(REST.annotationsObs)
|
||||
matrixFBSToDataframe(REST.annotationsObs)
|
||||
),
|
||||
...Universe.addVarAnnotations(
|
||||
universe,
|
||||
Universe.matrixFBSToDataframe(REST.annotationsVar)
|
||||
),
|
||||
...Universe.addObsLayout(
|
||||
universe,
|
||||
Universe.matrixFBSToDataframe(REST.layoutObs)
|
||||
matrixFBSToDataframe(REST.annotationsVar)
|
||||
),
|
||||
...Universe.addObsLayout(universe, matrixFBSToDataframe(REST.layoutObs)),
|
||||
};
|
||||
|
||||
/* create world */
|
||||
@@ -59,9 +57,9 @@ describe("createWorldFromEntireUniverse", () => {
|
||||
const universe = Universe.createUniverseFromResponse(
|
||||
_.cloneDeep(REST.config),
|
||||
_.cloneDeep(REST.schema),
|
||||
Universe.matrixFBSToDataframe(_.cloneDeep(REST.annotationsObs)),
|
||||
Universe.matrixFBSToDataframe(_.cloneDeep(REST.annotationsVar)),
|
||||
Universe.matrixFBSToDataframe(_.cloneDeep(REST.layoutObs))
|
||||
matrixFBSToDataframe(_.cloneDeep(REST.annotationsObs)),
|
||||
matrixFBSToDataframe(_.cloneDeep(REST.annotationsVar)),
|
||||
matrixFBSToDataframe(_.cloneDeep(REST.layoutObs))
|
||||
);
|
||||
expect(universe).toBeDefined();
|
||||
|
||||
@@ -144,16 +142,16 @@ describe("createWorldFromCurrentSelection", () => {
|
||||
})
|
||||
);
|
||||
|
||||
expect(world.obsAnnotations.rowIndex.keys()).toEqual(
|
||||
expect(world.obsAnnotations.rowIndex.labels()).toEqual(
|
||||
new Int32Array(matchingIndices)
|
||||
);
|
||||
expect(world.obsAnnotations.colIndex.keys()).toEqual(
|
||||
universe.obsAnnotations.colIndex.keys()
|
||||
expect(world.obsAnnotations.colIndex.labels()).toEqual(
|
||||
universe.obsAnnotations.colIndex.labels()
|
||||
);
|
||||
expect(world.obsLayout.rowIndex.keys()).toEqual(
|
||||
expect(world.obsLayout.rowIndex.labels()).toEqual(
|
||||
new Int32Array(matchingIndices)
|
||||
);
|
||||
expect(world.obsLayout.colIndex.keys()).toEqual(
|
||||
expect(world.obsLayout.colIndex.labels()).toEqual(
|
||||
world.schema.layout.obs[0].dims
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user