Added @typescript-eslint/recommended config with suppressions (#2345)

* Disabled @blueprintjs/classes-constants. #2288.

* thuang-eslint-bp-off (#2344)

* Disabled @blueprintjs/classes-constants on webpack dev and shared. #2288.

* Added TS recommended, suppress lint errors codemod.

* Added per-error/warning ignore for tests.

* Added per-error/warning ignore for configuration.

* Added per-error/warning ignore for src. Removed suppress package.

* Minor linting.

Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
This commit is contained in:
Mim Hastie
2021-07-28 16:06:34 -07:00
committed by GitHub
co-authored by Timmy Huang
parent 32f60a1547
commit 27575b8d86
163 changed files with 1827 additions and 64 deletions
+11
View File
@@ -6,7 +6,9 @@ import { postNetworkErrorToast } from "../components/framework/toasters";
dispatch an action error to the user. Currently we use
async toasts.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
let networkErrorToastKey: any = null;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const dispatchNetworkErrorMessageToUser = (message: any) => {
if (!networkErrorToastKey) {
networkErrorToastKey = postNetworkErrorToast(message);
@@ -18,8 +20,11 @@ export const dispatchNetworkErrorMessageToUser = (message: any) => {
/*
Catch unexpected errors and make sure we don't lose them!
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function catchErrorsWrap(fn: any, dispatchToUser = false) {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
return (dispatch: any, getState: any) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
fn(dispatch, getState).catch((error: any) => {
console.error(error);
if (dispatchToUser) {
@@ -34,6 +39,7 @@ export function catchErrorsWrap(fn: any, dispatchToUser = false) {
* Wrapper to perform async fetch with some modest error handling
* and decoding. Arguments are identical to standard fetch.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const doFetch = async (url: any, init = {}) => {
try {
// add defaults to the fetch init param.
@@ -42,6 +48,7 @@ export const doFetch = async (url: any, init = {}) => {
credentials: "include",
...init,
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const acceptType = (init as any).headers?.get("Accept");
const res = await fetch(url, init);
if (
@@ -67,6 +74,7 @@ export const doFetch = async (url: any, init = {}) => {
/*
Wrapper to perform an async fetch and JSON decode response.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const doJsonRequest = async (url: any, init = {}) => {
const res = await doFetch(url, {
...init,
@@ -78,6 +86,7 @@ export const doJsonRequest = async (url: any, init = {}) => {
/*
Wrapper to perform an async fetch for binary data.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const doBinaryRequest = async (url: any, init = {}) => {
const res = await doFetch(url, {
...init,
@@ -101,7 +110,9 @@ Parameters:
So [1, 2, 3, 4, 10, 11, 14] -> [ [1, 4], [10, 11], 14]
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export const rangeEncodeIndices = (
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
indices: any,
minRangeLength = 3,
sorted = false
+14
View File
@@ -11,19 +11,25 @@ const panBound = 0.8;
const scratch0 = new Float32Array(16);
const scratch1 = new Float32Array(16);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function clamp(val: any, rng: any) {
return Math.max(Math.min(val, rng[1]), rng[0]);
}
class Camera {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
canvas: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
prevEvent: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
viewMatrix: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
viewMatrixInv: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
constructor(canvas: any) {
this.prevEvent = {
clientX: 0,
@@ -47,6 +53,7 @@ class Camera {
return this.viewMatrix[0];
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
pan(dx: any, dy: any) {
const m = this.viewMatrix;
const dyRange = [
@@ -67,6 +74,7 @@ class Camera {
mat3.invert(this.viewMatrixInv, m);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
zoomAt(d: any, x = 0, y = 0) {
/*
Camera zoom at [x,y]
@@ -90,12 +98,14 @@ class Camera {
Event handling
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
flush(e: any) {
this.prevEvent.type = e.type;
this.prevEvent.clientX = e.clientX;
this.prevEvent.clientY = e.clientY;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
localPosition(target: any, canvasX: any, canvasY: any, projectionInvTF: any) {
/*
Convert mouse position to local
@@ -116,6 +126,7 @@ class Camera {
return pos;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
mousePan(e: any, projectionTF: any) {
const projectionInvTF = mat3.invert(scratch0, projectionTF);
const pos = this.localPosition(
@@ -136,6 +147,7 @@ class Camera {
return true;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
wheelZoom(e: any, projectionTF: any) {
const { height } = this.canvas;
const { deltaY, deltaMode, clientX, clientY } = e;
@@ -152,6 +164,7 @@ class Camera {
return true;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
handleEvent(e: any, projectionTF: any) {
/*
process the event, and return true if camera view changed
@@ -181,6 +194,7 @@ class Camera {
}
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
function attachCamera(canvas: any) {
return new Camera(canvas);
}
+6
View File
@@ -11,19 +11,25 @@ TL;DR: sort order is:
import isNumber from "is-number";
import * as globals from "../globals";
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function caseInsensitiveCompare(a: any, b: any) {
const textA = String(a).toUpperCase();
const textB = String(b).toUpperCase();
return textA < textB ? -1 : textA > textB ? 1 : 0;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
const catLabelSort = (isUserAnno: any, values: any) => {
/* this sort could be memoized for perf */
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const strings: any = [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const ints: any = [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const unassignedOrNaN: any = [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
values.forEach((v: any) => {
if (isUserAnno && v === globals.unassignedCategoryLabel) {
unassignedOrNaN.push(v);
+15
View File
@@ -23,10 +23,15 @@ label -> {
}
*/
const getCoordinatesByLabel = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
categoryName: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
categoryDf: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
layoutChoice: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
layoutDf: any
) => {
const coordsByCategoryLabel = new Map();
@@ -105,10 +110,15 @@ const getCoordinatesByLabel = (
*/
const calcMedianCentroid = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
categoryName: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
categoryDf: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
layoutChoice: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
layoutDf: any
) => {
// generate a map describing the coordinates for each label within the given category
@@ -145,10 +155,15 @@ const calcMedianCentroid = (
// A simple function to hash the parameters
const hashMedianCentroid = (
// @ts-expect-error ts-migrate(6133) FIXME: 'schema' is declared but its value is never read.
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
categoryName: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
categoryDf: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
layoutChoice: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
layoutDf: any
) => {
const category = categoryDf.col(categoryName);
+1
View File
@@ -8,6 +8,7 @@
* @returns a number
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default function clamp(val: any, rng: any) {
return Math.max(Math.min(val, rng[1]), rng[0]);
}
+1
View File
@@ -10,6 +10,7 @@ If `setTo` is not undefined, values outside the [lower, upper] range will be set
`setTo`.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default function clip(arr: any, lower: any, upper: any, setTo: any) {
const lowerSet = setTo === undefined ? lower : setTo;
const upperSet = setTo === undefined ? upper : setTo;
+4
View File
@@ -11,15 +11,19 @@ objects.
import { memoize } from "./util";
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function hashDataframe(df: any) {
if (df.isEmpty()) return "";
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return df.__columnsAccessor.map((c: any) => c.__id).join(",");
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function noop(df: any) {
return df;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
const dataframeMemo = (capacity = 100) =>
memoize(noop, hashDataframe, capacity);
+54
View File
@@ -73,25 +73,34 @@ Dataframe
**/
class Dataframe {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
__columns: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
__columnsAccessor: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
__id: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
colIndex: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
dims: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
length: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
rowIndex: any;
/**
Constructors & factories
**/
constructor(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
dims: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
columnarData: any,
rowIndex = null,
colIndex = null,
@@ -137,10 +146,15 @@ class Dataframe {
Object.freeze(this);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
static __errorChecks(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
dims: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
columnarData: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
rowIndex: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
colIndex: any
) {
const [nRows, nCols] = dims;
@@ -180,6 +194,7 @@ class Dataframe {
}
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
static __compileColumn(column: any, getRowByOffset: any, getRowByLabel: any) {
/*
Each column accessor is a function which will lookup data by
@@ -215,11 +230,13 @@ class Dataframe {
const __id = __getMemoId();
/* get value by row label */
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const get = function get(rlabel: any) {
return column[getRowByOffset(rlabel)];
};
/* get value by row offset */
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const iget = function iget(roffset: any) {
return column[roffset];
};
@@ -230,11 +247,13 @@ class Dataframe {
};
/* test for row label inclusion in column */
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const has = function has(rlabel: any) {
const offset = getRowByOffset(rlabel);
return offset >= 0 && offset < length;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const ihas = function ihas(offset: any) {
return offset >= 0 && offset < length;
};
@@ -246,6 +265,7 @@ class Dataframe {
NOTE: not found return is DIFFERENT than the default Array.indexOf as
-1 is a plausible Dataframe row/col label.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const indexOf = function indexOf(value: any) {
const offset = column.indexOf(value);
if (offset === -1) {
@@ -270,10 +290,12 @@ class Dataframe {
Create histogram bins for this column. Memoized.
*/
const _memoHistoCat = memoize(_histogramCategorical, hashCategorical);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const histogramCategorical = (by: any) => _memoHistoCat(get, by);
let histogram = null;
if (isTypedArray(column)) {
const mFn = memoize(histogramContinuous, hashContinuous);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
histogram = (bins: any, domain: any, by: any) =>
mFn(get, bins, domain, by);
} else {
@@ -295,6 +317,7 @@ class Dataframe {
return get;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
__compile(accessors: any) {
/*
Compile data accessors for each column.
@@ -303,6 +326,7 @@ class Dataframe {
*/
const getRowByOffset = this.rowIndex.getOffset.bind(this.rowIndex);
const getRowByLabel = this.rowIndex.getLabel.bind(this.rowIndex);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.__columnsAccessor = this.__columns.map((column: any, idx: any) => {
if (accessors[idx]) {
return accessors[idx];
@@ -312,6 +336,7 @@ class Dataframe {
Object.freeze(this.__columnsAccessor);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
clone() {
/*
Clone this dataframe
@@ -326,6 +351,7 @@ class Dataframe {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
withCol(label: any, colData: any, withRowIndex = null) {
/*
Create a new DF, which is `this` plus the new column. Example:
@@ -369,6 +395,7 @@ class Dataframe {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
withColsFrom(dataframe: any, labels: any) {
/*
return a new dataframe containing all columns from both `this` and the
@@ -433,6 +460,7 @@ class Dataframe {
// otherwise, bulid a new dataframe combining columns from both
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const srcOffsets = srcLabels.map((l: any) =>
dataframe.colIndex.getOffset(l)
);
@@ -447,11 +475,13 @@ class Dataframe {
const { rowIndex } = this;
const columns = [
...this.__columns,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
...srcOffsets.map((i: any) => dataframe.__columns[i]),
];
const colIndex = this.colIndex.withLabels(dstLabels);
const columnsAccessor = [
...this.__columnsAccessor,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
...srcOffsets.map((i: any) => dataframe.__columnsAccessor[i]),
];
@@ -465,12 +495,14 @@ class Dataframe {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
withColsFromAll(dataframes = []) {
dataframes = Array.isArray(dataframes) ? dataframes : [dataframes];
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
return dataframes.reduce((acc, df) => acc.withColsFrom(df), this);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
dropCol(label: any) {
/*
Create a new dataframe, omitting one columns.
@@ -507,6 +539,7 @@ class Dataframe {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
renameCol(oldLabel: any, newLabel: any) {
/*
Accelerator for dropping a column and then adding it again with a new label
@@ -532,6 +565,7 @@ class Dataframe {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
replaceColData(label: any, newColData: any) {
/*
Accelerator for dropping a column then adding it again with same
@@ -553,6 +587,7 @@ class Dataframe {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
static empty(rowIndex = null, colIndex = null) {
const dims = [
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
@@ -564,6 +599,7 @@ class Dataframe {
return new Dataframe(dims, new Array(dims[1]), rowIndex, colIndex);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
static create(dims: any, columnarData: any) {
/*
Create a dataframe from raw columnar data. All column arrays
@@ -575,6 +611,7 @@ class Dataframe {
return new Dataframe(dims, columnarData, null, null);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
__subset(newRowIndex: any, newColIndex: any) {
const dims = [...this.dims];
@@ -595,6 +632,7 @@ class Dataframe {
let { rowIndex } = this;
if (newRowIndex) {
const rowOffsets = this.rowIndex.getOffsets(newRowIndex.labels());
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
__columns = __columns.map((col: any) => {
const newCol = new col.constructor(rowOffsets.length);
for (let i = 0, l = rowOffsets.length; i < l; i += 1) {
@@ -617,6 +655,7 @@ class Dataframe {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
subset(rowLabels: any, colLabels = null, withRowIndex = null) {
/*
Subset by row/col labels.
@@ -639,6 +678,7 @@ class Dataframe {
return this.__subset(rowIndex, colIndex);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isubset(rowOffsets: any, colOffsets = null, withRowIndex = null) {
/*
Subset by row/col offset.
@@ -663,6 +703,7 @@ class Dataframe {
return this.__subset(rowIndex, colIndex);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isubsetMask(rowMask: any, colMask = null, withRowIndex = null) {
/*
Subset on row/column based upon a truthy/falsey array (a mask).
@@ -682,6 +723,7 @@ class Dataframe {
}
/* convert masks to lists - method wastes space, but is fast */
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const toList = (mask: any, maxSize: any) => {
if (!mask) {
return null;
@@ -706,11 +748,13 @@ class Dataframe {
Data access with row/col.
**/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
columns() {
/* return all column accessors as an array, in offset order */
return [...this.__columnsAccessor];
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
col(columnLabel: any) {
/*
Return accessor bound to a column. Allows random row access
@@ -731,6 +775,7 @@ class Dataframe {
return this.__columnsAccessor[coff];
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
icol(columnOffset: any) {
/*
Return column accessor by offset.
@@ -740,6 +785,7 @@ class Dataframe {
: undefined;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
at(r: any, c: any) {
/*
Access a single value, for a row/col label pair.
@@ -757,6 +803,7 @@ class Dataframe {
return this.__columns[coff][roff];
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
iat(r: any, c: any) {
/*
Access a single value, for a row/col offset (integer) position.
@@ -770,6 +817,7 @@ class Dataframe {
return this.__columns[c][r];
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
has(r: any, c: any) {
/*
Test if row/col labels exist in the dataframe - returns true/false
@@ -780,6 +828,7 @@ class Dataframe {
return coff >= 0 && coff < nCols && roff >= 0 && roff < nRows;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
ihas(r: any, c: any) {
/*
Test if row/col offset (integer) position exists in the
@@ -796,6 +845,7 @@ class Dataframe {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
hasCol(c: any) {
/*
Test if col label exists - return true/false
@@ -803,6 +853,7 @@ class Dataframe {
return !!this.col(c);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
isEmpty() {
/*
Return true if this is an empty dataframe, ie, has dimensions [0,0]
@@ -818,6 +869,7 @@ class Dataframe {
add these as useful.
****/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
mapColumns(callback: any) {
/*
map all columns in the dataframe, returning a new dataframe comprised of the
@@ -825,9 +877,11 @@ class Dataframe {
callback MUST not modify the column, but instead return a mutated copy.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const columns = this.__columns.map((colData: any, colIdx: any) =>
callback(colData, colIdx, this)
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const columnsAccessor = columns.map((c: any, idx: any) =>
this.__columns[idx] === c ? this.__columnsAccessor[idx] : undefined
);
+16
View File
@@ -3,6 +3,7 @@ Dataframe histogram
*/
import { isTypedArray } from "./util";
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _histogramContinuous(column: any, bins: any, min: any, max: any) {
const valBins = new Array(bins).fill(0);
if (!column) {
@@ -22,10 +23,15 @@ function _histogramContinuous(column: any, bins: any, min: any, max: any) {
}
function _histogramContinuousBy(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
column: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
bins: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
min: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
max: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
by: any
) {
const byMap = new Map();
@@ -52,6 +58,7 @@ function _histogramContinuousBy(
return byMap;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _histogramCategorical(column: any) {
const valMap = new Map();
if (!column) {
@@ -69,6 +76,7 @@ function _histogramCategorical(column: any) {
return valMap;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _histogramCategoricalBy(column: any, by: any) {
const byMap = new Map();
if (!column || !by) {
@@ -96,6 +104,7 @@ function _histogramCategoricalBy(column: any, by: any) {
/*
Count category occupancy. Optional group-by category.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function histogramCategorical(column: any, by: any) {
if (by && isTypedArray(by)) {
throw new Error("Group by column must be categorical");
@@ -108,6 +117,7 @@ export function histogramCategorical(column: any, by: any) {
/*
Memoization hash for histogramCategorical()
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function hashCategorical(column: any, by: any) {
if (by) {
return `${column.__id}:${by.__id}`;
@@ -119,10 +129,13 @@ export function hashCategorical(column: any, by: any) {
Bin counts for continuous/scalar values, with optional group-by category.
Values outside domain are ignored.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function histogramContinuous(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
column: any,
bins = 40,
domain = [0, 1],
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
by: any
) {
if (by && isTypedArray(by)) {
@@ -137,10 +150,13 @@ export function histogramContinuous(
/*
Memoization hash for histogramContinuous
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function hashContinuous(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
column: any,
bins = "",
domain = [0, 0],
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
by: any
) {
const [min, max] = domain;
+69
View File
@@ -10,6 +10,7 @@ import { __getMemoId } from "./util";
/*
Private utility functions
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function extent(tarr: any) {
let min = 0x7fffffff;
let max = ~min; // eslint-disable-line no-bitwise -- Establishes 0 of same size
@@ -26,19 +27,23 @@ function extent(tarr: any) {
}
class IdentityInt32Index {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
maxOffset: any;
/*
identity/noop index, with small assumptions that labels are int32
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(maxOffset: any) {
this.maxOffset = maxOffset;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
get __id() {
return `IdentityInt32Index_${this.maxOffset}`;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
labels() {
// memoize
const k = fillRange(new Int32Array(this.maxOffset));
@@ -48,30 +53,38 @@ class IdentityInt32Index {
return k;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
getOffset(i: any) {
// label to offset
return Number.isInteger(i) && i >= 0 && i < this.maxOffset ? i : undefined;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
getOffsets(arr: any) {
// labels to offsets
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return arr.map((i: any) => this.getOffset(i));
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
getLabel(i: any) {
// offset to label
return Number.isInteger(i) && i >= 0 && i < this.maxOffset ? i : undefined;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
getLabels(arr: any) {
// offsets to labels
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return arr.map((i: any) => this.getLabel(i));
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
size() {
return this.maxOffset;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
__promote(labelArray: any) {
/*
time/space decision - based on the resulting density
@@ -90,6 +103,7 @@ class IdentityInt32Index {
return new DenseInt32Index(labelArray, [minLabel, maxLabel]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
subset(labels: any) {
/* validate subset */
const { maxOffset } = this;
@@ -102,11 +116,13 @@ class IdentityInt32Index {
}
/* identity index - labels are offsets */
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isubset(offsets: any) {
return this.subset(offsets);
}
/* identity index - labels are offsets */
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isubsetMask(mask: any) {
let count = 0;
if (mask.length !== this.maxOffset) {
@@ -123,6 +139,7 @@ class IdentityInt32Index {
return this.subset(labels);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
withLabel(label: any) {
if (label === this.maxOffset) {
return new IdentityInt32Index(label + 1);
@@ -130,10 +147,12 @@ class IdentityInt32Index {
return this.__promote([...this.labels(), label]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
withLabels(labels: any) {
return this.__promote([...this.labels(), ...labels]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
dropLabel(label: any) {
if (label === this.maxOffset - 1) {
return new IdentityInt32Index(label);
@@ -145,20 +164,28 @@ class IdentityInt32Index {
}
class DenseInt32Index {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
__id: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
getLabel: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
getLabels: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
getOffset: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
getOffsets: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
index: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
minLabel: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
rindex: any;
/*
@@ -167,6 +194,7 @@ class DenseInt32Index {
of the forward index labels must be known a priori (so that the index
array can be pre-allocated).
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(labels: any, labelRange = null) {
if (labels.constructor !== Int32Array) {
labels = new Int32Array(labels);
@@ -192,35 +220,45 @@ class DenseInt32Index {
this.__compile();
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
__compile() {
const { minLabel, index, rindex } = this;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.getOffset = function getOffset(l: any) {
if (!Number.isInteger(l)) return undefined;
const offset = index[l - minLabel];
return offset === -1 ? undefined : offset;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.getOffsets = function getOffsets(arr: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return arr.map((i: any) => this.getOffset(i));
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.getLabel = function getLabel(i: any) {
return Number.isInteger(i) ? rindex[i] : undefined;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.getLabels = function getLabels(arr: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return arr.map((i: any) => this.getLabel(i));
};
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
labels() {
return this.rindex;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
size() {
return this.rindex.length;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
__promote(labelArray: any) {
/*
time/space decision - if we are going to use less than 10% of the
@@ -238,6 +276,7 @@ class DenseInt32Index {
return new DenseInt32Index(labelArray, [minLabel, maxLabel]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
subset(labels: any) {
/* validate subset */
for (let i = 0, l = labels.length; i < l; i += 1) {
@@ -249,6 +288,7 @@ class DenseInt32Index {
return this.__promote(labels);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isubset(offsets: any) {
/* validate subset */
const { rindex } = this;
@@ -263,6 +303,7 @@ class DenseInt32Index {
return this.__promote(labels);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isubsetMask(mask: any) {
const { rindex } = this;
if (mask.length !== rindex.length)
@@ -279,14 +320,17 @@ class DenseInt32Index {
return this.__promote(labels);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
withLabel(label: any) {
return this.__promote([...this.labels(), label]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
withLabels(labels: any) {
return this.__promote([...this.labels(), ...labels]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
dropLabel(label: any) {
const labelArray = [...this.labels()];
labelArray.splice(labelArray.indexOf(label), 1);
@@ -295,30 +339,39 @@ class DenseInt32Index {
}
class KeyIndex {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
__id: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
getLabel: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
getLabels: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
getOffset: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
getOffsets: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
index: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
rindex: any;
/*
KeyIndex indexes arbitrary JS primitive types, and uses a Map()
as its core data structure.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(labels: any) {
const index = new Map();
if (labels === undefined) {
labels = [];
}
const rindex = labels;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
labels.forEach((v: any, i: any) => {
index.set(v, i);
});
@@ -334,33 +387,43 @@ class KeyIndex {
this.__compile();
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
__compile() {
const { index, rindex } = this;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.getOffset = function getOffset(k: any) {
return index.get(k);
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.getOffsets = function getOffsets(arr: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return arr.map((l: any) => this.getOffset(l));
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.getLabel = function getLabel(i: any) {
return Number.isInteger(i) ? rindex[i] : undefined;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.getLabels = function getLabels(arr: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return arr.map((i: any) => this.getLabel(i));
};
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
labels() {
return this.rindex;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
size() {
return this.rindex.length;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
subset(labels: any) {
/* validate subset */
for (let i = 0, l = labels.length; i < l; i += 1) {
@@ -374,6 +437,7 @@ class KeyIndex {
return new KeyIndex(labels);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isubset(offsets: any) {
const { rindex } = this;
const maxOffset = rindex.length;
@@ -388,6 +452,7 @@ class KeyIndex {
return new KeyIndex(labels);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isubsetMask(mask: any) {
const { rindex } = this;
if (mask.length !== rindex.length)
@@ -404,14 +469,17 @@ class KeyIndex {
return new KeyIndex(labels);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
withLabel(label: any) {
return new KeyIndex([...this.rindex, label]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
withLabels(labels: any) {
return new KeyIndex([...this.rindex, ...labels]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
dropLabel(label: any) {
const idx = this.rindex.indexOf(label);
const labelArray = [...this.rindex];
@@ -420,6 +488,7 @@ class KeyIndex {
}
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
function isLabelIndex(i: any) {
return (
i instanceof IdentityInt32Index ||
+2
View File
@@ -13,6 +13,7 @@ import { sortArray } from "../typedCrossfilter/sort";
// @ts-expect-error ts-migrate(6133) FIXME: 'v' is declared but its value is never read.
const centileNames = new Array(101).fill(0).map((v, idx) => idx / 100);
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function summarizeContinuous(col: any) {
let min;
let max;
@@ -64,6 +65,7 @@ export function summarizeContinuous(col: any) {
};
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function summarizeCategorical(col: any) {
const categoryCounts = new Map();
if (col) {
+6
View File
@@ -4,13 +4,16 @@ Private utility code for dataframe
export { isTypedArray, isArrayOrTypedArray } from "../typeHelpers";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function callOnceLazy(f: any) {
/*
call function once, and save the result, regardless of arguments (this is not
the same as typical memoization).
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
let value: any;
let calledOnce = false;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const result = function result(...args: any[]) {
if (!calledOnce) {
value = f(...args);
@@ -21,6 +24,7 @@ export function callOnceLazy(f: any) {
return result;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function memoize(fn: any, hashFn: any, maxResultsCached = -1) {
/*
function memoization, with user-provided hash. hashFn must return a
@@ -29,6 +33,7 @@ export function memoize(fn: any, hashFn: any, maxResultsCached = -1) {
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality
*/
const cache = new Map();
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const wrap = function wrap(...args: any[]) {
const key = hashFn(...args);
if (cache.has(key)) {
@@ -57,6 +62,7 @@ export function memoize(fn: any, hashFn: any, maxResultsCached = -1) {
memoization helpers - just a global counter.
**/
let __DataframeMemoId__ = 0;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function __getMemoId() {
const id = __DataframeMemoId__;
__DataframeMemoId__ += 1;
+1
View File
@@ -6,6 +6,7 @@ If undefined or empty array, or array contains only non-finite numbers,
will return [undefined, undefined]
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
function finiteExtent(tarr: any) {
let min;
let max;
+1
View File
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default function fromEntries(arr: any) {
/*
Similar to Object.fromEntries, but only handles array.
+2
View File
@@ -10,10 +10,12 @@ import significantDigits from "./significantDigits";
* @returns - the number formatted as scientific, if it's big enough
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default function maybeScientific(x: any) {
let format = ",";
const _ticks = x.ticks(4);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
if (x.domain().some((n: any) => Math.abs(n) >= 10000)) {
/*
heuristic: if the last tick d3 wants to render has one significant
+9
View File
@@ -13,16 +13,22 @@ anno matrix namespaces. It is still used by the component tier.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const makeDimensionName = (namespace: any, key: any) => `${namespace}_${key}`;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const layoutDimensionName = (key: any) =>
makeDimensionName("layout", key);
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const obsAnnoDimensionName = (key: any) =>
makeDimensionName("obsAnno", key);
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const diffexpDimensionName = (key: any) =>
makeDimensionName("varData_diffexp", key);
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const userDefinedDimensionName = (key: any) =>
makeDimensionName("varData_userDefined", key);
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export const geneSetSummaryDimensionName = (key: any) =>
makeDimensionName("geneSetSummary", key);
@@ -37,8 +43,11 @@ export const geneSetSummaryDimensionName = (key: any) =>
ie., makeContinuousDimensionName(continuousNamespace = {isObs: true}, "total_reads")
see: histogram brush, as it doesn't know what type of continuous it was with only field
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export const makeContinuousDimensionName = (
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
continuousNamespace: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
key: any
) => {
let name;
+1
View File
@@ -6,6 +6,7 @@
import pull from "lodash.pull";
import uniq from "lodash.uniq";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default function parseBulkGeneString(geneString: any) {
return pull(uniq(geneString.split(/[ ,]+/)), "");
}
+2
View File
@@ -6,6 +6,7 @@ import scaleRGB from "./scaleRGB";
//
const colorCache = {};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function parseColorName(c: any) {
if (c[0] !== "#") {
const _c = c.replace(/[^\d,.]/g, "").split(",");
@@ -22,6 +23,7 @@ function parseColorName(c: any) {
];
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default (c: any) => {
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
let cv = colorCache[c];
+16
View File
@@ -37,13 +37,18 @@ function compare(a, b) {
export default class PromiseLimit {
constructor(maxConcurrency = 5) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).queue = new TinyQueue([], compare);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).maxConcurrency = maxConcurrency;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).pending = 0;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).insertCounter = 0;
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'p' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
priorityAdd(p, fn, ...args) {
// p - numermic priority (lower first)
// fn - must return a promise
@@ -52,6 +57,7 @@ export default class PromiseLimit {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'fn' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
add(fn, ...args) {
// fn - must return a promise
// args - will be passed to fn
@@ -63,23 +69,33 @@ export default class PromiseLimit {
**/
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'priority' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
_push(priority, fn, args) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const order = (this as any).insertCount;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).insertCount += 1;
return new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).queue.push({ priority, order, fn, args, resolve, reject });
this._resolveNext(false);
});
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
_resolveNext = (completed = true) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
if (completed) (this as any).pending -= 1;
while (
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).queue.length > 0 &&
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).pending < (this as any).maxConcurrency
) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const task = (this as any).queue.pop(); // order of insertion
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(this as any).pending += 1;
const { resolve, reject, fn, args } = task;
+1
View File
@@ -15,6 +15,7 @@ Arguments:
import { sortArray } from "./typedCrossfilter/sort";
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'quantArr' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export default function quantile(quantArr, tarr, sorted = false) {
/*
start with the naive (sort) implementation. Later, use a faster partition
+3
View File
@@ -31,11 +31,13 @@ function _doFill(arr, start, step, count) {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'arr' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function rangeFill(arr, start = 0, step = 1) {
return _doFill(arr, start, step, arr.length);
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'start' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function range(start, stop, step) {
if (start === undefined) return [];
if (stop === undefined) {
@@ -48,6 +50,7 @@ export function range(start, stop, step) {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'start' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function linspace(start, stop, nsteps) {
// @ts-expect-error ts-migrate(2363) FIXME: The right-hand side of an arithmetic operation mus... Remove this comment to see the full error message
const delta = (stop - start) / (nsteps - 1).toFixed();
+4
View File
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default function renderThrottle(callback: any) {
/*
This wraps a call to requestAnimationFrame(), enforcing a single
@@ -5,9 +6,12 @@ export default function renderThrottle(callback: any) {
of times, and it will coallesce multiple inter-frame calls into a
single render).
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
let rafCurrentlyInProgress: any = null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return function f(this: any) {
if (rafCurrentlyInProgress) return;
// eslint-disable-next-line @typescript-eslint/no-this-alias --- FIXME: disabled temporarily on migrate to TS.
const context = this;
rafCurrentlyInProgress = window.requestAnimationFrame(() => {
callback.apply(context);
+3
View File
@@ -6,14 +6,17 @@
// myScale(0) === -1
// this is is equivalent to d3.scaleLinear().domain([0,1]).range([-1,1])
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default (domain: any, range: any) => {
const domainStart = domain[0];
const scale = (range[1] - range[0]) / (domain[1] - domain[0]);
const invScale = 1 / scale;
const rangeStart = range[0];
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const f = (value: any) => (value - domainStart) * scale + rangeStart;
// inverter
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
f.invert = (value: any) => (value - rangeStart) * invScale + domainStart;
return f;
+1
View File
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default (input: any) => {
const outputMax = 1;
const outputMin = 0;
+1
View File
@@ -2,6 +2,7 @@
via https://github.com/nodef/extra-number/blob/master/scripts/significantDigits.js
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export default (n: any) => {
return n
.toExponential()
@@ -18,6 +18,7 @@ categorical annotations to be writable.
*/
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'schema' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function isCategoricalAnnotation(schema, name) {
/*
we treat any string, categorical or boolean as a categorical.
@@ -30,6 +31,7 @@ export function isCategoricalAnnotation(schema, name) {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'schema' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function isContinuousAnnotation(schema, name) {
/*
Return true/false/undefined
@@ -46,11 +48,13 @@ function _isUserAnnotation(schema, name) {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'annoMatrix' implicitly has an 'any' typ... Remove this comment to see the full error message
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function isUserAnnotation(annoMatrix, name) {
return _isUserAnnotation(annoMatrix.schema, name);
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'df' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function allHaveLabelByMask(df, colName, label, mask) {
// return true if all rows as indicated by mask have the colname set to label.
// False if not.
@@ -69,6 +73,7 @@ export function allHaveLabelByMask(df, colName, label, mask) {
const legalCharacters = /^(\w|[ .()-])+$/;
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function annotationNameIsErroneous(name) {
/*
Validate the name - return:
@@ -12,10 +12,15 @@ import { range } from "../range";
given a color mode & accessor, generate an annoMatrix query that will
fulfill it
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function createColorQuery(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
colorMode: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
colorByAccessor: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
schema: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
genesets: any
) {
if (!colorMode || !colorByAccessor || !schema || !genesets) return null;
@@ -66,6 +71,7 @@ export function createColorQuery(
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _defaultColors(nObs: any) {
const defaultCellColor = parseRGB(globals.defaultCellColor);
return {
@@ -89,9 +95,13 @@ Returns:
}
*/
function _createColorTable(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
colorMode: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
colorByAccessor: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
colorByData: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema: any,
userColors = null
) {
@@ -132,6 +142,7 @@ export const createColorTable = memoize(_createColorTable);
* - scale: function which given label returns d3 color scale for label
* Order doesn't matter - everything is keyed by label value.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function loadUserColorConfig(userColors: any) {
const convertedUserColors = {};
Object.keys(userColors).forEach((category) => {
@@ -147,6 +158,7 @@ export function loadUserColorConfig(userColors: any) {
[{}, {}]
);
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const scale = (label: any) => scaleMap[label];
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
convertedUserColors[category] = { colors, scale };
@@ -155,9 +167,13 @@ export function loadUserColorConfig(userColors: any) {
}
function _createUserColors(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
data: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
colorAccessor: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
userColors: any
) {
const { colors, scale: scaleByLabel } = userColors[colorAccessor];
@@ -167,7 +183,9 @@ function _createUserColors(
// See createColorsByCategoricalMetadata() for another example.
const { categories } = schema.annotations.obsByName[colorAccessor];
const categoryMap = new Map();
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
categories.forEach((label: any, idx: any) => categoryMap.set(idx, label));
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const scale = (idx: any) => scaleByLabel(categoryMap.get(idx));
return { rgb, scale };
@@ -175,8 +193,11 @@ function _createUserColors(
const createUserColors = memoize(_createUserColors);
function _createColorsByCategoricalMetadata(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
data: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
colorAccessor: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema: any
) {
const { categories } = schema.annotations.obsByName[colorAccessor];
@@ -186,6 +207,7 @@ function _createColorsByCategoricalMetadata(
.domain([0, categories.length]);
/* pre-create colors - much faster than doing it for each obs */
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const colors = categories.reduce((acc: any, cat: any, idx: any) => {
acc[cat] = parseRGB(scale(idx));
return acc;
@@ -198,6 +220,7 @@ const createColorsByCategoricalMetadata = memoize(
_createColorsByCategoricalMetadata
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function createRgbArray(data: any, colors: any) {
const rgb = new Array(data.length);
for (let i = 0, len = data.length; i < len; i += 1) {
@@ -207,6 +230,7 @@ function createRgbArray(data: any, colors: any) {
return rgb;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _createColorsByContinuousMetadata(data: any, min: any, max: any) {
const colorBins = 100;
const scale = d3
@@ -35,10 +35,12 @@ Remember that option values can be ANY js type, except undefined/null.
}
}
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function topNCategories(colSchema: any, summary: any, N: any) {
/* return top N categories by occurrences in the data */
const { categories: allCategories } = colSchema;
const counts = allCategories.map(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(cat: any) => summary.categoryCounts.get(cat) ?? 0
);
@@ -47,6 +49,7 @@ function topNCategories(colSchema: any, summary: any, N: any) {
}
const sortIndex = fillRange(new Array(allCategories.length)).sort(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(a: any, b: any) => counts[b] - counts[a]
);
const topNindices = new Set(sortIndex.slice(0, N));
@@ -62,6 +65,7 @@ function topNCategories(colSchema: any, summary: any, N: any) {
return [allCategories, _topNCategories, topNCounts];
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function isSelectableCategoryName(schema: any, name: any) {
const { index } = schema.annotations.obs;
const colSchema = schema.annotations.obsByName[name];
@@ -72,6 +76,7 @@ export function isSelectableCategoryName(schema: any, name: any) {
);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function selectableCategoryNames(schema: any, names: any) {
/*
return all obs annotation names that are categorical AND have a
@@ -80,10 +85,13 @@ export function selectableCategoryNames(schema: any, names: any) {
If the initial name list not provided, use everything in the schema.
*/
if (!schema) return [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
if (!names) names = schema.annotations.obs.columns.map((c: any) => c.name);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return names.filter((name: any) => isSelectableCategoryName(schema, name));
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function createCategorySummaryFromDfCol(dfCol: any, colSchema: any) {
const N = globals.maxCategoricalOptionsToDisplay;
const { writable: isUserAnno } = colSchema;
@@ -100,6 +108,7 @@ export function createCategorySummaryFromDfCol(dfCol: any, colSchema: any) {
categoryValueCounts,
] = topNCategories(colSchema, summary, N);
const categoryValueIndices = new Map(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
categoryValues.map((v: any, i: any) => [v, i])
);
const numCategoryValues = categoryValueIndices.size;
@@ -116,10 +125,13 @@ export function createCategorySummaryFromDfCol(dfCol: any, colSchema: any) {
};
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function createCategoricalSelection(names: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return fromEntries(names.map((name: any) => [name, new Map()]));
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function pruneVarDataCache(varData: any, needed: any) {
/*
Remove any unneeded columns from the varData dataframe. Will only
+18 -2
View File
@@ -17,12 +17,14 @@ Matrix flatbuffer decoding support. See fbs/matrix.fbs
/*
Decode NetEncoding.TypedArray
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function decodeTypedArray(uType: any, uValF: any, inplace = false) {
if (uType === NetEncoding.TypedArray.NONE) {
return null;
}
// Convert to a JS class that supports this type
// @ts-expect-error --- FIXME: Element implicitly has an 'any' type.
const TypeClass = NetEncoding[NetEncoding.TypedArray[uType]];
// Create a TypedArray that references the underlying buffer
let arr = uValF(new TypeClass()).dataArray();
@@ -48,6 +50,7 @@ Returns: object containing decoded Matrix:
colIdx: []|null
}
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function decodeMatrixFBS(arrayBuffer: any, inplace = false) {
const bb = new flatbuffers.ByteBuffer(new Uint8Array(arrayBuffer));
const matrix = NetEncoding.Matrix.getRootAsMatrix(bb);
@@ -79,8 +82,11 @@ export function decodeMatrixFBS(arrayBuffer: any, inplace = false) {
};
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function encodeTypedArray(builder: any, uType: any, uData: any) {
// @ts-expect-error --- FIXME: Element implicitly has an 'any' type.
const uTypeName = NetEncoding.TypedArray[uType];
// @ts-expect-error --- FIXME: Element implicitly has an 'any' type.
const ArrayType = NetEncoding[uTypeName];
const dv = ArrayType.createDataVector(builder, uData);
builder.startObject(1);
@@ -88,6 +94,7 @@ function encodeTypedArray(builder: any, uType: any, uData: any) {
return builder.endObject();
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function encodeMatrixFBS(df: any) {
/*
encode the dataframe as an FBS Matrix
@@ -108,12 +115,15 @@ export function encodeMatrixFBS(df: any) {
let encColumns;
if (shape[0] > 0 && shape[1] > 0) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const columns = df.columns().map((col: any) => col.asArray());
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const cols = columns.map((carr: any) => {
let uType;
let tarr;
if (isTypedArray(carr)) {
// @ts-expect-error --- FIXME: Element implicitly has an 'any' type.
uType = NetEncoding.TypedArray[carr.constructor.name];
tarr = encodeTypedArray(builder, uType, carr);
} else {
@@ -169,6 +179,7 @@ export function encodeMatrixFBS(df: any) {
return builder.asUint8Array();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function promoteTypedArray(o: any) {
/*
Decide what internal data type to use for the data returned from
@@ -201,6 +212,7 @@ function promoteTypedArray(o: any) {
return new TypedArrayCtor(o);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function matrixFBSToDataframe(arrayBuffers: any) {
/*
Convert array of Matrix FBS to a Dataframe.
@@ -217,18 +229,22 @@ export function matrixFBSToDataframe(arrayBuffers: any) {
arrayBuffers = [arrayBuffers];
}
if (arrayBuffers.length === 0) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
return (Dataframe as any).Dataframe.empty();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const fbs = arrayBuffers.map((ab: any) => decodeMatrixFBS(ab, true)); // leave in place
/* check that all FBS have same row dimensionality */
const { nRows } = fbs[0];
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
fbs.forEach((b: any) => {
if (b.nRows !== nRows)
throw new Error("FBS with inconsistent dimensionality");
});
const columns = fbs
const columns = fbs // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
.map((fb: any) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
fb.columns.map((c: any) => {
if (isFpTypedArray(c) || Array.isArray(c)) return c;
return promoteTypedArray(c);
@@ -236,7 +252,7 @@ export function matrixFBSToDataframe(arrayBuffers: any) {
)
.flat();
// colIdx may be TypedArray or Array
const colIdx = fbs
const colIdx = fbs // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
.map((b: any) =>
Array.isArray(b.colIdx) ? b.colIdx : Array.from(b.colIdx)
)
@@ -15,24 +15,30 @@ System wide schema assumptions:
- schema will be internally self-consistent (eg, index matches columns)
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function indexEntireSchema(schema: any) {
/* Index schema for ease of use */
schema.annotations.obsByName = fromEntries(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema.annotations?.obs?.columns?.map((v: any) => [v.name, v]) ?? []
);
schema.annotations.varByName = fromEntries(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema.annotations?.var?.columns?.map((v: any) => [v.name, v]) ?? []
);
schema.layout.obsByName = fromEntries(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema.layout?.obs?.map((v: any) => [v.name, v]) ?? []
);
schema.layout.varByName = fromEntries(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema.layout?.var?.map((v: any) => [v.name, v]) ?? []
);
return schema;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _copyObsAnno(schema: any) {
/* redux copy conventions - WARNING, only for modifying obs annotations */
return {
@@ -44,6 +50,7 @@ function _copyObsAnno(schema: any) {
};
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _copyObsLayout(schema: any) {
return {
...schema,
@@ -54,36 +61,44 @@ function _copyObsLayout(schema: any) {
};
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _reindexObsAnno(schema: any) {
/* reindex obs annotations ONLY */
schema.annotations.obsByName = fromEntries(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema.annotations.obs.columns.map((v: any) => [v.name, v])
);
return schema;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function _reindexObsLayout(schema: any) {
schema.layout.obsByName = fromEntries(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
schema.layout.obs.map((v: any) => [v.name, v])
);
return schema;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function removeObsAnnoColumn(schema: any, name: any) {
const newSchema = _copyObsAnno(schema);
newSchema.annotations.obs.columns = schema.annotations.obs.columns.filter(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(v: any) => v.name !== name
);
return _reindexObsAnno(newSchema);
}
// @ts-expect-error ts-migrate(6133) FIXME: 'name' is declared but its value is never read.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function addObsAnnoColumn(schema: any, name: any, defn: any) {
const newSchema = _copyObsAnno(schema);
newSchema.annotations.obs.columns.push(defn);
return _reindexObsAnno(newSchema);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function removeObsAnnoCategory(schema: any, name: any, category: any) {
/* remove a category from a categorical annotation */
const categories = schema.annotations.obsByName[name]?.categories;
@@ -100,6 +115,7 @@ export function removeObsAnnoCategory(schema: any, name: any, category: any) {
return newSchema;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function addObsAnnoCategory(schema: any, name: any, category: any) {
/* add a category to a categorical annotation */
const categories = schema.annotations.obsByName[name]?.categories;
@@ -120,6 +136,7 @@ export function addObsAnnoCategory(schema: any, name: any, category: any) {
return newSchema;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function addObsLayout(schema: any, layout: any) {
/* add or replace a layout */
const newSchema = _copyObsLayout(schema);
@@ -127,9 +144,11 @@ export function addObsLayout(schema: any, layout: any) {
return _reindexObsLayout(newSchema);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function removeObsLayout(schema: any, name: any) {
/* remove a layout */
const newSchema = _copyObsLayout(schema);
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
newSchema.layout.obs = schema.layout.obs.filter((v: any) => v.name !== name);
return _reindexObsLayout(newSchema);
}
@@ -39,6 +39,7 @@ import { clip, isubsetMask, isubset } from "../../annoMatrix";
import { memoize } from "../dataframe/util";
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'annoMatrix' implicitly has an 'any' typ... Remove this comment to see the full error message
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function _clipAnnoMatrix(annoMatrix, min, max) {
/*
clip the annoMatrix.
@@ -49,6 +50,7 @@ export function _clipAnnoMatrix(annoMatrix, min, max) {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'annoMatrix' implicitly has an 'any' typ... Remove this comment to see the full error message
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function _userSubsetAnnoMatrix(annoMatrix, mask) {
/*
user-requested row subset of annoMatrix, to be added on top of any
@@ -71,6 +73,7 @@ export function _userSubsetAnnoMatrix(annoMatrix, mask) {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'annoMatrix' implicitly has an 'any' typ... Remove this comment to see the full error message
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function _userResetSubsetAnnoMatrix(annoMatrix) {
/*
Reset/remove all user-requested subsets. Do not remove clip or embedding subset.
@@ -97,6 +100,7 @@ export function _userResetSubsetAnnoMatrix(annoMatrix) {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'annoMatrix' implicitly has an 'any' typ... Remove this comment to see the full error message
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function _setEmbeddingSubset(annoMatrix, embeddingDf) {
/*
Set the embedding subset view. Only create a subset view for the embedding
@@ -164,6 +168,7 @@ function _getEmbeddingRowOffsets(baseRowIndex, embeddingDf) {
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'embeddingDf' implicitly has an 'any' ty... Remove this comment to see the full error message
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function _getDiscreteCellEmbeddingRowIndex(embeddingDf) {
const idx = _getEmbeddingRowOffsets(embeddingDf.rowIndex, embeddingDf);
if (idx === null) return embeddingDf.rowIndex;
@@ -176,6 +181,7 @@ export const getDiscreteCellEmbeddingRowIndex = memoize(
);
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'annoMatrix' implicitly has an 'any' typ... Remove this comment to see the full error message
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function getEmbSubsetView(annoMatrix) {
/* if there is an embedding subset in the view stack, return it. Falsish if not. */
while (annoMatrix.isView) {
+11
View File
@@ -43,22 +43,29 @@ Example:
*/
export default class StateMachine {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
events: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
graph: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
onError: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
state: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
states: any;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(initState: any, transitions: any, onError: any) {
this.onError = onError || (() => undefined);
this.state = initState;
// all states
this.states = new Set(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
transitions.reduce((names: any, tsn: any) => {
names.push(tsn.from);
names.push(tsn.to);
@@ -67,10 +74,12 @@ export default class StateMachine {
);
// all transition names (aka events)
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.events = new Set(transitions.map((tsn: any) => tsn.event));
// the transition graph.
// graph[event][from] -> transition
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
this.graph = transitions.reduce((graph: any, tsn: any) => {
const { event, from } = tsn;
if (!graph.has(event)) graph.set(event, new Map());
@@ -80,6 +89,7 @@ export default class StateMachine {
}, new Map());
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
clone(initState: any) {
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
const fsm = new StateMachine(initState, []);
@@ -90,6 +100,7 @@ export default class StateMachine {
return fsm;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
next(event: any, data: any) {
const { graph, state } = this;
const tsnMap = graph.get(event);
+3
View File
@@ -5,6 +5,7 @@ Various type and schema related helper functions.
/*
Utility function to test for a typed array
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function isTypedArray(x: any) {
return (
ArrayBuffer.isView(x) &&
@@ -15,6 +16,7 @@ export function isTypedArray(x: any) {
/*
Test for float typed array, ie, Float32TypedArray or Float64TypedArray
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function isFpTypedArray(x: any) {
let constructor;
const isFloatArray =
@@ -24,6 +26,7 @@ export function isFpTypedArray(x: any) {
return isFloatArray;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function isArrayOrTypedArray(x: any) {
return Array.isArray(x) || isTypedArray(x);
}
@@ -17,16 +17,22 @@
// The underlying data structure uses TypedArrays for performance.
//
class BitArray {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
bitarray: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
bitmask: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
dimensionCount: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
length: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
width: any;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(length: any) {
// Initially allocate a 32 bit wide array. allocDimension() will expand
// as necessary.
@@ -50,12 +56,14 @@ class BitArray {
// Return the number of records that are selected, ie, have a one bit in
// all allocated dimensions.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
selectionCount() {
return this.countAllOnes();
}
// Count all records that have a 'one' bit in allocated dimensions.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
countAllOnes() {
let count = 0;
const { bitarray, length, width } = this;
@@ -86,6 +94,7 @@ class BitArray {
// count trailing zeros - hard to do fast in JS!
// https://en.wikipedia.org/wiki/Find_first_set#CTZ
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
static ctz(av: any) {
let c = 32;
let v = av;
@@ -100,6 +109,7 @@ class BitArray {
}
// find a free dimension. Return undefined if none
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
_findFreeDimension() {
let dim;
for (let col = 0; col < this.width; col += 1) {
@@ -115,6 +125,7 @@ class BitArray {
// allocate and return the dimension ID (bit position)
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
allocDimension() {
let dim = this._findFreeDimension();
@@ -140,6 +151,7 @@ class BitArray {
// free a dimension for later use. MUST deselect the dimension, as other
// code assume the column will be zero valued.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
freeDimension(dim: any) {
// all selection tests assume unallocated dimensions are zero valued.
this.deselectAll(dim);
@@ -150,6 +162,7 @@ class BitArray {
// return true if this index is selected in ALL dimensions.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isSelected(index: any) {
const { width, length, bitarray } = this;
@@ -162,6 +175,7 @@ class BitArray {
// return true if this index is selected in ALL dimensions IGNORING dim
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isSelectedIgnoringDim(index: any, dim: any) {
const ignoreOffset = dim >>> 5;
const ignoreMask = ~(1 << dim % 32);
@@ -186,6 +200,7 @@ class BitArray {
// select index on dimension
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectOne(dim: any, index: any) {
const col = dim >>> 5;
const before = this.bitarray[col * this.length + index];
@@ -195,6 +210,7 @@ class BitArray {
// deselect index on dimension
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
deselectOne(dim: any, index: any) {
const col = dim >>> 5;
const before = this.bitarray[col * this.length + index];
@@ -204,6 +220,7 @@ class BitArray {
// select all indices on dimension.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectAll(dim: any) {
const col = dim >> 5;
const one = 1 << dim % 32;
@@ -214,6 +231,7 @@ class BitArray {
// deselect all indices on dimension
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
deselectAll(dim: any) {
const col = dim >> 5;
const zero = ~(1 << dim % 32);
@@ -224,6 +242,7 @@ class BitArray {
// select range of indices on a dimension
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectFromRange(dim: any, range: any) {
const col = dim >>> 5;
const first = range[0];
@@ -238,6 +257,7 @@ class BitArray {
// select range of indices on a dimension, indirect through a sort map.
// Indirect functions are used to map between sort and natural order.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectIndirectFromRange(dim: any, indirect: any, range: any) {
const col = dim >>> 5;
const first = range[0];
@@ -251,6 +271,7 @@ class BitArray {
// deselect range of indices on a dimension
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
deselectFromRange(dim: any, range: any) {
const col = dim >>> 5;
const first = range[0];
@@ -264,6 +285,7 @@ class BitArray {
// deselect range of indices on a dimension, indirect through a sort map.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
deselectIndirectFromRange(dim: any, indirect: any, range: any) {
const col = dim >>> 5;
const first = range[0];
@@ -278,6 +300,7 @@ class BitArray {
// Fill the array with selected|deselected value based upon the
// current selection state.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
fillBySelection(result: any, selectedValue: any, deselectedValue: any) {
// special case (width === 1) for performance
if (this.width === 1) {
@@ -11,6 +11,7 @@ import {
import { makeSortIndex } from "./util";
class NotImplementedError extends Error {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
constructor(...params: any[]) {
super(...params);
@@ -22,12 +23,16 @@ class NotImplementedError extends Error {
}
export default class ImmutableTypedCrossfilter {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
data: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
dimensions: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
selectionCache: any;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(data: any, dimensions = {}, selectionCache = {}) {
/*
Typically, parameter 'data' is one of:
@@ -57,14 +62,17 @@ export default class ImmutableTypedCrossfilter {
Object.preventExtensions(this);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
size() {
return this.data.length;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
all() {
return this.data;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
setData(data: any) {
if (this.data === data) return this;
// please leave, WIP
@@ -72,15 +80,18 @@ export default class ImmutableTypedCrossfilter {
return new ImmutableTypedCrossfilter(data, this.dimensions);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
dimensionNames() {
/* return array of all dimensions (by name) */
return Object.keys(this.dimensions);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
hasDimension(name: any) {
return !!this.dimensions[name];
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
addDimension(name: any, type: any, ...rest: any[]) {
/*
Add a new dimension to this crossfilter, of type DimensionType.
@@ -119,6 +130,7 @@ export default class ImmutableTypedCrossfilter {
});
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
delDimension(name: any) {
const { data } = this;
const { bitArray } = this.selectionCache;
@@ -139,6 +151,7 @@ export default class ImmutableTypedCrossfilter {
});
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
renameDimension(oldName: any, newName: any) {
const { [oldName]: dim, ...dimensions } = this.dimensions;
const { data, selectionCache } = this;
@@ -153,6 +166,7 @@ export default class ImmutableTypedCrossfilter {
return new ImmutableTypedCrossfilter(data, newDimensions, selectionCache);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
select(name: any, spec: any) {
/*
select on named dimension, as indicated by `spec`. Spec is an object
@@ -181,10 +195,15 @@ export default class ImmutableTypedCrossfilter {
return new ImmutableTypedCrossfilter(data, dimensions, newSelectionCache);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
static _dimSelnHasUpdated(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectionCache: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
id: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
newSeln: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
oldSeln: any
) {
/*
@@ -220,24 +239,29 @@ export default class ImmutableTypedCrossfilter {
If sort index exists in the dimension, assume sort ordered ranges.
*/
if (oldSeln.index) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
dels.forEach((interval: any) =>
bitArray.deselectIndirectFromRange(id, oldSeln.index, interval)
);
} else {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
dels.forEach((interval: any) => bitArray.deselectFromRange(id, interval));
}
if (newSeln.index) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
adds.forEach((interval: any) =>
bitArray.selectIndirectFromRange(id, newSeln.index, interval)
);
} else {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
adds.forEach((interval: any) => bitArray.selectFromRange(id, interval));
}
return { bitArray };
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
_getSelectionCache() {
if (!this.selectionCache) this.selectionCache = {};
@@ -249,6 +273,7 @@ export default class ImmutableTypedCrossfilter {
const id = bitArray.allocDimension();
this.dimensions[name].id = id;
const { ranges, index } = selection;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
ranges.forEach((range: any) => {
if (index) {
bitArray.selectIndirectFromRange(id, index, range);
@@ -262,16 +287,19 @@ export default class ImmutableTypedCrossfilter {
return this.selectionCache;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
_clearSelectionCache() {
this.selectionCache = {};
return this.selectionCache;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
_setSelectionCache(vals = {}) {
Object.assign(this.selectionCache, vals);
return this.selectionCache;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
allSelected() {
/*
return array of all records currently selected by all dimensions
@@ -292,6 +320,7 @@ export default class ImmutableTypedCrossfilter {
return data.isubsetMask(this.allSelectedMask());
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
allSelectedMask() {
/*
return Uint8Array containing selection state (truthy/falsey) for each record.
@@ -310,6 +339,7 @@ export default class ImmutableTypedCrossfilter {
return allSelectedMask;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
countSelected() {
/*
return number of records selected on all dimensions
@@ -324,6 +354,7 @@ export default class ImmutableTypedCrossfilter {
return countSelected;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
isElementSelected(i: any) {
/*
return truthy/falsey if this record is selected on all dimensions
@@ -332,6 +363,7 @@ export default class ImmutableTypedCrossfilter {
return selectionCache.bitArray.isSelected(i);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
fillByIsSelected(array: any, selectedValue: any, deselectedValue: any) {
/*
fill array with one of two values, based upon selection state.
@@ -357,8 +389,10 @@ for a dimension:
- name - the dimension name/label.
*/
class _ImmutableBaseDimension {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
name: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
constructor(name: any) {
this.name = name;
}
@@ -367,12 +401,14 @@ class _ImmutableBaseDimension {
return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
rename(name: any) {
const d = this.clone();
d.name = name;
return d;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
select(spec: any) {
const { mode } = spec;
if (mode === undefined) {
@@ -385,10 +421,13 @@ class _ImmutableBaseDimension {
}
class ImmutableScalarDimension extends _ImmutableBaseDimension {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
index: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
value: any;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(name: any, data: any, value: any, ValueArrayType: any) {
super(name);
@@ -416,6 +455,7 @@ class ImmutableScalarDimension extends _ImmutableBaseDimension {
// only by enumerated dimensions
array = this._createValueArray(
data,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
(i: any) => value[i],
new ValueArrayType(data.length)
);
@@ -430,7 +470,7 @@ class ImmutableScalarDimension extends _ImmutableBaseDimension {
this.index = makeSortIndex(array);
}
// eslint-disable-next-line class-methods-use-this -- needed for polymorphism
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- needed for polymorphism
_createValueArray(data: any, mapf: any, array: any) {
// create dimension value array
const len = data.length;
@@ -441,6 +481,7 @@ class ImmutableScalarDimension extends _ImmutableBaseDimension {
return larray;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
select(spec: any) {
const { mode } = spec;
const { index } = this;
@@ -458,6 +499,7 @@ class ImmutableScalarDimension extends _ImmutableBaseDimension {
}
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectExact(spec: any) {
const { value, index } = this;
let { values } = spec;
@@ -477,6 +519,7 @@ class ImmutableScalarDimension extends _ImmutableBaseDimension {
return { ranges, index };
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectRange(spec: any) {
const { value, index } = this;
/*
@@ -496,10 +539,12 @@ class ImmutableScalarDimension extends _ImmutableBaseDimension {
}
class ImmutableEnumDimension extends ImmutableScalarDimension {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(name: any, data: any, value: any) {
super(name, data, value, Uint32Array);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
_createValueArray(data: any, mapf: any, array: any) {
const len = data.length;
const larray = array;
@@ -524,6 +569,7 @@ class ImmutableEnumDimension extends ImmutableScalarDimension {
return larray;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectExact(spec: any) {
// @ts-expect-error FIXME Adding enumIndex as member variable results in "undefined" enumIndex value
const { enumIndex } = this;
@@ -533,6 +579,7 @@ class ImmutableEnumDimension extends ImmutableScalarDimension {
}
return super.selectExact({
mode: spec.mode,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
values: values.map((v: any) =>
binarySearch(enumIndex, v, 0, enumIndex.length)
),
@@ -540,21 +587,26 @@ class ImmutableEnumDimension extends ImmutableScalarDimension {
}
// @ts-expect-error ts-migrate(2416) FIXME: Property 'selectRange' in type 'ImmutableEnumDimen... Remove this comment to see the full error message
// eslint-disable-next-line class-methods-use-this -- enables polymorphism
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/explicit-module-boundary-types -- enables polymorphism
selectRange() {
throw new Error("range selection unsupported on Enumerated dimension");
}
}
class ImmutableSpatialDimension extends _ImmutableBaseDimension {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
X: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
Xindex: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
Y: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
Yindex: any;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
constructor(name: any, data: any, X: any, Y: any) {
super(name);
@@ -570,6 +622,7 @@ class ImmutableSpatialDimension extends _ImmutableBaseDimension {
this.Yindex = makeSortIndex(Y);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
select(spec: any) {
const { mode } = spec;
switch (mode) {
@@ -586,6 +639,7 @@ class ImmutableSpatialDimension extends _ImmutableBaseDimension {
}
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectWithinRect(spec: any) {
/*
{ mode: "within-rect", minX: 1, minY: 0, maxX: 3, maxY: 9 }
@@ -619,6 +673,7 @@ class ImmutableSpatialDimension extends _ImmutableBaseDimension {
* then the polygon test is applied
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
selectWithinPolygon(spec: any) {
/*
{ mode: "within-polygon", polygon: [ [x0, y0], ... ] }
@@ -674,6 +729,7 @@ export const DimTypes = {
spatial: ImmutableSpatialDimension,
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function isArrayOrTypedArray(x: any) {
return (
Array.isArray(x) ||
@@ -683,6 +739,7 @@ function isArrayOrTypedArray(x: any) {
}
/* return bounding box of the polygon */
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function polygonBoundingBox(polygon: any) {
let minX = Number.MAX_VALUE;
let minY = Number.MAX_VALUE;
@@ -707,6 +764,7 @@ function polygonBoundingBox(polygon: any) {
* @param {float} y - point y coordinate
* @type {boolean}
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function withinPolygon(polygon: any, x: any, y: any) {
const n = polygon.length;
let p = polygon[n - 1];
@@ -16,9 +16,11 @@ class PositiveIntervals {
// 1. no overlapping intervals
// 2. sorted in order of interval min.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
static canonicalize(A: any) {
if (A.length <= 1) return A;
const copy = A.slice();
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
copy.sort((a: any, b: any) => a[0] - b[0]);
const res = [];
res.push(copy[0]);
@@ -38,10 +40,12 @@ class PositiveIntervals {
// Return interval with values belonging to both A and B. Essentially
// a set union operation.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
static union(A: any, B: any) {
return PositiveIntervals.canonicalize([...A, ...B]);
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
static _flatten(A: any, B: any) {
const points = []; /* point, A, start */
for (let a = 0; a < A.length; a += 1) {
@@ -60,6 +64,7 @@ class PositiveIntervals {
// A - B, ie, the interval with all values in A that are not in B. Essentially
// a set difference operation.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
static difference(A: any, B: any) {
// Corner cases
if (A.length === 0 || B.length === 0) {
@@ -96,6 +101,7 @@ class PositiveIntervals {
// Return interval with values belonging to A or B. Essentially a set
// intersection.
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
static intersection(A: any, B: any) {
if (A.length === 0 || B.length === 0) {
return [];
+61
View File
@@ -10,11 +10,13 @@ import { isTypedArray, isFpTypedArray } from "../typeHelpers";
/*
Comparators for float sort. -Infinity < finite < Infinity < NaN
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function lt(a: any, b: any) {
if (Number.isNaN(b)) return !Number.isNaN(a);
return a < b;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function gt(a: any, b: any) {
if (Number.isNaN(a)) return !Number.isNaN(b);
return a > b;
@@ -24,6 +26,7 @@ function gt(a: any, b: any) {
insertion sort, used for small arrays (controlled by SMALL_ARRAY constant)
*/
const SMALL_ARRAY = 32;
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function insertionsort(a: any, lo: any, hi: any) {
for (let i = lo + 1; i < hi + 1; i += 1) {
const x = a[i];
@@ -36,6 +39,7 @@ function insertionsort(a: any, lo: any, hi: any) {
return a;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function insertionsortFloats(a: any, lo: any, hi: any) {
for (let i = lo + 1; i < hi + 1; i += 1) {
const x = a[i];
@@ -48,6 +52,7 @@ function insertionsortFloats(a: any, lo: any, hi: any) {
return a;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function insertionsortIndirect(a: any, s: any, lo: any, hi: any) {
for (let i = lo + 1; i < hi + 1; i += 1) {
const x = a[i];
@@ -61,6 +66,7 @@ function insertionsortIndirect(a: any, s: any, lo: any, hi: any) {
return a;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function insertionsortFloatsIndirect(a: any, s: any, lo: any, hi: any) {
for (let i = lo + 1; i < hi + 1; i += 1) {
const x = a[i];
@@ -77,6 +83,7 @@ function insertionsortFloatsIndirect(a: any, s: any, lo: any, hi: any) {
/*
Quicksort - used for larger arrays
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function quicksort(a: any, lo: any, hi: any) {
if (hi - lo < SMALL_ARRAY) {
return insertionsort(a, lo, hi);
@@ -107,6 +114,7 @@ function quicksort(a: any, lo: any, hi: any) {
return a;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function quicksortFloats(a: any, lo: any, hi: any) {
if (hi - lo < SMALL_ARRAY) {
return insertionsortFloats(a, lo, hi);
@@ -137,6 +145,7 @@ function quicksortFloats(a: any, lo: any, hi: any) {
return a;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function quicksortIndirect(a: any, s: any, lo: any, hi: any) {
if (hi - lo < SMALL_ARRAY) {
return insertionsortIndirect(a, s, lo, hi);
@@ -168,6 +177,7 @@ function quicksortIndirect(a: any, s: any, lo: any, hi: any) {
return a;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function quicksortFloatsIndirect(a: any, s: any, lo: any, hi: any) {
if (hi - lo < SMALL_ARRAY) {
return insertionsortFloatsIndirect(a, s, lo, hi);
@@ -203,6 +213,7 @@ function quicksortFloatsIndirect(a: any, s: any, lo: any, hi: any) {
Convenience wrappers, handling optimization paths and default
handlers for NaN comparisons. Sorts in place.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function sortArray(arr: any) {
if (Array.isArray(arr)) {
return quicksort(arr, 0, arr.length - 1);
@@ -217,6 +228,7 @@ export function sortArray(arr: any) {
throw new Error("sortArray received unsupported object type");
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function sortIndex(index: any, source: any) {
if (isFpTypedArray(source))
return quicksortFloatsIndirect(index, source, 0, index.length - 1);
@@ -235,9 +247,13 @@ export function sortIndex(index: any, source: any) {
// Python: bisect.bisect_left()
//
function lowerBoundNonFloat(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
last: any
) {
let lfirst = first;
@@ -259,6 +275,7 @@ function lowerBoundNonFloat(
// If the underlying array is a Float32Array or Float64Array, will enforce
// the ordering -Infinity < finite < Infinity < NaN.
//
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function lowerBoundFloat(valueArray: any, value: any, first: any, last: any) {
let lfirst = first;
let llast = last;
@@ -274,6 +291,7 @@ function lowerBoundFloat(valueArray: any, value: any, first: any, last: any) {
return lfirst;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function lowerBound(valueArray: any, value: any, first: any, last: any) {
if (isFpTypedArray(valueArray)) {
return lowerBoundFloat(valueArray, value, first, last);
@@ -284,10 +302,15 @@ export function lowerBound(valueArray: any, value: any, first: any, last: any) {
// Inlined performance optimization - used to indirect through a sort map.
//
function lowerBoundNonFloatIndirect(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
indexArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
last: any
) {
let lfirst = first;
@@ -305,10 +328,15 @@ function lowerBoundNonFloatIndirect(
}
function lowerBoundFloatIndirect(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
indexArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
last: any
) {
let lfirst = first;
@@ -325,11 +353,17 @@ function lowerBoundFloatIndirect(
return lfirst;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function lowerBoundIndirect(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
indexArray: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
last: any
) {
if (isFpTypedArray(valueArray)) {
@@ -350,9 +384,13 @@ export function lowerBoundIndirect(
// Python: bisect.bisect_right()
//
function upperBoundNonFloat(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
last: any
) {
let lfirst = first;
@@ -369,6 +407,7 @@ function upperBoundNonFloat(
return lfirst;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
function upperBoundFloat(valueArray: any, value: any, first: any, last: any) {
let lfirst = first;
let llast = last;
@@ -384,6 +423,7 @@ function upperBoundFloat(valueArray: any, value: any, first: any, last: any) {
return lfirst;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function upperBound(valueArray: any, value: any, first: any, last: any) {
if (isFpTypedArray(valueArray)) {
return upperBoundFloat(valueArray, value, first, last);
@@ -394,10 +434,15 @@ export function upperBound(valueArray: any, value: any, first: any, last: any) {
// Inline performance optimization
//
function upperBoundNonFloatIndirect(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
indexArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
last: any
) {
let lfirst = first;
@@ -415,10 +460,15 @@ function upperBoundNonFloatIndirect(
}
function upperBoundFloatIndirect(
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
indexArray: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
last: any
) {
let lfirst = first;
@@ -435,11 +485,17 @@ function upperBoundFloatIndirect(
return lfirst;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function upperBoundIndirect(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
indexArray: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
last: any
) {
if (isFpTypedArray(valueArray)) {
@@ -455,10 +511,15 @@ export function upperBoundIndirect(
// The same semantics/behavior as:
// C++: binary_search()
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
export function binarySearch(
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
valueArray: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
value: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
first: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
last: any
) {
const index = lowerBound(valueArray, value, first, last);
+2
View File
@@ -7,6 +7,7 @@ import { rangeFill as fillRange } from "../range";
// slice out of one array into another, using an index array
//
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function sliceByIndex(src: any, index: any) {
if (index === undefined || index === null) {
return src;
@@ -18,6 +19,7 @@ export function sliceByIndex(src: any, index: any) {
return dst;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
export function makeSortIndex(src: any) {
const index = fillRange(new Uint32Array(src.length));
sortIndex(index, src);