mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-23 13:18:12 +08:00
934cc5c69b
* Added TS. Updated build and linting config. Added types. * [ts-migrate][.] Rename files from JS/JSX to TS/TSX Co-authored-by: ts-migrate <> * [ts-migrate][.] Run TS Migrate Co-authored-by: ts-migrate <> * Corrected files mangled by ts-migrate. * Updated lint config, minor linting. * Re-enabled Husky. * Updated tests and config. * Reverted webpack devtool config. * Removed obsolete snapshots. * Added annotations snap. * Updated tsconfig includes wrt linting. * Removed ts-migrate. Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
/*
|
|
test FBS encode/decode API
|
|
*/
|
|
import { Dataframe, KeyIndex } from "../../../src/util/dataframe";
|
|
import {
|
|
decodeMatrixFBS,
|
|
encodeMatrixFBS,
|
|
} from "../../../src/util/stateManager/matrix";
|
|
|
|
describe("encode/decode", () => {
|
|
test("round trip", () => {
|
|
const columns = [
|
|
["red", "green", "blue"],
|
|
new Int32Array(3).fill(0),
|
|
new Uint32Array(3).fill(1),
|
|
new Float32Array(3).fill(2),
|
|
];
|
|
|
|
const dfNoColIdx = new Dataframe([3, 4], columns);
|
|
const dfA = decodeMatrixFBS(encodeMatrixFBS(dfNoColIdx));
|
|
expect([dfA.nRows, dfA.nCols]).toEqual(dfNoColIdx.dims);
|
|
expect(dfA.colIdx).toBeNull();
|
|
expect(dfA.rowIdx).toBeNull();
|
|
expect(dfA.columns).toEqual(columns);
|
|
|
|
const colIndex = new KeyIndex(["a", "b", "c", "d"]);
|
|
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'KeyIndex' is not assignable to p... Remove this comment to see the full error message
|
|
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.labels());
|
|
expect(dfB.rowIdx).toBeNull();
|
|
expect(dfB.columns).toEqual(columns);
|
|
});
|
|
});
|