mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-09 06:28:13 +08:00
type quantile
This commit is contained in:
@@ -14,15 +14,25 @@ Arguments:
|
|||||||
|
|
||||||
import { sortArray } from "./typedCrossfilter/sort";
|
import { sortArray } from "./typedCrossfilter/sort";
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'quantArr' implicitly has an 'any' type.
|
export default function quantile(
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
quantArr: Array<number>,
|
||||||
export default function quantile(quantArr, tarr, sorted = false) {
|
tarr:
|
||||||
|
| Int8Array
|
||||||
|
| Uint8Array
|
||||||
|
| Int16Array
|
||||||
|
| Uint16Array
|
||||||
|
| Int32Array
|
||||||
|
| Uint32Array
|
||||||
|
| Uint8ClampedArray
|
||||||
|
| Float32Array
|
||||||
|
| Float64Array,
|
||||||
|
sorted = false
|
||||||
|
): Array<unknown> {
|
||||||
/*
|
/*
|
||||||
start with the naive (sort) implementation. Later, use a faster partition
|
start with the naive (sort) implementation. Later, use a faster partition
|
||||||
*/
|
*/
|
||||||
const arr = sorted ? tarr : sortArray(new tarr.constructor(tarr)); // copy
|
const arr = sorted ? tarr : sortArray(tarr.constructor(tarr)); // copy
|
||||||
const len = arr.length;
|
const len = arr.length;
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'q' implicitly has an 'any' type.
|
|
||||||
return quantArr.map((q) => {
|
return quantArr.map((q) => {
|
||||||
if (q === 1) {
|
if (q === 1) {
|
||||||
return arr[len - 1];
|
return arr[len - 1];
|
||||||
|
|||||||
Reference in New Issue
Block a user