add array type foundations (#2376)

This commit is contained in:
Bruce Martin
2021-08-12 07:17:05 -07:00
committed by GitHub
parent 59c475b821
commit 660dff256c
9 changed files with 103 additions and 65 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
import { flatbuffers } from "flatbuffers";
import { NetEncoding } from "./matrix_generated";
import { isTypedArray, isFpTypedArray } from "../typeHelpers";
import { isTypedArray, isFloatTypedArray } from "../../common/types/arraytypes";
import {
Dataframe,
IdentityInt32Index,
@@ -188,7 +188,7 @@ function promoteTypedArray(o: any) {
TODO - future optimization: not all int32/uint32 data series require
promotion to float64. We COULD simply look at the data to decide.
*/
if (isFpTypedArray(o) || Array.isArray(o)) return o;
if (isFloatTypedArray(o) || Array.isArray(o)) return o;
let TypedArrayCtor;
switch (o.constructor) {
@@ -246,7 +246,7 @@ export function matrixFBSToDataframe(arrayBuffers: any) {
.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;
if (isFloatTypedArray(c) || Array.isArray(c)) return c;
return promoteTypedArray(c);
})
)