Convert float annotations if possible. (#1987)

* Convert float annotations if possible.

The client converts all arrays to floats.
If a category contains integer labels, and that category is copied, it will contains floats (e.g 1.0 instead of 1).
When that category is put back to the server, it fails in the tiledb code, which does not accept floats.
The solution is to convert a float category to integer, if possible.

  #1984

* updates
This commit is contained in:
bmccandless
2020-11-20 17:01:53 -06:00
committed by GitHub
parent f77038ad58
commit 2cc02a84cb
4 changed files with 52 additions and 6 deletions
+5 -5
View File
@@ -178,26 +178,26 @@ function promoteTypedArray(o) {
*/
if (isFpTypedArray(o) || Array.isArray(o)) return o;
let TyepdArrayCtor;
let TypedArrayCtor;
switch (o.constructor) {
case Int8Array:
case Uint8Array:
case Uint8ClampedArray:
case Int16Array:
case Uint16Array:
TyepdArrayCtor = Float32Array;
TypedArrayCtor = Float32Array;
break;
case Int32Array:
case Uint32Array:
TyepdArrayCtor = Float64Array;
TypedArrayCtor = Float64Array;
break;
default:
throw new Error("Unexpected data type returned from server.");
}
if (o.constructor === TyepdArrayCtor) return o;
return new TyepdArrayCtor(o);
if (o.constructor === TypedArrayCtor) return o;
return new TypedArrayCtor(o);
}
export function matrixFBSToDataframe(arrayBuffers) {