mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-05 05:18:12 +08:00
* 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>
This commit is contained in:
co-authored by
ts-migrate
Timmy Huang
parent
7328cbdbd5
commit
934cc5c69b
+76
-42
@@ -18,12 +18,17 @@ import {
|
||||
|
||||
import { appUrlBase, TEST_EMAIL, TEST_PASSWORD } from "./config";
|
||||
|
||||
export async function drag(testId, start, end, lasso = false) {
|
||||
export async function drag(testId: any, start: any, end: any, lasso = false) {
|
||||
const layout = await waitByID(testId);
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const elBox = await layout.boxModel();
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const x1 = elBox.content[0].x + start.x;
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const x2 = elBox.content[0].x + end.x;
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const y1 = elBox.content[0].y + start.y;
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const y2 = elBox.content[0].y + end.y;
|
||||
await page.mouse.move(x1, y1);
|
||||
await page.mouse.down();
|
||||
@@ -38,7 +43,7 @@ export async function drag(testId, start, end, lasso = false) {
|
||||
await page.mouse.up();
|
||||
}
|
||||
|
||||
export async function clickOnCoordinate(testId, coord) {
|
||||
export async function clickOnCoordinate(testId: any, coord: any) {
|
||||
const layout = await expect(page).toMatchElement(getTestId(testId));
|
||||
const elBox = await layout.boxModel();
|
||||
|
||||
@@ -51,11 +56,12 @@ export async function clickOnCoordinate(testId, coord) {
|
||||
await page.mouse.click(x, y);
|
||||
}
|
||||
|
||||
export async function getAllHistograms(testclass, testIds) {
|
||||
const histTestIds = testIds.map((tid) => `histogram-${tid}`);
|
||||
export async function getAllHistograms(testclass: any, testIds: any) {
|
||||
const histTestIds = testIds.map((tid: any) => `histogram-${tid}`);
|
||||
|
||||
// these load asynchronously, so we need to wait for each histogram individually,
|
||||
// and they may be quite slow in some cases.
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 2.
|
||||
await waitForAllByIds(histTestIds, { timeout: 4 * 60 * 1000 });
|
||||
|
||||
const allHistograms = await getAllByClass(testclass);
|
||||
@@ -71,7 +77,7 @@ export async function getAllHistograms(testclass, testIds) {
|
||||
return testIDs.map((id) => id.replace(/^histogram-/, ""));
|
||||
}
|
||||
|
||||
export async function getAllCategoriesAndCounts(category) {
|
||||
export async function getAllCategoriesAndCounts(category: any) {
|
||||
// these load asynchronously, so we have to wait for the specific category.
|
||||
await waitByID(`category-${category}`);
|
||||
|
||||
@@ -80,13 +86,14 @@ export async function getAllCategoriesAndCounts(category) {
|
||||
(rows) =>
|
||||
Object.fromEntries(
|
||||
rows.map((row) => {
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const cat = row
|
||||
.querySelector("[data-testclass='categorical-value']")
|
||||
.getAttribute("aria-label");
|
||||
|
||||
const count = row.querySelector(
|
||||
const count = (row.querySelector(
|
||||
"[data-testclass='categorical-value-count']"
|
||||
).innerText;
|
||||
) as any).innerText;
|
||||
|
||||
return [cat, count];
|
||||
})
|
||||
@@ -94,12 +101,12 @@ export async function getAllCategoriesAndCounts(category) {
|
||||
);
|
||||
}
|
||||
|
||||
export async function getCellSetCount(num) {
|
||||
export async function getCellSetCount(num: any) {
|
||||
await clickOn(`cellset-button-${num}`);
|
||||
return getOneElementInnerText(`[data-testid='cellset-count-${num}']`);
|
||||
}
|
||||
|
||||
export async function resetCategory(category) {
|
||||
export async function resetCategory(category: any) {
|
||||
const checkboxId = `${category}:category-select`;
|
||||
await waitByID(checkboxId);
|
||||
const checkedPseudoclass = await page.$eval(
|
||||
@@ -110,6 +117,7 @@ export async function resetCategory(category) {
|
||||
|
||||
const categoryRow = await waitByID(`${category}:category-expand`);
|
||||
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const isExpanded = await categoryRow.$(
|
||||
"[data-testclass='category-expand-is-expanded']"
|
||||
);
|
||||
@@ -117,16 +125,26 @@ export async function resetCategory(category) {
|
||||
if (isExpanded) await clickOn(`${category}:category-expand`);
|
||||
}
|
||||
|
||||
export async function calcCoordinate(testId, xAsPercent, yAsPercent) {
|
||||
export async function calcCoordinate(
|
||||
testId: any,
|
||||
xAsPercent: any,
|
||||
yAsPercent: any
|
||||
) {
|
||||
const el = await waitByID(testId);
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const size = await el.boxModel();
|
||||
return {
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
x: Math.floor(size.width * xAsPercent),
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
y: Math.floor(size.height * yAsPercent),
|
||||
};
|
||||
}
|
||||
|
||||
export async function calcDragCoordinates(testId, coordinateAsPercent) {
|
||||
export async function calcDragCoordinates(
|
||||
testId: any,
|
||||
coordinateAsPercent: any
|
||||
) {
|
||||
return {
|
||||
start: await calcCoordinate(
|
||||
testId,
|
||||
@@ -141,7 +159,7 @@ export async function calcDragCoordinates(testId, coordinateAsPercent) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function selectCategory(category, values, reset = true) {
|
||||
export async function selectCategory(category: any, values: any, reset = true) {
|
||||
if (reset) await resetCategory(category);
|
||||
|
||||
await clickOn(`${category}:category-expand`);
|
||||
@@ -152,8 +170,9 @@ export async function selectCategory(category, values, reset = true) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function expandCategory(category) {
|
||||
export async function expandCategory(category: any) {
|
||||
const expand = await waitByID(`${category}:category-expand`);
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const notExpanded = await expand.$(
|
||||
"[data-testclass='category-expand-is-not-expanded']"
|
||||
);
|
||||
@@ -167,7 +186,7 @@ export async function clip(min = 0, max = 100) {
|
||||
await clickOn("clip-commit");
|
||||
}
|
||||
|
||||
export async function createCategory(categoryName) {
|
||||
export async function createCategory(categoryName: any) {
|
||||
await clickOnUntil("open-annotation-dialog", async () => {
|
||||
await expect(page).toMatchElement(getTestId("new-category-name"));
|
||||
});
|
||||
@@ -182,17 +201,18 @@ export async function createCategory(categoryName) {
|
||||
|
||||
*/
|
||||
|
||||
export async function colorByGeneset(genesetName) {
|
||||
export async function colorByGeneset(genesetName: any) {
|
||||
await clickOn(`${genesetName}:colorby-entire-geneset`);
|
||||
}
|
||||
|
||||
export async function colorByGene(gene) {
|
||||
export async function colorByGene(gene: any) {
|
||||
await clickOn(`colorby-${gene}`);
|
||||
}
|
||||
|
||||
export async function assertColorLegendLabel(label) {
|
||||
export async function assertColorLegendLabel(label: any) {
|
||||
const handle = await waitByID("continuous_legend_color_by_label");
|
||||
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const result = await handle.evaluate((node) => {
|
||||
return node.getAttribute("aria-label");
|
||||
});
|
||||
@@ -200,15 +220,16 @@ export async function assertColorLegendLabel(label) {
|
||||
return expect(result).toBe(label);
|
||||
}
|
||||
|
||||
export async function expandGeneset(genesetName) {
|
||||
export async function expandGeneset(genesetName: any) {
|
||||
const expand = await waitByID(`${genesetName}:geneset-expand`);
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const notExpanded = await expand.$(
|
||||
"[data-testclass='geneset-expand-is-not-expanded']"
|
||||
);
|
||||
if (notExpanded) await clickOn(`${genesetName}:geneset-expand`);
|
||||
}
|
||||
|
||||
export async function createGeneset(genesetName) {
|
||||
export async function createGeneset(genesetName: any) {
|
||||
await clickOnUntil("open-create-geneset-dialog", async () => {
|
||||
await expect(page).toMatchElement(getTestId("create-geneset-input"));
|
||||
});
|
||||
@@ -218,7 +239,7 @@ export async function createGeneset(genesetName) {
|
||||
await waitByClass("autosave-complete");
|
||||
}
|
||||
|
||||
export async function editGenesetName(genesetName, editText) {
|
||||
export async function editGenesetName(genesetName: any, editText: any) {
|
||||
const editButton = `${genesetName}:edit-genesetName-mode`;
|
||||
const submitButton = `${genesetName}:submit-geneset`;
|
||||
await clickOnUntil(`${genesetName}:see-actions`, async () => {
|
||||
@@ -229,7 +250,7 @@ export async function editGenesetName(genesetName, editText) {
|
||||
await clickOn(submitButton);
|
||||
}
|
||||
|
||||
export async function deleteGeneset(genesetName) {
|
||||
export async function deleteGeneset(genesetName: any) {
|
||||
const targetId = `${genesetName}:delete-geneset`;
|
||||
|
||||
await clickOnUntil(`${genesetName}:see-actions`, async () => {
|
||||
@@ -242,16 +263,18 @@ export async function deleteGeneset(genesetName) {
|
||||
await waitByClass("autosave-complete");
|
||||
}
|
||||
|
||||
export async function assertGenesetDoesNotExist(genesetName) {
|
||||
export async function assertGenesetDoesNotExist(genesetName: any) {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const result = await isElementPresent(
|
||||
getTestId(`${genesetName}:geneset-name`)
|
||||
);
|
||||
await expect(result).toBe(false);
|
||||
}
|
||||
|
||||
export async function assertGenesetExists(genesetName) {
|
||||
export async function assertGenesetExists(genesetName: any) {
|
||||
const handle = await waitByID(`${genesetName}:geneset-name`);
|
||||
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const result = await handle.evaluate((node) => {
|
||||
return node.getAttribute("aria-label");
|
||||
});
|
||||
@@ -265,7 +288,7 @@ export async function assertGenesetExists(genesetName) {
|
||||
|
||||
*/
|
||||
|
||||
export async function addGeneToSet(genesetName, geneToAddToSet) {
|
||||
export async function addGeneToSet(genesetName: any, geneToAddToSet: any) {
|
||||
const submitButton = `${genesetName}:submit-gene`;
|
||||
|
||||
await clickOn(`${genesetName}:add-new-gene-to-geneset`);
|
||||
@@ -273,7 +296,7 @@ export async function addGeneToSet(genesetName, geneToAddToSet) {
|
||||
await clickOn(submitButton);
|
||||
}
|
||||
|
||||
export async function removeGene(geneSymbol) {
|
||||
export async function removeGene(geneSymbol: any) {
|
||||
const targetId = `delete-from-geneset:${geneSymbol}`;
|
||||
|
||||
await clickOn(targetId);
|
||||
@@ -281,9 +304,10 @@ export async function removeGene(geneSymbol) {
|
||||
await waitByClass("autosave-complete");
|
||||
}
|
||||
|
||||
export async function assertGeneExistsInGeneset(geneSymbol) {
|
||||
export async function assertGeneExistsInGeneset(geneSymbol: any) {
|
||||
const handle = await waitByID(`${geneSymbol}:gene-label`);
|
||||
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const result = await handle.evaluate((node) => {
|
||||
return node.getAttribute("aria-label");
|
||||
});
|
||||
@@ -291,13 +315,14 @@ export async function assertGeneExistsInGeneset(geneSymbol) {
|
||||
return expect(result).toBe(geneSymbol);
|
||||
}
|
||||
|
||||
export async function assertGeneDoesNotExist(geneSymbol) {
|
||||
export async function assertGeneDoesNotExist(geneSymbol: any) {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const result = await isElementPresent(getTestId(`${geneSymbol}:gene-label`));
|
||||
|
||||
await expect(result).toBe(false);
|
||||
}
|
||||
|
||||
export async function expandGene(geneSymbol) {
|
||||
export async function expandGene(geneSymbol: any) {
|
||||
await clickOn(`maximize-${geneSymbol}`);
|
||||
}
|
||||
|
||||
@@ -307,7 +332,7 @@ export async function expandGene(geneSymbol) {
|
||||
|
||||
*/
|
||||
|
||||
export async function duplicateCategory(categoryName) {
|
||||
export async function duplicateCategory(categoryName: any) {
|
||||
await clickOn("open-annotation-dialog");
|
||||
|
||||
await typeInto("new-category-name", categoryName);
|
||||
@@ -333,7 +358,10 @@ export async function duplicateCategory(categoryName) {
|
||||
await waitByClass("autosave-complete");
|
||||
}
|
||||
|
||||
export async function renameCategory(oldCategoryName, newCategoryName) {
|
||||
export async function renameCategory(
|
||||
oldCategoryName: any,
|
||||
newCategoryName: any
|
||||
) {
|
||||
await clickOn(`${oldCategoryName}:see-actions`);
|
||||
await clickOn(`${oldCategoryName}:edit-category-mode`);
|
||||
await clearInputAndTypeInto(
|
||||
@@ -343,7 +371,7 @@ export async function renameCategory(oldCategoryName, newCategoryName) {
|
||||
await clickOn(`${oldCategoryName}:submit-category-edit`);
|
||||
}
|
||||
|
||||
export async function deleteCategory(categoryName) {
|
||||
export async function deleteCategory(categoryName: any) {
|
||||
const targetId = `${categoryName}:delete-category`;
|
||||
|
||||
await clickOnUntil(`${categoryName}:see-actions`, async () => {
|
||||
@@ -352,10 +380,11 @@ export async function deleteCategory(categoryName) {
|
||||
|
||||
await clickOn(targetId);
|
||||
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
||||
await assertCategoryDoesNotExist();
|
||||
}
|
||||
|
||||
export async function createLabel(categoryName, labelName) {
|
||||
export async function createLabel(categoryName: any, labelName: any) {
|
||||
/**
|
||||
* (thuang): This explicit wait is needed, since currently showing
|
||||
* the modal again quickly after the previous action dismissing the
|
||||
@@ -380,13 +409,17 @@ export async function createLabel(categoryName, labelName) {
|
||||
await clickOn(`${categoryName}:submit-label`);
|
||||
}
|
||||
|
||||
export async function deleteLabel(categoryName, labelName) {
|
||||
export async function deleteLabel(categoryName: any, labelName: any) {
|
||||
await expandCategory(categoryName);
|
||||
await clickOn(`${categoryName}:${labelName}:see-actions`);
|
||||
await clickOn(`${categoryName}:${labelName}:delete-label`);
|
||||
}
|
||||
|
||||
export async function renameLabel(categoryName, oldLabelName, newLabelName) {
|
||||
export async function renameLabel(
|
||||
categoryName: any,
|
||||
oldLabelName: any,
|
||||
newLabelName: any
|
||||
) {
|
||||
await expandCategory(categoryName);
|
||||
await clickOn(`${categoryName}:${oldLabelName}:see-actions`);
|
||||
await clickOn(`${categoryName}:${oldLabelName}:edit-label`);
|
||||
@@ -397,13 +430,13 @@ export async function renameLabel(categoryName, oldLabelName, newLabelName) {
|
||||
await clickOn(`${categoryName}:${oldLabelName}:submit-label-edit`);
|
||||
}
|
||||
|
||||
export async function addGeneToSearch(geneName) {
|
||||
export async function addGeneToSearch(geneName: any) {
|
||||
await typeInto("gene-search", geneName);
|
||||
await page.keyboard.press("Enter");
|
||||
await page.waitForSelector(`[data-testid='histogram-${geneName}']`);
|
||||
}
|
||||
|
||||
export async function subset(coordinatesAsPercent) {
|
||||
export async function subset(coordinatesAsPercent: any) {
|
||||
// In order to deselect the selection after the subset, make sure we have some clear part
|
||||
// of the scatterplot we can click on
|
||||
assert(coordinatesAsPercent.x2 < 0.99 || coordinatesAsPercent.y2 < 0.99);
|
||||
@@ -417,8 +450,8 @@ export async function subset(coordinatesAsPercent) {
|
||||
await clickOnCoordinate("layout-graph", clearCoordinate);
|
||||
}
|
||||
|
||||
export async function setSellSet(cellSet, cellSetNum) {
|
||||
const selections = cellSet.filter((sel) => sel.kind === "categorical");
|
||||
export async function setSellSet(cellSet: any, cellSetNum: any) {
|
||||
const selections = cellSet.filter((sel: any) => sel.kind === "categorical");
|
||||
|
||||
for (const selection of selections) {
|
||||
await selectCategory(selection.metadata, selection.values, true);
|
||||
@@ -427,19 +460,20 @@ export async function setSellSet(cellSet, cellSetNum) {
|
||||
await getCellSetCount(cellSetNum);
|
||||
}
|
||||
|
||||
export async function runDiffExp(cellSet1, cellSet2) {
|
||||
export async function runDiffExp(cellSet1: any, cellSet2: any) {
|
||||
await setSellSet(cellSet1, 1);
|
||||
await setSellSet(cellSet2, 2);
|
||||
await clickOn("diffexp-button");
|
||||
}
|
||||
|
||||
export async function bulkAddGenes(geneNames) {
|
||||
export async function bulkAddGenes(geneNames: any) {
|
||||
await clickOn("section-bulk-add");
|
||||
await typeInto("input-bulk-add", geneNames.join(","));
|
||||
await page.keyboard.press("Enter");
|
||||
}
|
||||
|
||||
export async function assertCategoryDoesNotExist(categoryName) {
|
||||
export async function assertCategoryDoesNotExist(categoryName: any) {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const result = await isElementPresent(
|
||||
getTestId(`${categoryName}:category-label`)
|
||||
);
|
||||
@@ -480,7 +514,7 @@ export async function logout() {
|
||||
await waitByID("log-in");
|
||||
}
|
||||
|
||||
async function waitUntilFormFieldStable(selector) {
|
||||
async function waitUntilFormFieldStable(selector: any) {
|
||||
const MAX_RETRY = 10;
|
||||
const WAIT_FOR_MS = 200;
|
||||
|
||||
@@ -58,10 +58,12 @@ describe("metadata loads", () => {
|
||||
const categories = await getAllCategoriesAndCounts(label);
|
||||
|
||||
expect(Object.keys(categories)).toMatchObject(
|
||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
||||
Object.keys(data.categorical[label])
|
||||
);
|
||||
|
||||
expect(Object.values(categories)).toMatchObject(
|
||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
||||
Object.values(data.categorical[label])
|
||||
);
|
||||
}
|
||||
@@ -159,10 +161,12 @@ describe("subset", () => {
|
||||
const categories = await getAllCategoriesAndCounts(label);
|
||||
|
||||
expect(Object.keys(categories)).toMatchObject(
|
||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
||||
Object.keys(data.subset.categorical[label])
|
||||
);
|
||||
|
||||
expect(Object.values(categories)).toMatchObject(
|
||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
||||
Object.values(data.subset.categorical[label])
|
||||
);
|
||||
}
|
||||
@@ -195,6 +199,7 @@ describe("clipping", () => {
|
||||
test("clip continuous", async () => {
|
||||
await goToPage(appUrlBase);
|
||||
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
|
||||
await clip(data.clip.min, data.clip.max);
|
||||
const histBrushableAreaId = `histogram-${data.clip.metadata}-plot-brushable-area`;
|
||||
const coords = await calcDragCoordinates(
|
||||
@@ -254,6 +259,7 @@ describe("centroid labels", () => {
|
||||
const generatedLabels = await getAllByClass("centroid-label");
|
||||
// Number of labels generated should be equal to size of the object
|
||||
expect(generatedLabels).toHaveLength(
|
||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
||||
Object.keys(data.categorical[label]).length
|
||||
);
|
||||
}
|
||||
@@ -275,6 +281,7 @@ describe("graph overlay", () => {
|
||||
data.pan["coordinates-as-percent"]
|
||||
);
|
||||
|
||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
||||
const categoryValue = Object.keys(data.categorical[category])[0];
|
||||
const initialCoordinates = await getElementCoordinates(
|
||||
`${categoryValue}-centroid-label`
|
||||
+18
-8
@@ -76,7 +76,7 @@ const brushThisGeneGeneset = "brush_this_gene";
|
||||
const geneBrushedCellCount = "109";
|
||||
const subsetGeneBrushedCellCount = "96";
|
||||
|
||||
async function setup(config) {
|
||||
async function setup(config: any) {
|
||||
await goToPage(appUrlBase);
|
||||
|
||||
if (config.categoricalAnno) {
|
||||
@@ -150,7 +150,7 @@ describe.each([
|
||||
await expect(page).toClick(getTestClass("pop-1-geneset-expand"));
|
||||
|
||||
await page.waitForFunction(
|
||||
(selector) => !document.querySelector(selector),
|
||||
(selector: any) => !document.querySelector(selector),
|
||||
{},
|
||||
getTestClass("gene-loading-spinner")
|
||||
);
|
||||
@@ -165,7 +165,7 @@ describe.each([
|
||||
await expect(page).toClick(getTestClass("pop-2-geneset-expand"));
|
||||
|
||||
await page.waitForFunction(
|
||||
(selector) => !document.querySelector(selector),
|
||||
(selector: any) => !document.querySelector(selector),
|
||||
{},
|
||||
getTestClass("gene-loading-spinner")
|
||||
);
|
||||
@@ -362,8 +362,11 @@ describe.each([
|
||||
expect(actualLabelName).toBe(expectedLabelName);
|
||||
expect(actualLabelCount).toBe(expectedLabelCount);
|
||||
|
||||
async function getInnerText(element, className) {
|
||||
return element.$eval(getTestClass(className), (node) => node?.innerText);
|
||||
async function getInnerText(element: any, className: any) {
|
||||
return element.$eval(
|
||||
getTestClass(className),
|
||||
(node: any) => node?.innerText
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -388,7 +391,9 @@ describe.each([
|
||||
`categorical-value-count-${perTestCategoryName}-${perTestLabelName}`
|
||||
);
|
||||
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
expect(await result.evaluate((node) => node.innerText)).toBe(
|
||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'boolean' cannot be used as an index type.
|
||||
data.categoryLabel.newCount.bySubsetConfig[config.withSubset]
|
||||
);
|
||||
});
|
||||
@@ -448,6 +453,7 @@ describe.each([
|
||||
await createLabel(perTestCategoryName, labelName);
|
||||
await assertLabelExists(perTestCategoryName, labelName);
|
||||
await clickOn("undo");
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
await assertLabelDoesNotExist(perTestCategoryName);
|
||||
await clickOn("redo");
|
||||
await assertLabelExists(perTestCategoryName, labelName);
|
||||
@@ -457,10 +463,12 @@ describe.each([
|
||||
await setup(config);
|
||||
|
||||
await deleteLabel(perTestCategoryName, perTestLabelName);
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
await assertLabelDoesNotExist(perTestCategoryName);
|
||||
await clickOn("undo");
|
||||
await assertLabelExists(perTestCategoryName, perTestLabelName);
|
||||
await clickOn("redo");
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
await assertLabelDoesNotExist(perTestCategoryName);
|
||||
});
|
||||
|
||||
@@ -523,9 +531,10 @@ describe.each([
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
async function assertCategoryExists(categoryName) {
|
||||
async function assertCategoryExists(categoryName: any) {
|
||||
const handle = await waitByID(`${categoryName}:category-label`);
|
||||
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const result = await handle.evaluate((node) =>
|
||||
node.getAttribute("aria-label")
|
||||
);
|
||||
@@ -533,7 +542,7 @@ describe.each([
|
||||
return expect(result).toBe(categoryName);
|
||||
}
|
||||
|
||||
async function assertLabelExists(categoryName, labelName) {
|
||||
async function assertLabelExists(categoryName: any, labelName: any) {
|
||||
await expect(page).toMatchElement(
|
||||
getTestId(`${categoryName}:category-expand`)
|
||||
);
|
||||
@@ -545,11 +554,12 @@ describe.each([
|
||||
);
|
||||
|
||||
expect(
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
await previous.evaluate((node) => node.getAttribute("aria-label"))
|
||||
).toBe(labelName);
|
||||
}
|
||||
|
||||
async function assertLabelDoesNotExist(categoryName, labelName) {
|
||||
async function assertLabelDoesNotExist(categoryName: any, labelName: any) {
|
||||
await expandCategory(categoryName);
|
||||
const result = await page.$(
|
||||
`[data-testid='categorical-value-${categoryName}-${labelName}']`
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"testRunner": "jest-circus/runner",
|
||||
"preset": "jest-puppeteer",
|
||||
"testMatch": ["**/__tests__/**/?(*.)(spec|test).js?(x)"],
|
||||
"setupFiles": ["../setupMissingGlobals.js"],
|
||||
"setupFilesAfterEnv": ["expect-puppeteer", "./puppeteer.setup.js"],
|
||||
"globalSetup": "../globalSetup.js",
|
||||
"testMatch": ["**/__tests__/**/?(*.)(spec|test).ts?(x)"],
|
||||
"setupFiles": ["../setupMissingGlobals.ts"],
|
||||
"setupFilesAfterEnv": ["expect-puppeteer", "./puppeteer.setup.ts"],
|
||||
"globalSetup": "../globalSetup.ts",
|
||||
"globalTeardown": "jest-environment-puppeteer/teardown",
|
||||
"testEnvironment": "./screenshot_env.js"
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ beforeEach(async () => {
|
||||
const userAgent = await browser.userAgent();
|
||||
await page.setUserAgent(`${userAgent}bot`);
|
||||
|
||||
// @ts-expect-error ts-migrate(2341) FIXME: Property '_client' is private and only accessible ... Remove this comment to see the full error message
|
||||
await page._client.send("Animation.setPlaybackRate", { playbackRate: 12 });
|
||||
|
||||
page.on("pageerror", (err) => {
|
||||
@@ -49,7 +50,7 @@ beforeEach(async () => {
|
||||
}
|
||||
const errorMsgText = await Promise.all(
|
||||
// TODO can we do this without internal properties?
|
||||
msg.args().map((arg) => arg._remoteObject.description)
|
||||
msg.args().map((arg: any) => arg._remoteObject.description)
|
||||
);
|
||||
throw new Error(`Console error: ${errorMsgText}`);
|
||||
}
|
||||
@@ -1,31 +1,31 @@
|
||||
/* eslint-disable no-await-in-loop -- await in loop is needed to emulate sequential user actions */
|
||||
export function getTestId(id) {
|
||||
export function getTestId(id: any) {
|
||||
return `[data-testid='${id}']`;
|
||||
}
|
||||
|
||||
export function getTestClass(className) {
|
||||
export function getTestClass(className: any) {
|
||||
return `[data-testclass='${className}']`;
|
||||
}
|
||||
|
||||
export async function waitByID(testId, props = {}) {
|
||||
export async function waitByID(testId: any, props = {}) {
|
||||
return page.waitForSelector(getTestId(testId), props);
|
||||
}
|
||||
|
||||
export async function waitByClass(testClass, props = {}) {
|
||||
export async function waitByClass(testClass: any, props = {}) {
|
||||
return page.waitForSelector(`[data-testclass='${testClass}']`, props);
|
||||
}
|
||||
|
||||
export async function waitForAllByIds(testIds) {
|
||||
export async function waitForAllByIds(testIds: any) {
|
||||
await Promise.all(
|
||||
testIds.map((testId) => page.waitForSelector(getTestId(testId)))
|
||||
testIds.map((testId: any) => page.waitForSelector(getTestId(testId)))
|
||||
);
|
||||
}
|
||||
|
||||
export async function getAllByClass(testClass) {
|
||||
export async function getAllByClass(testClass: any) {
|
||||
return page.$$(`[data-testclass=${testClass}]`);
|
||||
}
|
||||
|
||||
export async function typeInto(testId, text) {
|
||||
export async function typeInto(testId: any, text: any) {
|
||||
// blueprint's typeahead is treating typing weird, clicking & waiting first solves this
|
||||
// only works for text without special characters
|
||||
await waitByID(testId);
|
||||
@@ -36,7 +36,7 @@ export async function typeInto(testId, text) {
|
||||
await page.type(selector, text);
|
||||
}
|
||||
|
||||
export async function clearInputAndTypeInto(testId, text) {
|
||||
export async function clearInputAndTypeInto(testId: any, text: any) {
|
||||
await waitByID(testId);
|
||||
const selector = getTestId(testId);
|
||||
// only works for text without special characters
|
||||
@@ -49,7 +49,7 @@ export async function clearInputAndTypeInto(testId, text) {
|
||||
await page.type(selector, text);
|
||||
}
|
||||
|
||||
export async function clickOn(testId, options = {}) {
|
||||
export async function clickOn(testId: any, options = {}) {
|
||||
await expect(page).toClick(getTestId(testId), options);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export async function clickOn(testId, options = {}) {
|
||||
* (thuang): There are times when Puppeteer clicks on a button and the page doesn't respond.
|
||||
* So I added clickOnUntil() to retry clicking until a given condition is met.
|
||||
*/
|
||||
export async function clickOnUntil(testId, assert) {
|
||||
export async function clickOnUntil(testId: any, assert: any) {
|
||||
const MAX_RETRY = 10;
|
||||
const WAIT_FOR_MS = 200;
|
||||
|
||||
@@ -81,19 +81,19 @@ export async function clickOnUntil(testId, assert) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getOneElementInnerHTML(selector, options = {}) {
|
||||
export async function getOneElementInnerHTML(selector: any, options = {}) {
|
||||
await page.waitForSelector(selector, options);
|
||||
|
||||
return page.$eval(selector, (el) => el.innerHTML);
|
||||
}
|
||||
|
||||
export async function getOneElementInnerText(selector) {
|
||||
export async function getOneElementInnerText(selector: any) {
|
||||
expect(page).toMatchElement(selector);
|
||||
|
||||
return page.$eval(selector, (el) => el.innerText);
|
||||
return page.$eval(selector, (el) => (el as any).innerText);
|
||||
}
|
||||
|
||||
export async function getElementCoordinates(testId) {
|
||||
export async function getElementCoordinates(testId: any) {
|
||||
return page.$eval(getTestId(testId), (elem) => {
|
||||
const { left, top } = elem.getBoundingClientRect();
|
||||
return [left, top];
|
||||
@@ -101,12 +101,14 @@ export async function getElementCoordinates(testId) {
|
||||
}
|
||||
|
||||
async function clickTermsOfService() {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
if (!(await isElementPresent(getTestId("tos-cookies-accept")))) return;
|
||||
|
||||
await clickOn("tos-cookies-accept");
|
||||
}
|
||||
|
||||
async function nameNewAnnotation() {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
if (await isElementPresent(getTestId("annotation-dialog"))) {
|
||||
await typeInto("new-annotation-name", "ignoreE2E");
|
||||
await clickOn("submit-annotation");
|
||||
@@ -116,7 +118,7 @@ async function nameNewAnnotation() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function goToPage(url) {
|
||||
export async function goToPage(url: any) {
|
||||
await page.goto(url, {
|
||||
waitUntil: "networkidle0",
|
||||
});
|
||||
@@ -125,7 +127,8 @@ export async function goToPage(url) {
|
||||
await clickTermsOfService();
|
||||
}
|
||||
|
||||
export async function isElementPresent(selector, options) {
|
||||
export async function isElementPresent(selector: any, options: any) {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 2.
|
||||
return Boolean(await page.$(selector, options));
|
||||
}
|
||||
/* eslint-enable no-await-in-loop -- await in loop is needed to emulate sequential user actions */
|
||||
@@ -2,6 +2,7 @@ const PuppeteerEnvironment = require("jest-environment-puppeteer");
|
||||
require("jest-circus");
|
||||
const ENV_DEFAULT = require("../../../environment.default.json");
|
||||
|
||||
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'takeScreen... Remove this comment to see the full error message
|
||||
const takeScreenshot = require("./takeScreenshot");
|
||||
|
||||
class ScreenshotEnvironment extends PuppeteerEnvironment {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-ignore FIXME revisit from ts-migrate
|
||||
const {
|
||||
SecretsManagerClient,
|
||||
GetSecretValueCommand,
|
||||
+12
-2
@@ -20,7 +20,12 @@ describe("cascade", () => {
|
||||
const reducer = cascadeReducers([
|
||||
[
|
||||
"foo",
|
||||
(currentState, action, nextSharedState, prevSharedState) => {
|
||||
(
|
||||
currentState: any,
|
||||
action: any,
|
||||
nextSharedState: any,
|
||||
prevSharedState: any
|
||||
) => {
|
||||
expect(currentState).toBeUndefined();
|
||||
expect(action).toEqual(topLevelAction);
|
||||
expect(nextSharedState).toStrictEqual({});
|
||||
@@ -30,7 +35,12 @@ describe("cascade", () => {
|
||||
],
|
||||
[
|
||||
"bar",
|
||||
(currentState, action, nextSharedState, prevSharedState) => {
|
||||
(
|
||||
currentState: any,
|
||||
action: any,
|
||||
nextSharedState: any,
|
||||
prevSharedState: any
|
||||
) => {
|
||||
expect(currentState).toBeUndefined();
|
||||
expect(action).toEqual(topLevelAction);
|
||||
expect(nextSharedState).toStrictEqual({ foo: 0 });
|
||||
+2
@@ -501,6 +501,7 @@ describe("geneset: set tid", () => {
|
||||
test("not a number error", () => {
|
||||
expect(() => {
|
||||
genesetsReducer(
|
||||
// @ts-expect-error ts-migrate(2322) FIXME: Type 'number' is not assignable to type 'undefined... Remove this comment to see the full error message
|
||||
{ lastTid: 1 },
|
||||
{
|
||||
type: "geneset: set tid",
|
||||
@@ -513,6 +514,7 @@ describe("geneset: set tid", () => {
|
||||
test("decrement error", () => {
|
||||
expect(() => {
|
||||
genesetsReducer(
|
||||
// @ts-expect-error ts-migrate(2322) FIXME: Type 'number' is not assignable to type 'undefined... Remove this comment to see the full error message
|
||||
{ lastTid: 1 },
|
||||
{
|
||||
type: "geneset: set tid",
|
||||
+4
-3
@@ -2,6 +2,7 @@ import undoable from "../../src/reducers/undoable";
|
||||
|
||||
describe("create", () => {
|
||||
test("no keys", () => {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2-3 arguments, but got 1.
|
||||
expect(() => undoable(() => {})).toThrow();
|
||||
expect(() => undoable(() => {}, null)).toThrow();
|
||||
expect(() => undoable(() => {}, [])).toThrow();
|
||||
@@ -23,7 +24,7 @@ describe("create", () => {
|
||||
describe("undo", () => {
|
||||
test("expected state modifications", () => {
|
||||
const initialState = { a: 0, b: 1000 };
|
||||
const reducer = (state) => {
|
||||
const reducer = (state: any) => {
|
||||
return { a: state.a + 1, b: state.b + 1 };
|
||||
};
|
||||
const undoableReducer = undoable(reducer, ["a"]);
|
||||
@@ -43,10 +44,10 @@ describe("undo", () => {
|
||||
|
||||
describe("redo", () => {
|
||||
const initialState = { a: 0, b: 1000 };
|
||||
const reducer = (state) => {
|
||||
const reducer = (state: any) => {
|
||||
return { a: state.a + 1, b: state.b + 1 };
|
||||
};
|
||||
let UR;
|
||||
let UR: any;
|
||||
|
||||
beforeEach(() => {
|
||||
UR = undoable(reducer, ["a"]);
|
||||
@@ -5,5 +5,6 @@ the jest test environment).
|
||||
|
||||
import { TextDecoder, TextEncoder } from "util";
|
||||
|
||||
// @ts-expect-error ts-migrate(2322) FIXME: Type 'typeof TextDecoder' is not assignable to typ... Remove this comment to see the full error message
|
||||
global.TextDecoder = TextDecoder;
|
||||
global.TextEncoder = TextEncoder;
|
||||
+22
-17
@@ -14,10 +14,11 @@ import { Dataframe } from "../../../src/util/dataframe";
|
||||
enableFetchMocks();
|
||||
|
||||
describe("AnnoMatrix", () => {
|
||||
let annoMatrix;
|
||||
let annoMatrix: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
fetch.resetMocks(); // reset all fetch mocking state
|
||||
(fetch as any).resetMocks(); // reset all fetch mocking state
|
||||
// reset all fetch mocking state
|
||||
annoMatrix = new AnnoMatrixLoader(
|
||||
serverMocks.baseDataURL,
|
||||
serverMocks.schema.schema
|
||||
@@ -36,7 +37,7 @@ describe("AnnoMatrix", () => {
|
||||
});
|
||||
|
||||
test("simple single column fetch", async () => {
|
||||
fetch.once(serverMocks.annotationsObs(["name_0"]));
|
||||
(fetch as any).once(serverMocks.annotationsObs(["name_0"]));
|
||||
|
||||
const df = await annoMatrix.fetch("obs", "name_0");
|
||||
expect(df).toBeInstanceOf(Dataframe);
|
||||
@@ -45,7 +46,7 @@ describe("AnnoMatrix", () => {
|
||||
});
|
||||
|
||||
test("simple multi column fetch", async () => {
|
||||
fetch
|
||||
(fetch as any)
|
||||
.once(serverMocks.annotationsObs(["name_0"]))
|
||||
.once(serverMocks.annotationsObs(["n_genes"]));
|
||||
|
||||
@@ -55,9 +56,11 @@ describe("AnnoMatrix", () => {
|
||||
});
|
||||
|
||||
describe("fetch from field", () => {
|
||||
const getLastTwo = async (field) => {
|
||||
const getLastTwo = async (field: any) => {
|
||||
const columnNames = annoMatrix.getMatrixColumns(field).slice(-2);
|
||||
fetch.mockResponses(...columnNames.map(() => serverMocks.responder));
|
||||
(fetch as any).mockResponses(
|
||||
...columnNames.map(() => serverMocks.responder)
|
||||
);
|
||||
await expect(
|
||||
annoMatrix.fetch(field, columnNames)
|
||||
).resolves.toBeInstanceOf(Dataframe);
|
||||
@@ -70,19 +73,19 @@ describe("AnnoMatrix", () => {
|
||||
|
||||
test("fetch - test all query forms", async () => {
|
||||
// single string is a column name
|
||||
fetch.once(serverMocks.annotationsObs(["n_genes"]));
|
||||
(fetch as any).once(serverMocks.annotationsObs(["n_genes"]));
|
||||
await expect(annoMatrix.fetch("obs", "n_genes")).resolves.toBeInstanceOf(
|
||||
Dataframe
|
||||
);
|
||||
|
||||
// array of column names, expecting n_genes to be cached.
|
||||
fetch.once(serverMocks.annotationsObs(["percent_mito"]));
|
||||
(fetch as any).once(serverMocks.annotationsObs(["percent_mito"]));
|
||||
await expect(
|
||||
annoMatrix.fetch("obs", ["n_genes", "percent_mito"])
|
||||
).resolves.toBeInstanceOf(Dataframe);
|
||||
|
||||
// more complex value filter query, enumerated
|
||||
fetch.once(serverMocks.responder);
|
||||
(fetch as any).once(serverMocks.responder);
|
||||
await expect(
|
||||
annoMatrix.fetch("X", {
|
||||
where: {
|
||||
@@ -95,7 +98,7 @@ describe("AnnoMatrix", () => {
|
||||
|
||||
// more complex value filter query, range
|
||||
const varIndex = annoMatrix.schema.annotations.var.index;
|
||||
fetch
|
||||
(fetch as any)
|
||||
.once(
|
||||
serverMocks.withExpected("/data/var", [[`var:${varIndex}`, "SUMO3"]])
|
||||
)
|
||||
@@ -171,7 +174,7 @@ describe("AnnoMatrix", () => {
|
||||
expect(am1.nObs).toEqual(am2.nObs);
|
||||
expect(am1.nVar).toEqual(am2.nVar);
|
||||
|
||||
fetch
|
||||
(fetch as any)
|
||||
.once(serverMocks.annotationsObs(["n_genes"]))
|
||||
.once(serverMocks.annotationsObs(["n_genes"]));
|
||||
const ng1 = await am1.fetch("obs", "n_genes");
|
||||
@@ -185,9 +188,10 @@ describe("AnnoMatrix", () => {
|
||||
});
|
||||
|
||||
describe("add/drop column", () => {
|
||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'base' implicitly has an 'any' type.
|
||||
async function addDrop(base) {
|
||||
expect(base.getMatrixColumns("obs")).not.toContain("foo");
|
||||
fetch.mockRejectOnce(new Error("unknown column name"));
|
||||
(fetch as any).mockRejectOnce(new Error("unknown column name"));
|
||||
await expect(base.fetch("obs", "foo")).rejects.toThrow(
|
||||
"unknown column name"
|
||||
);
|
||||
@@ -212,7 +216,7 @@ describe("AnnoMatrix", () => {
|
||||
const am2 = am1.dropObsColumn("foo");
|
||||
expect(base.getMatrixColumns("obs")).not.toContain("foo");
|
||||
expect(am2.getMatrixColumns("obs")).not.toContain("foo");
|
||||
fetch.mockRejectOnce(new Error("unknown column name"));
|
||||
(fetch as any).mockRejectOnce(new Error("unknown column name"));
|
||||
await expect(am2.fetch("obs", "foo")).rejects.toThrow(
|
||||
"unknown column name"
|
||||
);
|
||||
@@ -235,14 +239,14 @@ describe("AnnoMatrix", () => {
|
||||
const am4 = clip(am3, 0, 1);
|
||||
await addDrop(am4);
|
||||
|
||||
fetch.mockResponse(serverMocks.responder);
|
||||
(fetch as any).mockResponse(serverMocks.responder);
|
||||
|
||||
await am1.fetch("obs", am1.getMatrixColumns("obs"));
|
||||
await am2.fetch("obs", am2.getMatrixColumns("obs"));
|
||||
await am3.fetch("obs", am3.getMatrixColumns("obs"));
|
||||
await am4.fetch("obs", am4.getMatrixColumns("obs"));
|
||||
|
||||
fetch.resetMocks();
|
||||
(fetch as any).resetMocks();
|
||||
|
||||
await addDrop(am1);
|
||||
await addDrop(am2);
|
||||
@@ -252,6 +256,7 @@ describe("AnnoMatrix", () => {
|
||||
});
|
||||
|
||||
describe("setObsColumnValues", () => {
|
||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'base' implicitly has an 'any' type.
|
||||
async function addSetDrop(base) {
|
||||
/* add column */
|
||||
let am = base.addObsColumn(
|
||||
@@ -287,7 +292,7 @@ describe("AnnoMatrix", () => {
|
||||
);
|
||||
|
||||
/* drop column */
|
||||
fetch.mockRejectOnce(new Error("unknown column name"));
|
||||
(fetch as any).mockRejectOnce(new Error("unknown column name"));
|
||||
am = am1.dropObsColumn("test");
|
||||
await expect(am.fetch("obs", "test")).rejects.toThrow(
|
||||
"unknown column name"
|
||||
@@ -308,7 +313,7 @@ describe("AnnoMatrix", () => {
|
||||
const am3 = isubset(annoMatrix, [10, 1, 0, 30, 2]);
|
||||
await addSetDrop(am3);
|
||||
|
||||
fetch.mockResponse(serverMocks.responder);
|
||||
(fetch as any).mockResponse(serverMocks.responder);
|
||||
|
||||
await am1.fetch("obs", am1.getMatrixColumns("obs"));
|
||||
await am2.fetch("obs", am2.getMatrixColumns("obs"));
|
||||
+60
-36
@@ -17,11 +17,12 @@ import { rangeFill } from "../../../src/util/range";
|
||||
enableFetchMocks();
|
||||
|
||||
describe("AnnoMatrixCrossfilter", () => {
|
||||
let annoMatrix;
|
||||
let crossfilter;
|
||||
let annoMatrix: any;
|
||||
let crossfilter: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
fetch.resetMocks(); // reset all fetch mocking state
|
||||
(fetch as any).resetMocks(); // reset all fetch mocking state
|
||||
// reset all fetch mocking state
|
||||
annoMatrix = new AnnoMatrixLoader(
|
||||
serverMocks.baseDataURL,
|
||||
serverMocks.schema.schema
|
||||
@@ -67,7 +68,9 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
crossfilter.obsCrossfilter.hasDimension("obs/louvain")
|
||||
).toBeFalsy();
|
||||
|
||||
fetch.once(serverMocks.dataframeResponse(["louvain"], [obsLouvain]));
|
||||
(fetch as any).once(
|
||||
serverMocks.dataframeResponse(["louvain"], [obsLouvain])
|
||||
);
|
||||
let newCrossfilter = await crossfilter.select("obs", "louvain", {
|
||||
mode: "none",
|
||||
});
|
||||
@@ -76,7 +79,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
expect(
|
||||
newCrossfilter.obsCrossfilter.hasDimension("obs/louvain")
|
||||
).toBeTruthy();
|
||||
expect(fetch.mock.calls).toHaveLength(1);
|
||||
expect((fetch as any).mock.calls).toHaveLength(1);
|
||||
|
||||
newCrossfilter = await crossfilter.select("obs", "louvain", {
|
||||
mode: "all",
|
||||
@@ -87,7 +90,9 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
test("simple column select", async () => {
|
||||
let xfltr;
|
||||
|
||||
fetch.once(serverMocks.dataframeResponse(["louvain"], [obsLouvain]));
|
||||
(fetch as any).once(
|
||||
serverMocks.dataframeResponse(["louvain"], [obsLouvain])
|
||||
);
|
||||
xfltr = await crossfilter.select("obs", "louvain", {
|
||||
mode: "exact",
|
||||
values: ["NK cells", "B cells"],
|
||||
@@ -105,6 +110,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
expect(xfltr.allSelectedLabels()).toEqual(
|
||||
Int32Array.from(
|
||||
obsLouvain.reduce((acc, val, idx) => {
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'number' is not assignable to par... Remove this comment to see the full error message
|
||||
if (val === "NK cells" || val === "B cells") acc.push(idx);
|
||||
return acc;
|
||||
}, [])
|
||||
@@ -124,10 +130,11 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
const values = df.col("louvain").asArray();
|
||||
const selected = xfltr.allSelectedMask();
|
||||
values.every(
|
||||
(val, idx) => !["NK cells", "B cells"].includes(val) !== !selected[idx]
|
||||
(val: any, idx: any) =>
|
||||
!["NK cells", "B cells"].includes(val) !== !selected[idx]
|
||||
);
|
||||
|
||||
fetch.once(
|
||||
(fetch as any).once(
|
||||
serverMocks.dataframeResponse(["n_genes"], [new Int32Array(obsNGenes)])
|
||||
);
|
||||
xfltr = await xfltr.select("obs", "n_genes", {
|
||||
@@ -146,6 +153,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
val < 500 &&
|
||||
(louvain === "NK cells" || louvain === "B cells")
|
||||
)
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'number' is not assignable to par... Remove this comment to see the full error message
|
||||
acc.push(idx);
|
||||
return acc;
|
||||
}, [])
|
||||
@@ -160,7 +168,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
const varIndex = annoMatrix.schema.annotations.var.index;
|
||||
|
||||
const { nObs } = annoMatrix.schema.dataframe;
|
||||
fetch.once(
|
||||
(fetch as any).once(
|
||||
serverMocks.dataframeResponse(
|
||||
["TEST"],
|
||||
[rangeFill(new Float32Array(nObs), 0, 0.1)]
|
||||
@@ -196,14 +204,16 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
});
|
||||
const values = df.icol(0).asArray();
|
||||
const selected = xfltr.allSelectedMask();
|
||||
values.every((val, idx) => !(val >= 0 && val <= 50) !== !selected[idx]);
|
||||
expect(selected.reduce((acc, val) => (val ? acc + 1 : acc), 0)).toEqual(
|
||||
xfltr.countSelected()
|
||||
values.every(
|
||||
(val: any, idx: any) => !(val >= 0 && val <= 50) !== !selected[idx]
|
||||
);
|
||||
expect(
|
||||
selected.reduce((acc: any, val: any) => (val ? acc + 1 : acc), 0)
|
||||
).toEqual(xfltr.countSelected());
|
||||
});
|
||||
|
||||
test("spatial column select", async () => {
|
||||
fetch.once(
|
||||
(fetch as any).once(
|
||||
serverMocks.dataframeResponse(
|
||||
["umap_0", "umap_1"],
|
||||
[Float32Array.from(embUmap[0]), Float32Array.from(embUmap[1])]
|
||||
@@ -222,6 +232,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
test("select on subset", async () => {
|
||||
const mask = new Uint8Array(annoMatrix.nObs).fill(0);
|
||||
for (let i = 0; i < mask.length; i += 2) {
|
||||
// @ts-expect-error ts-migrate(2322) FIXME: Type 'boolean' is not assignable to type 'number'.
|
||||
mask[i] = true;
|
||||
}
|
||||
const annoMatrixSubset = isubsetMask(annoMatrix, mask);
|
||||
@@ -230,7 +241,9 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
let xfltr = new AnnoMatrixObsCrossfilter(annoMatrixSubset);
|
||||
expect(xfltr.countSelected()).toEqual(annoMatrixSubset.nObs);
|
||||
|
||||
fetch.once(serverMocks.dataframeResponse(["louvain"], [obsLouvain]));
|
||||
(fetch as any).once(
|
||||
serverMocks.dataframeResponse(["louvain"], [obsLouvain])
|
||||
);
|
||||
xfltr = await xfltr.select("obs", "louvain", {
|
||||
mode: "exact",
|
||||
values: ["NK cells", "B cells"],
|
||||
@@ -243,7 +256,8 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
const values = df.col("louvain").asArray();
|
||||
const selected = xfltr.allSelectedMask();
|
||||
values.every(
|
||||
(val, idx) => !["NK cells", "B cells"].includes(val) !== !selected[idx]
|
||||
(val: any, idx: any) =>
|
||||
!["NK cells", "B cells"].includes(val) !== !selected[idx]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -256,7 +270,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
"unable to obsSelect upon the var dimension"
|
||||
);
|
||||
|
||||
fetch.mockRejectOnce(new Error("unknown column name"));
|
||||
(fetch as any).mockRejectOnce(new Error("unknown column name"));
|
||||
await expect(crossfilter.select("obs", "foo")).rejects.toThrow(
|
||||
"unknown column name"
|
||||
);
|
||||
@@ -267,24 +281,27 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
/*
|
||||
test the matrix mutators via crossfilter proxy
|
||||
*/
|
||||
async function helperAddTestCol(cf, colName, colSchema = null) {
|
||||
async function helperAddTestCol(cf: any, colName: any, colSchema = null) {
|
||||
expect(
|
||||
cf.annoMatrix.getMatrixColumns("obs").includes(colName)
|
||||
).toBeFalsy();
|
||||
|
||||
if (colSchema === null) {
|
||||
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ name: any; type: string; categories: strin... Remove this comment to see the full error message
|
||||
colSchema = {
|
||||
name: colName,
|
||||
type: "categorical",
|
||||
categories: ["toasty"],
|
||||
};
|
||||
}
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
colSchema.name = colName;
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
const initValue = colSchema.categories[0];
|
||||
const xfltr = cf.addObsColumn(colSchema, Array, initValue);
|
||||
expect(
|
||||
xfltr.annoMatrix.schema.annotations.obs.columns.filter(
|
||||
(v) => v.name === colName
|
||||
(v: any) => v.name === colName
|
||||
)
|
||||
).toHaveLength(1);
|
||||
const df = await xfltr.annoMatrix.fetch("obs", colName);
|
||||
@@ -314,7 +331,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
});
|
||||
expect(
|
||||
xfltr.annoMatrix.schema.annotations.obs.columns.filter(
|
||||
(v) => v.name === "foo"
|
||||
(v: any) => v.name === "foo"
|
||||
)
|
||||
).toHaveLength(1);
|
||||
|
||||
@@ -324,7 +341,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
df
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.every((v) => v === "A")
|
||||
.every((v: any) => v === "A")
|
||||
).toBeTruthy();
|
||||
|
||||
// check that we catch dups
|
||||
@@ -361,11 +378,11 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
xfltr = xfltr.dropObsColumn("foo");
|
||||
expect(
|
||||
xfltr.annoMatrix.schema.annotations.obs.columns.filter(
|
||||
(v) => v.name === "foo"
|
||||
(v: any) => v.name === "foo"
|
||||
)
|
||||
).toHaveLength(0);
|
||||
expect(xfltr.annoMatrix.schema.annotations.obsByName.foo).toBeUndefined();
|
||||
fetch.mockRejectOnce(new Error("unknown column name"));
|
||||
(fetch as any).mockRejectOnce(new Error("unknown column name"));
|
||||
await expect(xfltr.annoMatrix.fetch("obs", "foo")).rejects.toThrow(
|
||||
"unknown column name"
|
||||
);
|
||||
@@ -378,7 +395,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
});
|
||||
xfltr = xfltr.dropObsColumn("bar");
|
||||
|
||||
fetch.mockRejectOnce(new Error("unknown column name"));
|
||||
(fetch as any).mockRejectOnce(new Error("unknown column name"));
|
||||
await expect(xfltr.select("obs", "bar", { mode: "all" })).rejects.toThrow(
|
||||
"unknown column name"
|
||||
);
|
||||
@@ -404,7 +421,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
type: "categorical",
|
||||
});
|
||||
|
||||
fetch.mockRejectOnce(new Error("unknown column name"));
|
||||
(fetch as any).mockRejectOnce(new Error("unknown column name"));
|
||||
await expect(xfltr.annoMatrix.fetch("obs", "foo")).rejects.toThrow(
|
||||
"unknown column name"
|
||||
);
|
||||
@@ -419,7 +436,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
});
|
||||
xfltr = xfltr.renameObsColumn("bar", "xyz");
|
||||
|
||||
fetch.mockRejectOnce(new Error("unknown column name"));
|
||||
(fetch as any).mockRejectOnce(new Error("unknown column name"));
|
||||
await expect(xfltr.select("obs", "bar", { mode: "all" })).rejects.toThrow(
|
||||
"unknown column name"
|
||||
);
|
||||
@@ -429,7 +446,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
});
|
||||
|
||||
test("addObsAnnoCategory", async () => {
|
||||
let xfltr;
|
||||
let xfltr: any;
|
||||
|
||||
// catch unknown or readonly columns
|
||||
expect(() => crossfilter.addObsAnnoCategory("louvain", "mumble")).toThrow(
|
||||
@@ -440,6 +457,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
).toThrow("Unknown or readonly obs column");
|
||||
|
||||
// add a column and then add category to it
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '{ name: string; type: string; ca... Remove this comment to see the full error message
|
||||
xfltr = await helperAddTestCol(crossfilter, "foo", {
|
||||
name: "foo",
|
||||
type: "categorical",
|
||||
@@ -458,6 +476,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
);
|
||||
|
||||
// now same, but ensure we have built an index before doing the operation
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '{ name: string; type: string; ca... Remove this comment to see the full error message
|
||||
xfltr = await helperAddTestCol(crossfilter, "bar", {
|
||||
name: "bar",
|
||||
type: "categorical",
|
||||
@@ -486,6 +505,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
crossfilter.removeObsAnnoCategory("undefined-name", "mumble")
|
||||
).rejects.toThrow("Unknown or readonly obs column");
|
||||
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '{ name: string; type: string; ca... Remove this comment to see the full error message
|
||||
xfltr = await helperAddTestCol(crossfilter, "foo", {
|
||||
name: "foo",
|
||||
type: "categorical",
|
||||
@@ -496,7 +516,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
(await xfltr.annoMatrix.fetch("obs", "foo"))
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.every((v) => v === "unassigned")
|
||||
.every((v: any) => v === "unassigned")
|
||||
).toBeTruthy();
|
||||
expect(xfltr.annoMatrix.getColumnSchema("obs", "foo")).toMatchObject({
|
||||
name: "foo",
|
||||
@@ -515,7 +535,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
(await xfltr1.annoMatrix.fetch("obs", "foo"))
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.every((v) => v === "unassigned")
|
||||
.every((v: any) => v === "unassigned")
|
||||
).toBeTruthy();
|
||||
expect(xfltr1.annoMatrix.getColumnSchema("obs", "foo")).toMatchObject({
|
||||
name: "foo",
|
||||
@@ -538,7 +558,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
(await xfltr2.annoMatrix.fetch("obs", "foo"))
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.every((v) => v === "red")
|
||||
.every((v: any) => v === "red")
|
||||
).toBeTruthy();
|
||||
expect(xfltr2.annoMatrix.getColumnSchema("obs", "foo")).toMatchObject({
|
||||
name: "foo",
|
||||
@@ -556,6 +576,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
crossfilter.setObsColumnValues("undefined-name", [0], "mumble")
|
||||
).rejects.toThrow("Unknown or readonly obs column");
|
||||
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '{ name: string; type: string; ca... Remove this comment to see the full error message
|
||||
let xfltr = await helperAddTestCol(crossfilter, "foo", {
|
||||
name: "foo",
|
||||
type: "categorical",
|
||||
@@ -573,7 +594,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
(await xfltr.annoMatrix.fetch("obs", "foo"))
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.every((v) => v === "unassigned")
|
||||
.every((v: any) => v === "unassigned")
|
||||
).toBeTruthy();
|
||||
const xfltr1 = await xfltr.setObsColumnValues("foo", [0, 10], "purple");
|
||||
expect(
|
||||
@@ -581,7 +602,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.every(
|
||||
(v, i) =>
|
||||
(v: any, i: any) =>
|
||||
v === "unassigned" || (v === "purple" && (i === 0 || i === 10))
|
||||
)
|
||||
).toBeTruthy();
|
||||
@@ -615,6 +636,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
crossfilter.resetObsColumnValues("undefined-name", "red", "blue")
|
||||
).rejects.toThrow("Unknown or readonly obs column");
|
||||
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '{ name: string; type: string; ca... Remove this comment to see the full error message
|
||||
let xfltr = await helperAddTestCol(crossfilter, "foo", {
|
||||
name: "foo",
|
||||
type: "categorical",
|
||||
@@ -639,7 +661,7 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
(await xfltr1.annoMatrix.fetch("obs", "foo"))
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.filter((v) => v === "purple")
|
||||
.filter((v: any) => v === "purple")
|
||||
).toHaveLength(2);
|
||||
|
||||
xfltr1 = await xfltr1.resetObsColumnValues("foo", "purple", "magenta");
|
||||
@@ -647,13 +669,13 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
(await xfltr1.annoMatrix.fetch("obs", "foo"))
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.filter((v) => v === "magenta")
|
||||
.filter((v: any) => v === "magenta")
|
||||
).toHaveLength(2);
|
||||
expect(
|
||||
(await xfltr1.annoMatrix.fetch("obs", "foo"))
|
||||
.col("foo")
|
||||
.asArray()
|
||||
.filter((v) => v === "purple")
|
||||
.filter((v: any) => v === "purple")
|
||||
).toHaveLength(0);
|
||||
expect(xfltr1.annoMatrix.getColumnSchema("obs", "foo")).toMatchObject({
|
||||
name: "foo",
|
||||
@@ -673,12 +695,14 @@ describe("AnnoMatrixCrossfilter", () => {
|
||||
describe("edge cases", () => {
|
||||
test("transition from empty annoMatrix", async () => {
|
||||
// select before fetch needs to work
|
||||
fetch.once(serverMocks.dataframeResponse(["louvain"], [obsLouvain]));
|
||||
(fetch as any).once(
|
||||
serverMocks.dataframeResponse(["louvain"], [obsLouvain])
|
||||
);
|
||||
const xfltr = await crossfilter.select("obs", "louvain", {
|
||||
mode: "exact",
|
||||
values: "B cells",
|
||||
});
|
||||
expect(fetch.mock.calls).toHaveLength(1);
|
||||
expect((fetch as any).mock.calls).toHaveLength(1);
|
||||
expect(xfltr.obsCrossfilter.hasDimension("obs/louvain")).toBeTruthy();
|
||||
expect(xfltr.obsCrossfilter.all()).toBe(xfltr.annoMatrix._cache.obs);
|
||||
expect(xfltr.countSelected()).toEqual(
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
export const baseDataURL = "https://a.fake.url/api/v0.2";
|
||||
|
||||
window.CELLXGENE = {
|
||||
(window as any).CELLXGENE = {
|
||||
API: {
|
||||
prefix: baseDataURL,
|
||||
version: "v0.2/",
|
||||
+41
-22
@@ -14,7 +14,7 @@ const indexedSchema = {
|
||||
),
|
||||
};
|
||||
|
||||
function makeMockColumn(s, length) {
|
||||
function makeMockColumn(s: any, length: any) {
|
||||
const { type } = s;
|
||||
switch (type) {
|
||||
case "int32":
|
||||
@@ -37,20 +37,22 @@ function makeMockColumn(s, length) {
|
||||
}
|
||||
}
|
||||
|
||||
function getEncodedDataframe(colNames, length, colSchemas) {
|
||||
function getEncodedDataframe(colNames: any, length: any, colSchemas: any) {
|
||||
const colIndex = new KeyIndex(colNames);
|
||||
const columns = colSchemas.map((s) => makeMockColumn(s, length));
|
||||
const columns = colSchemas.map((s: any) => makeMockColumn(s, length));
|
||||
// @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 df = new Dataframe([length, colNames.length], columns, null, colIndex);
|
||||
const body = encodeMatrixFBS(df);
|
||||
return body;
|
||||
}
|
||||
|
||||
export function dataframeResponse(colNames, columns) {
|
||||
export function dataframeResponse(colNames: any, columns: any) {
|
||||
const colIndex = new KeyIndex(colNames);
|
||||
const df = new Dataframe(
|
||||
[columns[0].length, colNames.length],
|
||||
columns,
|
||||
null,
|
||||
// @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
|
||||
colIndex
|
||||
);
|
||||
const body = encodeMatrixFBS(df);
|
||||
@@ -60,15 +62,19 @@ export function dataframeResponse(colNames, columns) {
|
||||
return () => Promise.resolve({ body, init: { status: 200, headers } });
|
||||
}
|
||||
|
||||
function annotationObsResponse(request) {
|
||||
function annotationObsResponse(request: any) {
|
||||
const url = new URL(request.url);
|
||||
const params = Array.from(url.searchParams.entries());
|
||||
const params = Array.from((url.searchParams as any).entries());
|
||||
const names = params
|
||||
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
||||
.filter(([k]) => k === "annotation-name")
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '([, v]: [any, any]) => any' is n... Remove this comment to see the full error message
|
||||
.map(([, v]) => v);
|
||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'unknown' cannot be used as an index type.
|
||||
if (!names.every((n) => indexedSchema.obsByName[n])) {
|
||||
return Promise.reject(new Error("bad obs annotation name in URL"));
|
||||
}
|
||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'unknown' cannot be used as an index type.
|
||||
const colSchemas = names.map((n) => indexedSchema.obsByName[n]);
|
||||
const body = getEncodedDataframe(
|
||||
names,
|
||||
@@ -85,15 +91,19 @@ function annotationObsResponse(request) {
|
||||
});
|
||||
}
|
||||
|
||||
function annotationVarResponse(request) {
|
||||
function annotationVarResponse(request: any) {
|
||||
const url = new URL(request.url);
|
||||
const params = Array.from(url.searchParams.entries());
|
||||
const params = Array.from((url.searchParams as any).entries());
|
||||
const names = params
|
||||
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
||||
.filter(([k]) => k === "annotation-name")
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '([, v]: [any, any]) => any' is n... Remove this comment to see the full error message
|
||||
.map(([, v]) => v);
|
||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'unknown' cannot be used as an index type.
|
||||
if (!names.every((n) => indexedSchema.varByName[n])) {
|
||||
return Promise.reject(new Error("bad var annotation name in URL"));
|
||||
}
|
||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'unknown' cannot be used as an index type.
|
||||
const colSchemas = names.map((n) => indexedSchema.varByName[n]);
|
||||
const body = getEncodedDataframe(
|
||||
names,
|
||||
@@ -110,15 +120,19 @@ function annotationVarResponse(request) {
|
||||
});
|
||||
}
|
||||
|
||||
function layoutObsResponse(request) {
|
||||
function layoutObsResponse(request: any) {
|
||||
const url = new URL(request.url);
|
||||
const params = Array.from(url.searchParams.entries());
|
||||
const params = Array.from((url.searchParams as any).entries());
|
||||
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
||||
const names = params.filter(([k]) => k === "layout-name").map(([, v]) => v);
|
||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'unknown' cannot be used as an index type.
|
||||
if (!names.every((n) => indexedSchema.embByName[n])) {
|
||||
return Promise.reject(new Error("bad layout name in URL"));
|
||||
}
|
||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'unknown' cannot be used as an index type.
|
||||
const dims = names.map((n) => indexedSchema.embByName[n].dims).flat();
|
||||
const colSchemas = names
|
||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'unknown' cannot be used as an index type.
|
||||
.map((n) => [indexedSchema.embByName[n], indexedSchema.embByName[n]])
|
||||
.flat();
|
||||
const body = getEncodedDataframe(
|
||||
@@ -136,11 +150,11 @@ function layoutObsResponse(request) {
|
||||
});
|
||||
}
|
||||
|
||||
function dataVarResponse(request) {
|
||||
function dataVarResponse(request: any) {
|
||||
const url = new URL(request.url);
|
||||
const params = Array.from(url.searchParams.entries());
|
||||
const params = Array.from((url.searchParams as any).entries());
|
||||
|
||||
const colNames = params.map((v) => `${v[0]}/${v[1]}`);
|
||||
const colNames = params.map((v) => `${(v as any)[0]}/${(v as any)[1]}`);
|
||||
const colSchemas = colNames.map(() => schema.schema.dataframe);
|
||||
const body = getEncodedDataframe(
|
||||
colNames,
|
||||
@@ -157,7 +171,7 @@ function dataVarResponse(request) {
|
||||
});
|
||||
}
|
||||
|
||||
export function responder(request) {
|
||||
export function responder(request: any) {
|
||||
const url = new URL(request.url);
|
||||
const { pathname } = url;
|
||||
if (pathname.endsWith("/annotations/obs")) {
|
||||
@@ -175,25 +189,30 @@ export function responder(request) {
|
||||
return Promise.reject(new Error("bad URL"));
|
||||
}
|
||||
|
||||
export function withExpected(expectedURL, expectedParams) {
|
||||
export function withExpected(expectedURL: any, expectedParams: any) {
|
||||
/*
|
||||
Do some additional error checking
|
||||
*/
|
||||
return (request) => {
|
||||
return (request: any) => {
|
||||
// if URL is bogus, reject the promise
|
||||
const url = new URL(request.url);
|
||||
if (!url.pathname.endsWith(expectedURL)) {
|
||||
return Promise.reject(new Error("Unexpected URL!"));
|
||||
}
|
||||
const params = Array.from(url.searchParams.entries()).sort(
|
||||
(a, b) => a[0] < b[0]
|
||||
const params = Array.from((url.searchParams as any).entries()).sort(
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '(a: unknown, b: unknown) => bool... Remove this comment to see the full error message
|
||||
(a, b) => (a as any)[0] < (b as any)[0]
|
||||
);
|
||||
expectedParams = expectedParams.slice().sort((a, b) => a[0] < b[0]);
|
||||
expectedParams = expectedParams
|
||||
.slice()
|
||||
.sort((a: any, b: any) => a[0] < b[0]);
|
||||
|
||||
if (
|
||||
params.length !== expectedParams.length ||
|
||||
!params.every(
|
||||
(p, i) => p[0] === expectedParams[i][0] && p[1] === expectedParams[i][1]
|
||||
(p, i) =>
|
||||
(p as any)[0] === expectedParams[i][0] &&
|
||||
(p as any)[1] === expectedParams[i][1]
|
||||
)
|
||||
) {
|
||||
return Promise.reject(new Error("unexpected name requested in URL"));
|
||||
@@ -203,9 +222,9 @@ export function withExpected(expectedURL, expectedParams) {
|
||||
};
|
||||
}
|
||||
|
||||
export function annotationsObs(names) {
|
||||
export function annotationsObs(names: any) {
|
||||
return withExpected(
|
||||
"/annotations/obs",
|
||||
names.map((name) => ["annotation-name", name])
|
||||
names.map((name: any) => ["annotation-name", name])
|
||||
);
|
||||
}
|
||||
+8
-3
@@ -218,10 +218,15 @@ describe("whereCache", () => {
|
||||
},
|
||||
})
|
||||
);
|
||||
expect(wc.where.field.queryField.has("queryColumn")).toEqual(true);
|
||||
expect(wc.where.field.queryField.get("queryColumn")).toBeInstanceOf(Map);
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
expect((wc.where as any).field.queryField.has("queryColumn")).toEqual(true);
|
||||
expect(
|
||||
wc.where.field.queryField.get("queryColumn").has("queryValue")
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
(wc.where as any).field.queryField.get("queryColumn")
|
||||
).toBeInstanceOf(Map);
|
||||
expect(
|
||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
||||
(wc.where as any).field.queryField.get("queryColumn").has("queryValue")
|
||||
).toEqual(true);
|
||||
expect(_whereCacheGet(wc, schema, "field", query)).toEqual([0, 1, 2]);
|
||||
});
|
||||
@@ -8,9 +8,9 @@ import { indexEntireSchema } from "../../src/util/stateManager/schemaHelpers";
|
||||
import { _normalizeCategoricalSchema } from "../../src/annoMatrix/schema";
|
||||
|
||||
describe("centroid", () => {
|
||||
let schema;
|
||||
let obsAnnotations;
|
||||
let obsLayout;
|
||||
let schema: any;
|
||||
let obsAnnotations: any;
|
||||
let obsLayout: any;
|
||||
|
||||
beforeAll(() => {
|
||||
schema = indexEntireSchema(cloneDeep(REST.schema.schema));
|
||||
@@ -44,7 +44,7 @@ describe("centroid", () => {
|
||||
quantile([0.5], obsLayout.col("umap_1").asArray())[0],
|
||||
];
|
||||
|
||||
centroidResult.forEach((coordinate) => {
|
||||
centroidResult.forEach((coordinate: any) => {
|
||||
expect(coordinate).toEqual(expectedResult);
|
||||
});
|
||||
});
|
||||
@@ -68,7 +68,7 @@ describe("centroid", () => {
|
||||
quantile([0.5], obsLayout.col("umap_1").asArray())[0],
|
||||
];
|
||||
|
||||
centroidResult.forEach((coordinate) => {
|
||||
centroidResult.forEach((coordinate: any) => {
|
||||
expect(coordinate).toEqual(expectedResult);
|
||||
});
|
||||
});
|
||||
+40
-2
@@ -29,6 +29,7 @@ describe("dataframe constructor", () => {
|
||||
const df = new Dataframe.Dataframe(
|
||||
[3, 2],
|
||||
[new Int32Array([0, 1, 2]), new Int32Array([3, 4, 5])],
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'DenseInt32Index' is not assignab... Remove this comment to see the full error message
|
||||
new Dataframe.DenseInt32Index([2, 1, 0]),
|
||||
new Dataframe.KeyIndex(["A", "B"])
|
||||
);
|
||||
@@ -55,6 +56,7 @@ describe("simple data access", () => {
|
||||
new Float64Array([0.0, Number.NaN, Number.POSITIVE_INFINITY, 3.14159]),
|
||||
["red", "blue", "green", "nan"],
|
||||
],
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'DenseInt32Index' is not assignab... Remove this comment to see the full error message
|
||||
new Dataframe.DenseInt32Index([3, 2, 1, 0]),
|
||||
new Dataframe.KeyIndex(["numbers", "colors"])
|
||||
);
|
||||
@@ -139,10 +141,12 @@ describe("dataframe subsetting", () => {
|
||||
["red", "green", "blue"],
|
||||
],
|
||||
null, // identity index
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["int32", "string", "float32", "colors"])
|
||||
);
|
||||
|
||||
test("all rows, one column", () => {
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
const dfA = sourceDf.subset(null, ["colors"]);
|
||||
expect(dfA).toBeDefined();
|
||||
expect(dfA.dims).toEqual([3, 1]);
|
||||
@@ -158,6 +162,7 @@ describe("dataframe subsetting", () => {
|
||||
});
|
||||
|
||||
test("all rows, two columns", () => {
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
const dfB = sourceDf.subset(null, ["float32", "colors"]);
|
||||
expect(dfB).toBeDefined();
|
||||
expect(dfB.dims).toEqual([3, 2]);
|
||||
@@ -227,6 +232,7 @@ describe("dataframe subsetting", () => {
|
||||
});
|
||||
|
||||
test("two rows, two colums", () => {
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
const dfF = sourceDf.subset([0, 2], ["int32", "float32"]);
|
||||
expect(dfF).toBeDefined();
|
||||
expect(dfF.dims).toEqual([2, 2]);
|
||||
@@ -236,6 +242,7 @@ describe("dataframe subsetting", () => {
|
||||
expect(dfF.colIndex.labels()).toEqual(["int32", "float32"]);
|
||||
|
||||
// reverse the row and column order
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
const dfFr = sourceDf.subset([2, 0], ["float32", "int32"]);
|
||||
expect(dfFr).toBeDefined();
|
||||
expect(dfFr.dims).toEqual([2, 2]);
|
||||
@@ -248,6 +255,7 @@ describe("dataframe subsetting", () => {
|
||||
test("withRowIndex", () => {
|
||||
const df = sourceDf.subset(
|
||||
null,
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
["int32", "float32"],
|
||||
new Dataframe.DenseInt32Index([3, 2, 1])
|
||||
);
|
||||
@@ -258,12 +266,15 @@ describe("dataframe subsetting", () => {
|
||||
|
||||
test("withRowIndex error checks", () => {
|
||||
expect(() =>
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
sourceDf.subset(null, ["red"], new Dataframe.IdentityInt32Index(1))
|
||||
).toThrow(RangeError);
|
||||
expect(() =>
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
sourceDf.subset(null, ["red"], new Dataframe.DenseInt32Index([0, 1]))
|
||||
).toThrow(RangeError);
|
||||
expect(() =>
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
sourceDf.subset(null, ["red"], new Dataframe.KeyIndex([0, 1, 2, 3]))
|
||||
).toThrow(RangeError);
|
||||
});
|
||||
@@ -278,12 +289,14 @@ describe("dataframe subsetting", () => {
|
||||
new Float32Array([4.4, 5.5, 6.6]),
|
||||
["red", "green", "blue"],
|
||||
],
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'DenseInt32Index' is not assignab... Remove this comment to see the full error message
|
||||
new Dataframe.DenseInt32Index([2, 4, 6]),
|
||||
new Dataframe.KeyIndex(["int32", "string", "float32", "colors"])
|
||||
);
|
||||
|
||||
const dfA = sourceDf.isubsetMask(
|
||||
new Uint8Array([0, 1, 1]),
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Uint8Array' is not assignable to... Remove this comment to see the full error message
|
||||
new Uint8Array([1, 0, 0, 1])
|
||||
);
|
||||
expect(dfA.dims).toEqual([2, 2]);
|
||||
@@ -303,6 +316,7 @@ describe("dataframe subsetting", () => {
|
||||
["red", "green", "blue"],
|
||||
],
|
||||
null, // identity index
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["int32", "string", "float32", "colors"])
|
||||
);
|
||||
|
||||
@@ -316,6 +330,7 @@ describe("dataframe subsetting", () => {
|
||||
});
|
||||
|
||||
test("all rows, two cols", () => {
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'number[]' is not assignable to p... Remove this comment to see the full error message
|
||||
const dfA = sourceDf.isubset(null, [1, 2]);
|
||||
expect(dfA.dims).toEqual([3, 2]);
|
||||
expect(dfA.icol(0).asArray()).toEqual(["A", "B", "C"]);
|
||||
@@ -361,6 +376,7 @@ describe("dataframe factories", () => {
|
||||
const dfA = new Dataframe.Dataframe(
|
||||
[3, 2],
|
||||
[new Int32Array([0, 1, 2]), new Int32Array([3, 4, 5])],
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'DenseInt32Index' is not assignab... Remove this comment to see the full error message
|
||||
new Dataframe.DenseInt32Index([2, 1, 0]),
|
||||
new Dataframe.KeyIndex(["A", "B"])
|
||||
);
|
||||
@@ -385,6 +401,7 @@ describe("dataframe factories", () => {
|
||||
[true, false],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colors", "bools"])
|
||||
);
|
||||
const dfA = df.withCol("numbers", [1, 0]);
|
||||
@@ -408,6 +425,7 @@ describe("dataframe factories", () => {
|
||||
[true, false],
|
||||
],
|
||||
null,
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'DenseInt32Index' is not assignab... Remove this comment to see the full error message
|
||||
new Dataframe.DenseInt32Index([74, 75])
|
||||
);
|
||||
const dfA = df.withCol(72, [1, 0]);
|
||||
@@ -433,6 +451,7 @@ describe("dataframe factories", () => {
|
||||
[true, false],
|
||||
],
|
||||
null,
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'DenseInt32Index' is not assignab... Remove this comment to see the full error message
|
||||
new Dataframe.DenseInt32Index([74, 75])
|
||||
);
|
||||
const dfA = df.withCol(999, [1, 0]);
|
||||
@@ -541,6 +560,7 @@ describe("dataframe factories", () => {
|
||||
[1, 0],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colors", "bools", "numbers"])
|
||||
);
|
||||
|
||||
@@ -549,11 +569,14 @@ describe("dataframe factories", () => {
|
||||
[3, 1],
|
||||
[["red", "blue", "green"]],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colorsA"])
|
||||
);
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
expect(() => dfA.withColsFrom(dfB)).toThrow(RangeError);
|
||||
|
||||
/* duplicate labels should throw an error */
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
expect(() => dfA.withColsFrom(dfA)).toThrow(Error);
|
||||
});
|
||||
|
||||
@@ -564,15 +587,18 @@ describe("dataframe factories", () => {
|
||||
[2, 1],
|
||||
[["red", "blue"]],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colors"])
|
||||
);
|
||||
const dfB = new Dataframe.Dataframe(
|
||||
[2, 1],
|
||||
[[true, false]],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["bools"])
|
||||
);
|
||||
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const dfLikeA = dfEmpty.withColsFrom(dfA);
|
||||
expect(dfLikeA).toBeDefined();
|
||||
expect(dfLikeA.dims).toEqual(dfA.dims);
|
||||
@@ -581,6 +607,7 @@ describe("dataframe factories", () => {
|
||||
expect(dfLikeA.rowIndex.labels()).toEqual(dfA.rowIndex.labels());
|
||||
expect(dfLikeA.icol(0).asArray()).toEqual(dfA.icol(0).asArray());
|
||||
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const dfAlsoLikeA = dfA.withColsFrom(dfEmpty);
|
||||
expect(dfAlsoLikeA).toBeDefined();
|
||||
expect(dfAlsoLikeA.dims).toEqual(dfA.dims);
|
||||
@@ -589,6 +616,7 @@ describe("dataframe factories", () => {
|
||||
expect(dfAlsoLikeA.rowIndex.labels()).toEqual(dfA.rowIndex.labels());
|
||||
expect(dfAlsoLikeA.icol(0).asArray()).toEqual(dfA.icol(0).asArray());
|
||||
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
const dfC = dfA.withColsFrom(dfB);
|
||||
expect(dfC).toBeDefined();
|
||||
expect(dfC.dims).toEqual([2, 2]);
|
||||
@@ -605,6 +633,7 @@ describe("dataframe factories", () => {
|
||||
[2, 1],
|
||||
[["red", "blue"]],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colors"])
|
||||
);
|
||||
const dfB = new Dataframe.Dataframe(
|
||||
@@ -615,6 +644,7 @@ describe("dataframe factories", () => {
|
||||
[1, 0],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colors", "bools", "numbers"])
|
||||
);
|
||||
|
||||
@@ -647,6 +677,7 @@ describe("dataframe factories", () => {
|
||||
[2, 1],
|
||||
[["red", "blue"]],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colors"])
|
||||
);
|
||||
const dfB = new Dataframe.Dataframe(
|
||||
@@ -657,6 +688,7 @@ describe("dataframe factories", () => {
|
||||
[1, 0],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colors", "bools", "numbers"])
|
||||
);
|
||||
|
||||
@@ -680,6 +712,7 @@ describe("dataframe factories", () => {
|
||||
[1, 0],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["colors", "bools", "numbers"])
|
||||
);
|
||||
const dfA = df.dropCol("colors");
|
||||
@@ -751,6 +784,7 @@ describe("dataframe factories", () => {
|
||||
[1, 0],
|
||||
],
|
||||
null,
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'DenseInt32Index' is not assignab... Remove this comment to see the full error message
|
||||
new Dataframe.DenseInt32Index([102, 101, 100])
|
||||
);
|
||||
const dfA = df.dropCol(101);
|
||||
@@ -777,7 +811,7 @@ describe("dataframe factories", () => {
|
||||
new Float64Array(3).fill(1.1),
|
||||
]
|
||||
);
|
||||
const dfB = dfA.mapColumns((col, idx) => {
|
||||
const dfB = dfA.mapColumns((col: any, idx: any) => {
|
||||
expect(dfA.icol(idx).asArray()).toBe(col);
|
||||
return col;
|
||||
});
|
||||
@@ -822,6 +856,7 @@ describe("dataframe factories", () => {
|
||||
[1, 0],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["A", "B"])
|
||||
);
|
||||
const dfB = dfA.renameCol("B", "C");
|
||||
@@ -834,7 +869,7 @@ describe("dataframe factories", () => {
|
||||
});
|
||||
|
||||
describe("dataframe col", () => {
|
||||
let df = null;
|
||||
let df: any = null;
|
||||
beforeEach(() => {
|
||||
df = new Dataframe.Dataframe(
|
||||
[2, 2],
|
||||
@@ -843,6 +878,7 @@ describe("dataframe col", () => {
|
||||
[1, 0],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["A", "B"])
|
||||
);
|
||||
});
|
||||
@@ -1195,6 +1231,7 @@ describe("label indexing", () => {
|
||||
test("create", () => {
|
||||
expect(Dataframe.isLabelIndex(idx)).toBeTruthy();
|
||||
expect(() => new Dataframe.KeyIndex(["dup", "dup"])).toThrow(Error);
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
||||
expect(new Dataframe.KeyIndex().size()).toEqual(0);
|
||||
});
|
||||
|
||||
@@ -1367,6 +1404,7 @@ describe("corner cases", () => {
|
||||
[1, 0],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["A", "B"])
|
||||
);
|
||||
|
||||
+4
@@ -6,6 +6,7 @@ describe("Dataframe column histogram", () => {
|
||||
[3, 3],
|
||||
[["n1", "n2", "n3"], ["c1", "c2", "c3"], new Int32Array([0, 1, 2])],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["name", "cat", "value"])
|
||||
);
|
||||
|
||||
@@ -26,6 +27,7 @@ describe("Dataframe column histogram", () => {
|
||||
[3, 3],
|
||||
[["n1", "n2", "n3"], ["c1", "c2", "c3"], new Int32Array([0, 1, 2])],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["name", "cat", "value"])
|
||||
);
|
||||
|
||||
@@ -48,6 +50,7 @@ describe("Dataframe column histogram", () => {
|
||||
[3, 3],
|
||||
[["n1", "n2", "n3"], ["c1", "c2", "c3"], new Int32Array([0, 1, 2])],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["name", "cat", "value"])
|
||||
);
|
||||
|
||||
@@ -68,6 +71,7 @@ describe("Dataframe column histogram", () => {
|
||||
[3, 3],
|
||||
[["n1", "n2", "n3"], ["c1", "c2", "c3"], new Int32Array([0, 1, 2])],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["name", "cat", "value"])
|
||||
);
|
||||
|
||||
+6
-1
@@ -1,6 +1,6 @@
|
||||
import * as Dataframe from "../../../src/util/dataframe";
|
||||
|
||||
function float32Conversion(f) {
|
||||
function float32Conversion(f: any) {
|
||||
return new Float32Array([f])[0];
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ describe("Dataframe column summary", () => {
|
||||
[1],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex([
|
||||
"name",
|
||||
"nameString",
|
||||
@@ -106,6 +107,7 @@ describe("Dataframe column summary", () => {
|
||||
[1, false, "0"],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex([
|
||||
"name",
|
||||
"nameString",
|
||||
@@ -174,6 +176,7 @@ describe("Dataframe column summary", () => {
|
||||
expect.objectContaining({
|
||||
categorical: true,
|
||||
categories: expect.arrayContaining([1, false, "0"]),
|
||||
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
||||
categoryCounts: new Map([
|
||||
[1, 1],
|
||||
[false, 1],
|
||||
@@ -201,6 +204,7 @@ describe("Dataframe column summary", () => {
|
||||
[1, false, "0", "0"],
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex([
|
||||
"name",
|
||||
"nameString",
|
||||
@@ -269,6 +273,7 @@ describe("Dataframe column summary", () => {
|
||||
expect.objectContaining({
|
||||
categorical: true,
|
||||
categories: expect.arrayContaining([1, false, "0"]),
|
||||
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
||||
categoryCounts: new Map([
|
||||
[1, 1],
|
||||
[false, 1],
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
import PromiseLimit from "../../src/util/promiseLimit";
|
||||
import { range } from "../../src/util/range";
|
||||
|
||||
const delay = (t) => new Promise((resolve) => setTimeout(resolve, t));
|
||||
const delay = (t: any) => new Promise((resolve) => setTimeout(resolve, t));
|
||||
|
||||
describe("PromiseLimit", () => {
|
||||
test("simple evaluation, concurrency 1", async () => {
|
||||
@@ -51,7 +51,8 @@ describe("PromiseLimit", () => {
|
||||
running -= 1;
|
||||
};
|
||||
|
||||
await Promise.all(range(10).map((i) => plimit.add(() => callback(i))));
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
||||
await Promise.all(range(10).map((i: any) => plimit.add(() => callback(i))));
|
||||
|
||||
expect(maxRunning).toEqual(2);
|
||||
});
|
||||
@@ -6,14 +6,20 @@ describe("range", () => {
|
||||
});
|
||||
|
||||
test("range(stop)", () => {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
||||
expect(range(3)).toMatchObject([0, 1, 2]);
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
||||
expect(range(0)).toMatchObject([]);
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
||||
expect(range(1)).toMatchObject([0]);
|
||||
});
|
||||
|
||||
test("range(start,stop)", () => {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
||||
expect(range(0, 0)).toMatchObject([]);
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
||||
expect(range(0, 2)).toMatchObject([0, 1]);
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
||||
expect(range(4, 8)).toMatchObject([4, 5, 6, 7]);
|
||||
});
|
||||
|
||||
+13
-8
@@ -81,6 +81,7 @@ describe("categorical color helpers", () => {
|
||||
),
|
||||
],
|
||||
null,
|
||||
// @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
|
||||
new Dataframe.KeyIndex(["continuousColumn", "categoricalColumn"])
|
||||
);
|
||||
|
||||
@@ -95,6 +96,7 @@ describe("categorical color helpers", () => {
|
||||
const data = obsDataframe.col("categoricalColumn").asArray();
|
||||
const cats = schema.annotations.obsByName.categoricalColumn.categories;
|
||||
for (let i = 0; i < schema.dataframe.nObs; i += 1) {
|
||||
// @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
|
||||
expect(makeScale(ct.rgb[i])).toEqual(ct.scale(cats.indexOf(data[i])));
|
||||
}
|
||||
});
|
||||
@@ -112,6 +114,7 @@ describe("categorical color helpers", () => {
|
||||
const data = obsDataframe.col("categoricalColumn").asArray();
|
||||
const cats = schemaClone.annotations.obsByName.categoricalColumn.categories;
|
||||
for (let i = 0; i < schemaClone.dataframe.nObs; i += 1) {
|
||||
// @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
|
||||
expect(makeScale(ct.rgb[i])).toEqual(ct.scale(cats.indexOf(data[i])));
|
||||
}
|
||||
});
|
||||
@@ -122,7 +125,7 @@ describe("categorical color helpers", () => {
|
||||
Array.from(schema.annotations.obsByName.categoricalColumn.categories)
|
||||
);
|
||||
const userDefinedColorTable = {
|
||||
categoricalColumn: shuffleCats.reduce((acc, label) => {
|
||||
categoricalColumn: shuffleCats.reduce((acc: any, label: any) => {
|
||||
acc[label] = randRGBColor();
|
||||
return acc;
|
||||
}, {}),
|
||||
@@ -136,12 +139,14 @@ describe("categorical color helpers", () => {
|
||||
"categoricalColumn",
|
||||
obsDataframe,
|
||||
schema,
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
|
||||
userColors
|
||||
);
|
||||
expect(ct).toBeDefined();
|
||||
const data = obsDataframe.col("categoricalColumn").asArray();
|
||||
for (let i = 0; i < schema.dataframe.nObs; i += 1) {
|
||||
expect(makeScale(ct.rgb[i])).toEqual(
|
||||
// @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
|
||||
ct.scale(cats.indexOf(data[i])).toString()
|
||||
);
|
||||
}
|
||||
@@ -154,31 +159,31 @@ TODO:
|
||||
2. user defined colors
|
||||
*/
|
||||
|
||||
function indexSchema(schema) {
|
||||
function indexSchema(schema: any) {
|
||||
schema.annotations.obsByName = Object.fromEntries(
|
||||
schema.annotations?.obs?.columns?.map((v) => [v.name, v]) ?? []
|
||||
schema.annotations?.obs?.columns?.map((v: any) => [v.name, v]) ?? []
|
||||
);
|
||||
schema.annotations.varByName = Object.fromEntries(
|
||||
schema.annotations?.var?.columns?.map((v) => [v.name, v]) ?? []
|
||||
schema.annotations?.var?.columns?.map((v: any) => [v.name, v]) ?? []
|
||||
);
|
||||
schema.layout.obsByName = Object.fromEntries(
|
||||
schema.layout?.obs?.map((v) => [v.name, v]) ?? []
|
||||
schema.layout?.obs?.map((v: any) => [v.name, v]) ?? []
|
||||
);
|
||||
schema.layout.varByName = Object.fromEntries(
|
||||
schema.layout?.var?.map((v) => [v.name, v]) ?? []
|
||||
schema.layout?.var?.map((v: any) => [v.name, v]) ?? []
|
||||
);
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
function makeScale(rgb) {
|
||||
function makeScale(rgb: any) {
|
||||
// make a scale string from a rgb float triple
|
||||
return `rgb(${(rgb[0] * 255) >>> 0}, ${(rgb[1] * 255) >>> 0}, ${
|
||||
(rgb[2] * 256) >>> 0
|
||||
})`;
|
||||
}
|
||||
|
||||
function shuffle(array) {
|
||||
function shuffle(array: any) {
|
||||
for (let i = array.length - 1; i > 0; i -= 1) {
|
||||
const j = (Math.random() * (i + 1)) >>> 0;
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
+1
@@ -24,6 +24,7 @@ describe("encode/decode", () => {
|
||||
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);
|
||||
+9
-2
@@ -75,6 +75,7 @@ const aSchemaResponse = {
|
||||
|
||||
const anAnnotationsObsJSONResponse = {
|
||||
names: ["name", "field1", "field2", "field3", "field4"],
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
||||
data: _()
|
||||
.range(nObs)
|
||||
.map((idx) => [
|
||||
@@ -91,6 +92,7 @@ const anAnnotationsObsJSONResponse = {
|
||||
|
||||
const anAnnotationsVarJSONResponse = {
|
||||
names: ["fieldA", "fieldB", "fieldC", "fieldD", "name"],
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
||||
data: _()
|
||||
.range(nVar)
|
||||
.map((idx) => [
|
||||
@@ -105,7 +107,7 @@ const anAnnotationsVarJSONResponse = {
|
||||
.value(),
|
||||
};
|
||||
|
||||
function encodeTypedArray(builder, uType, uData) {
|
||||
function encodeTypedArray(builder: any, uType: any, uData: any) {
|
||||
const uTypeName = NetEncoding.TypedArray[uType];
|
||||
const ArrayType = NetEncoding[uTypeName];
|
||||
const dv = ArrayType.createDataVector(builder, uData);
|
||||
@@ -114,7 +116,7 @@ function encodeTypedArray(builder, uType, uData) {
|
||||
return builder.endObject();
|
||||
}
|
||||
|
||||
function encodeMatrix(columns, colIndex = undefined) {
|
||||
function encodeMatrix(columns: any, colIndex = undefined) {
|
||||
/*
|
||||
IMPORTANT: this is not a general purpose encoder. in particular,
|
||||
it doesn't correctly handle all column index types, nor does it
|
||||
@@ -123,6 +125,7 @@ function encodeMatrix(columns, colIndex = undefined) {
|
||||
encodeMatrixFBS in matrix.py is more general. This is used only
|
||||
as a testing santity check (alt implementation).
|
||||
*/
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 0 arguments, but got 1.
|
||||
const utf8Encoder = new TextEncoder("utf-8");
|
||||
const builder = new flatbuffers.Builder(1024);
|
||||
const cols = map(columns, (carr) => {
|
||||
@@ -172,11 +175,13 @@ function encodeMatrix(columns, colIndex = undefined) {
|
||||
|
||||
const anAnnotationsObsFBSResponse = (() => {
|
||||
const columns = zip(...anAnnotationsObsJSONResponse.data).slice(1);
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
return encodeMatrix(columns, anAnnotationsObsJSONResponse.names);
|
||||
})();
|
||||
|
||||
const anAnnotationsVarFBSResponse = (() => {
|
||||
const columns = zip(...anAnnotationsVarJSONResponse.data).slice(1);
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
return encodeMatrix(columns, anAnnotationsVarJSONResponse.names);
|
||||
})();
|
||||
|
||||
@@ -185,11 +190,13 @@ const aLayoutFBSResponse = (() => {
|
||||
new Float32Array(nObs).fill(Math.random()),
|
||||
new Float32Array(nObs).fill(Math.random()),
|
||||
];
|
||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string[]' is not assignable to p... Remove this comment to see the full error message
|
||||
return encodeMatrix(coords, ["umap_0", "umap_1"]);
|
||||
})();
|
||||
|
||||
const aDataObsResponse = {
|
||||
var: [2, 4, 29],
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
||||
obs: _()
|
||||
.range(nObs)
|
||||
.map((idx) => [idx, Math.random(), Math.random(), Math.random()])
|
||||
+46
-16
@@ -126,7 +126,7 @@ const someData = [
|
||||
},
|
||||
];
|
||||
|
||||
let payments = null;
|
||||
let payments: any = null;
|
||||
beforeEach(() => {
|
||||
payments = new Crossfilter(someData);
|
||||
});
|
||||
@@ -138,7 +138,12 @@ describe("ImmutableTypedCrossfilter", () => {
|
||||
expect(payments.all()).toEqual(someData);
|
||||
|
||||
const p = payments
|
||||
.addDimension("quantity", "scalar", (i, d) => d[i].quantity, Int32Array)
|
||||
.addDimension(
|
||||
"quantity",
|
||||
"scalar",
|
||||
(i: any, d: any) => d[i].quantity,
|
||||
Int32Array
|
||||
)
|
||||
.select("quantity", { mode: "all" });
|
||||
expect(p).toBeDefined();
|
||||
expect(p.all()).toEqual(someData);
|
||||
@@ -158,7 +163,7 @@ describe("ImmutableTypedCrossfilter", () => {
|
||||
const p2 = payments.addDimension(
|
||||
"quantity",
|
||||
"scalar",
|
||||
(i, data) => data[i].quantity,
|
||||
(i: any, data: any) => data[i].quantity,
|
||||
Int32Array
|
||||
);
|
||||
|
||||
@@ -175,10 +180,20 @@ describe("ImmutableTypedCrossfilter", () => {
|
||||
|
||||
test("select all and none", () => {
|
||||
let p = payments
|
||||
.addDimension("quantity", "scalar", (i, d) => d[i].quantity, Int32Array)
|
||||
.addDimension("tip", "scalar", (i, d) => d[i].tip, Float32Array)
|
||||
.addDimension("total", "scalar", (i, d) => d[i].total, Float32Array)
|
||||
.addDimension("type", "enum", (i, d) => d[i].type);
|
||||
.addDimension(
|
||||
"quantity",
|
||||
"scalar",
|
||||
(i: any, d: any) => d[i].quantity,
|
||||
Int32Array
|
||||
)
|
||||
.addDimension("tip", "scalar", (i: any, d: any) => d[i].tip, Float32Array)
|
||||
.addDimension(
|
||||
"total",
|
||||
"scalar",
|
||||
(i: any, d: any) => d[i].total,
|
||||
Float32Array
|
||||
)
|
||||
.addDimension("type", "enum", (i: any, d: any) => d[i].type);
|
||||
expect(p).toBeDefined();
|
||||
|
||||
/* expect all records to be selected - default init state */
|
||||
@@ -230,11 +245,21 @@ describe("ImmutableTypedCrossfilter", () => {
|
||||
});
|
||||
|
||||
describe("scalar dimension", () => {
|
||||
let p;
|
||||
let p: any;
|
||||
beforeEach(() => {
|
||||
p = payments
|
||||
.addDimension("quantity", "scalar", (i, d) => d[i].quantity, Int32Array)
|
||||
.addDimension("tip", "scalar", (i, d) => d[i].tip, Float32Array)
|
||||
.addDimension(
|
||||
"quantity",
|
||||
"scalar",
|
||||
(i: any, d: any) => d[i].quantity,
|
||||
Int32Array
|
||||
)
|
||||
.addDimension(
|
||||
"tip",
|
||||
"scalar",
|
||||
(i: any, d: any) => d[i].tip,
|
||||
Float32Array
|
||||
)
|
||||
.select("tip", { mode: "all" });
|
||||
});
|
||||
|
||||
@@ -277,9 +302,9 @@ describe("ImmutableTypedCrossfilter", () => {
|
||||
});
|
||||
|
||||
describe("enum dimension", () => {
|
||||
let p;
|
||||
let p: any;
|
||||
beforeEach(() => {
|
||||
p = payments.addDimension("type", "enum", (i, d) => d[i].type);
|
||||
p = payments.addDimension("type", "enum", (i: any, d: any) => d[i].type);
|
||||
});
|
||||
|
||||
test("all", () => {
|
||||
@@ -317,7 +342,7 @@ describe("ImmutableTypedCrossfilter", () => {
|
||||
});
|
||||
|
||||
describe("spatial dimension", () => {
|
||||
let p;
|
||||
let p: any;
|
||||
beforeEach(() => {
|
||||
const X = someData.map((r) => r.coords[0]);
|
||||
const Y = someData.map((r) => r.coords[1]);
|
||||
@@ -406,14 +431,19 @@ describe("ImmutableTypedCrossfilter", () => {
|
||||
});
|
||||
|
||||
describe("non-finite scalars", () => {
|
||||
let p;
|
||||
let p: any;
|
||||
beforeEach(() => {
|
||||
p = payments
|
||||
.addDimension("quantity", "scalar", (i, d) => d[i].quantity, Int32Array)
|
||||
.addDimension(
|
||||
"quantity",
|
||||
"scalar",
|
||||
(i: any, d: any) => d[i].quantity,
|
||||
Int32Array
|
||||
)
|
||||
.addDimension(
|
||||
"nonFinite",
|
||||
"scalar",
|
||||
(i, d) => d[i].nonFinite,
|
||||
(i: any, d: any) => d[i].nonFinite,
|
||||
Float32Array
|
||||
)
|
||||
.select("quantity", { mode: "all" });
|
||||
+13
-5
@@ -15,7 +15,7 @@ paths for:
|
||||
const pInf = Number.POSITIVE_INFINITY;
|
||||
const nInf = Number.NEGATIVE_INFINITY;
|
||||
|
||||
function fillRange(arr, start = 0) {
|
||||
function fillRange(arr: any, start = 0) {
|
||||
const larr = arr;
|
||||
for (let i = 0, len = larr.length; i < len; i += 1) {
|
||||
larr[i] = i + start;
|
||||
@@ -23,7 +23,7 @@ function fillRange(arr, start = 0) {
|
||||
return larr;
|
||||
}
|
||||
|
||||
function fillRand(arr) {
|
||||
function fillRand(arr: any) {
|
||||
for (let i = 0, len = arr.length; i < len; i += 1) {
|
||||
arr[i] = Math.random();
|
||||
}
|
||||
@@ -48,16 +48,22 @@ describe("sortArray", () => {
|
||||
describe("finite numbers", () => {
|
||||
[Array, Float32Array, Uint32Array, Int32Array, Float64Array].map((Type) =>
|
||||
test(Type.name, () => {
|
||||
// @ts-expect-error ts-migrate(2349) FIXME: This expression is not callable.
|
||||
expect(sortArray(Type.from([6, 5, 4, 3, 2, 1, 0]))).toMatchObject(
|
||||
// @ts-expect-error ts-migrate(2349) FIXME: This expression is not callable.
|
||||
Type.from([0, 1, 2, 3, 4, 5, 6])
|
||||
);
|
||||
|
||||
// @ts-expect-error ts-migrate(2349) FIXME: This expression is not callable.
|
||||
expect(sortArray(Type.from([6, 5, 4, 3, 2, 1]))).toMatchObject(
|
||||
// @ts-expect-error ts-migrate(2349) FIXME: This expression is not callable.
|
||||
Type.from([1, 2, 3, 4, 5, 6])
|
||||
);
|
||||
|
||||
const source = fillRand(new Type(1000));
|
||||
// @ts-expect-error ts-migrate(2349) FIXME: This expression is not callable.
|
||||
expect(sortArray(Type.from(source))).toMatchObject(
|
||||
// @ts-expect-error ts-migrate(2349) FIXME: This expression is not callable.
|
||||
Type.from(source).sort()
|
||||
);
|
||||
})
|
||||
@@ -130,22 +136,24 @@ describe("sortIndex", () => {
|
||||
describe("finite numbers", () => {
|
||||
[Array, Float32Array, Uint32Array, Int32Array, Float64Array].map((Type) =>
|
||||
test(Type.name, () => {
|
||||
// @ts-expect-error ts-migrate(2349) FIXME: This expression is not callable.
|
||||
const source1 = Type.from([6, 5, 4, 3, 2, 1, 0]);
|
||||
const index1 = fillRange(new Uint32Array(source1.length));
|
||||
expect(sortIndex(index1, source1)).toMatchObject(
|
||||
index1.sort((a, b) => source1[a] - source1[b])
|
||||
index1.sort((a: any, b: any) => source1[a] - source1[b])
|
||||
);
|
||||
|
||||
// @ts-expect-error ts-migrate(2349) FIXME: This expression is not callable.
|
||||
const source2 = Type.from([6, 5, 4, 3, 2, 1]);
|
||||
const index2 = fillRange(new Uint32Array(source2.length));
|
||||
expect(sortIndex(index2, source2)).toMatchObject(
|
||||
index2.sort((a, b) => source1[a] - source1[b])
|
||||
index2.sort((a: any, b: any) => source1[a] - source1[b])
|
||||
);
|
||||
|
||||
const source3 = fillRand(new Type(1000));
|
||||
const index3 = fillRange(new Uint32Array(source3.length));
|
||||
expect(sortIndex(index3, source3)).toMatchObject(
|
||||
index3.sort((a, b) => source1[a] - source1[b])
|
||||
index3.sort((a: any, b: any) => source1[a] - source1[b])
|
||||
);
|
||||
})
|
||||
);
|
||||
Reference in New Issue
Block a user