mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-23 13:58:12 +08:00
run prettier(2.0.5) (#1438)
This commit is contained in:
@@ -21,171 +21,171 @@ categorical annotations to be writable.
|
||||
*/
|
||||
|
||||
export function isCategoricalAnnotation(schema, name) {
|
||||
/* we treat any string, categorical or boolean as a categorical */
|
||||
const { type } = schema.annotations.obsByName[name];
|
||||
return type === "string" || type === "boolean" || type === "categorical";
|
||||
/* we treat any string, categorical or boolean as a categorical */
|
||||
const { type } = schema.annotations.obsByName[name];
|
||||
return type === "string" || type === "boolean" || type === "categorical";
|
||||
}
|
||||
|
||||
export function isContinuousAnnotation(schema, name) {
|
||||
return !isCategoricalAnnotation(schema, name);
|
||||
return !isCategoricalAnnotation(schema, name);
|
||||
}
|
||||
|
||||
function _isUserAnnotation(schema, name) {
|
||||
return schema.annotations.obsByName[name]?.writable;
|
||||
return schema.annotations.obsByName[name]?.writable;
|
||||
}
|
||||
|
||||
export function isUserAnnotation(worldOrUniverse, name) {
|
||||
return _isUserAnnotation(worldOrUniverse.schema, name);
|
||||
return _isUserAnnotation(worldOrUniverse.schema, name);
|
||||
}
|
||||
|
||||
export function removeObsAnnoSchema(schema, name) {
|
||||
/*
|
||||
/*
|
||||
remove named annotation from obs annotation schema
|
||||
*/
|
||||
|
||||
/* only remove if it exists and is a user annotation */
|
||||
if (!_isUserAnnotation(schema, name))
|
||||
throw new Error("removing non-user-defined schema");
|
||||
return SchemaHelpers.removeObsAnnoColumn(schema, name);
|
||||
/* only remove if it exists and is a user annotation */
|
||||
if (!_isUserAnnotation(schema, name))
|
||||
throw new Error("removing non-user-defined schema");
|
||||
return SchemaHelpers.removeObsAnnoColumn(schema, name);
|
||||
}
|
||||
|
||||
export function addObsAnnoSchema(schema, name, colSchema) {
|
||||
/*
|
||||
/*
|
||||
add a categorical type to the obs annotation schema
|
||||
*/
|
||||
|
||||
/* collision detection */
|
||||
if (schema.annotations.obs.columns.some(v => v.name === name))
|
||||
throw Error("annotations may not contain duplicate category names");
|
||||
if (name !== colSchema.name) throw Error("column schema does not match");
|
||||
return SchemaHelpers.addObsAnnoColumn(schema, name, colSchema);
|
||||
/* collision detection */
|
||||
if (schema.annotations.obs.columns.some((v) => v.name === name))
|
||||
throw Error("annotations may not contain duplicate category names");
|
||||
if (name !== colSchema.name) throw Error("column schema does not match");
|
||||
return SchemaHelpers.addObsAnnoColumn(schema, name, colSchema);
|
||||
}
|
||||
|
||||
export function dupObsAnnoSchema(schema, sourceName, dupName, defaultSchema) {
|
||||
/*
|
||||
/*
|
||||
duplicate the obs annotation `sourceName` schema, but with the name `dupName`
|
||||
*/
|
||||
const colSchema = {
|
||||
...schema.annotations.obsByName[sourceName],
|
||||
...defaultSchema,
|
||||
name: dupName
|
||||
};
|
||||
/* existance check */
|
||||
if (!colSchema) throw Error("source annotation does not exist");
|
||||
/* collision detection */
|
||||
if (schema.annotations.obs.columns.some(v => v.name === dupName))
|
||||
throw Error("annotations may not contain duplicate category names");
|
||||
return SchemaHelpers.addObsAnnoColumn(schema, dupName, colSchema);
|
||||
const colSchema = {
|
||||
...schema.annotations.obsByName[sourceName],
|
||||
...defaultSchema,
|
||||
name: dupName,
|
||||
};
|
||||
/* existance check */
|
||||
if (!colSchema) throw Error("source annotation does not exist");
|
||||
/* collision detection */
|
||||
if (schema.annotations.obs.columns.some((v) => v.name === dupName))
|
||||
throw Error("annotations may not contain duplicate category names");
|
||||
return SchemaHelpers.addObsAnnoColumn(schema, dupName, colSchema);
|
||||
}
|
||||
|
||||
export function removeObsAnnoCategory(schema, name, category) {
|
||||
/* don't allow deletion of unassigned category on writable annotations */
|
||||
/* don't allow deletion of unassigned category on writable annotations */
|
||||
|
||||
if (!_isUserAnnotation(schema, name))
|
||||
throw new Error("unable to modify read-only schema");
|
||||
if (category === unassignedCategoryLabel)
|
||||
throw new Error("may not remove unassigned category label");
|
||||
if (!_isUserAnnotation(schema, name))
|
||||
throw new Error("unable to modify read-only schema");
|
||||
if (category === unassignedCategoryLabel)
|
||||
throw new Error("may not remove unassigned category label");
|
||||
|
||||
return SchemaHelpers.removeObsAnnoCategory(schema, name, category);
|
||||
return SchemaHelpers.removeObsAnnoCategory(schema, name, category);
|
||||
}
|
||||
|
||||
export function addObsAnnoCategory(schema, name, category) {
|
||||
if (!_isUserAnnotation(schema, name))
|
||||
throw new Error("unable to modify read-only schema");
|
||||
if (!_isUserAnnotation(schema, name))
|
||||
throw new Error("unable to modify read-only schema");
|
||||
|
||||
return SchemaHelpers.addObsAnnoCategory(schema, name, category);
|
||||
return SchemaHelpers.addObsAnnoCategory(schema, name, category);
|
||||
}
|
||||
|
||||
export function setLabelByValue(df, colName, fromLabel, toLabel) {
|
||||
/*
|
||||
/*
|
||||
in the dataframe column `colName`, set any value of `fromLabel` to `toLabel`
|
||||
*/
|
||||
const keys = df.colIndex.keys();
|
||||
const ndf = df.mapColumns((col, colIdx) => {
|
||||
if (colName !== keys[colIdx]) return col;
|
||||
const keys = df.colIndex.keys();
|
||||
const ndf = df.mapColumns((col, colIdx) => {
|
||||
if (colName !== keys[colIdx]) return col;
|
||||
|
||||
/* clone data and return it. */
|
||||
const newCol = col.slice();
|
||||
for (let i = 0, l = newCol.length; i < l; i += 1) {
|
||||
if (newCol[i] === fromLabel) newCol[i] = toLabel;
|
||||
}
|
||||
return newCol;
|
||||
});
|
||||
return ndf;
|
||||
/* clone data and return it. */
|
||||
const newCol = col.slice();
|
||||
for (let i = 0, l = newCol.length; i < l; i += 1) {
|
||||
if (newCol[i] === fromLabel) newCol[i] = toLabel;
|
||||
}
|
||||
return newCol;
|
||||
});
|
||||
return ndf;
|
||||
}
|
||||
|
||||
export function setLabelByMask(df, colName, mask, label) {
|
||||
/*
|
||||
/*
|
||||
in the dataframe column `colName`, set the masked rows to 'label'
|
||||
*/
|
||||
const keys = df.colIndex.keys();
|
||||
const ndf = df.mapColumns((col, colIdx) => {
|
||||
if (colName !== keys[colIdx]) return col;
|
||||
const keys = df.colIndex.keys();
|
||||
const ndf = df.mapColumns((col, colIdx) => {
|
||||
if (colName !== keys[colIdx]) return col;
|
||||
|
||||
/* clone data and return it. */
|
||||
const newCol = col.slice();
|
||||
for (let i = 0, l = newCol.length; i < l; i += 1) {
|
||||
if (mask[i]) newCol[i] = label;
|
||||
}
|
||||
return newCol;
|
||||
});
|
||||
return ndf;
|
||||
/* clone data and return it. */
|
||||
const newCol = col.slice();
|
||||
for (let i = 0, l = newCol.length; i < l; i += 1) {
|
||||
if (mask[i]) newCol[i] = label;
|
||||
}
|
||||
return newCol;
|
||||
});
|
||||
return ndf;
|
||||
}
|
||||
|
||||
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.
|
||||
const col = df.col(colName);
|
||||
if (!col) return false;
|
||||
if (df.length !== mask.length)
|
||||
throw new RangeError("mismatch on mask length");
|
||||
// return true if all rows as indicated by mask have the colname set to label.
|
||||
// False if not.
|
||||
const col = df.col(colName);
|
||||
if (!col) return false;
|
||||
if (df.length !== mask.length)
|
||||
throw new RangeError("mismatch on mask length");
|
||||
|
||||
for (let i = 0; i < df.length; i += 1) {
|
||||
if (mask[i]) {
|
||||
if (col.iget(i) !== label) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
for (let i = 0; i < df.length; i += 1) {
|
||||
if (mask[i]) {
|
||||
if (col.iget(i) !== label) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function worldToUniverseMask(worldMask, worldObsAnnotations, nObs) {
|
||||
/*
|
||||
/*
|
||||
given world seleciton mask, return a selection mask for entire universe
|
||||
that has same selection state.
|
||||
*/
|
||||
const mask = new Uint8Array(nObs);
|
||||
const { rowIndex } = worldObsAnnotations;
|
||||
const mask = new Uint8Array(nObs);
|
||||
const { rowIndex } = worldObsAnnotations;
|
||||
|
||||
for (let i = 0, l = worldMask.length; i < l; i += 1) {
|
||||
if (worldMask[i]) {
|
||||
const label = rowIndex.getLabel(i);
|
||||
mask[label] = 1;
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
for (let i = 0, l = worldMask.length; i < l; i += 1) {
|
||||
if (worldMask[i]) {
|
||||
const label = rowIndex.getLabel(i);
|
||||
mask[label] = 1;
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
export function createWritableAnnotationDimensions(world, crossfilter) {
|
||||
const { obsAnnotations, schema } = world;
|
||||
const writableAnnotations = schema.annotations.obs.columns
|
||||
.filter(s => s.writable)
|
||||
.map(s => s.name);
|
||||
const { obsAnnotations, schema } = world;
|
||||
const writableAnnotations = schema.annotations.obs.columns
|
||||
.filter((s) => s.writable)
|
||||
.map((s) => s.name);
|
||||
|
||||
crossfilter = writableAnnotations.reduce((xflt, anno) => {
|
||||
const dimName = obsAnnoDimensionName(anno);
|
||||
if (xflt.hasDimension(dimName)) xflt = xflt.delDimension(dimName);
|
||||
return xflt.addDimension(
|
||||
dimName,
|
||||
"enum",
|
||||
obsAnnotations.col(anno).asArray()
|
||||
);
|
||||
}, crossfilter);
|
||||
return crossfilter;
|
||||
crossfilter = writableAnnotations.reduce((xflt, anno) => {
|
||||
const dimName = obsAnnoDimensionName(anno);
|
||||
if (xflt.hasDimension(dimName)) xflt = xflt.delDimension(dimName);
|
||||
return xflt.addDimension(
|
||||
dimName,
|
||||
"enum",
|
||||
obsAnnotations.col(anno).asArray()
|
||||
);
|
||||
}, crossfilter);
|
||||
return crossfilter;
|
||||
}
|
||||
|
||||
const legalCharacters = /^(\w|[ .()-])+$/;
|
||||
export function annotationNameIsErroneous(name) {
|
||||
/*
|
||||
/*
|
||||
Validate the name - return:
|
||||
* false - a valid name
|
||||
* string - a named error, indicating why it was invalid.
|
||||
@@ -196,21 +196,21 @@ export function annotationNameIsErroneous(name) {
|
||||
2. only accept alpha, numeric, underscore, period, parens, hyphen and space
|
||||
3. no runs of multiple spaces
|
||||
*/
|
||||
if (name === "") {
|
||||
return "empty-string";
|
||||
}
|
||||
if (name[0] === " " || name[name.length - 1] === " ") {
|
||||
return "trim-spaces";
|
||||
}
|
||||
if (!legalCharacters.test(name)) {
|
||||
return "illegal-characters";
|
||||
}
|
||||
for (let i = 1, l = name.length; i < l; i += 1) {
|
||||
if (name[i] === " " && name[i - 1] === " ") {
|
||||
return "multi-space-run";
|
||||
}
|
||||
}
|
||||
if (name === "") {
|
||||
return "empty-string";
|
||||
}
|
||||
if (name[0] === " " || name[name.length - 1] === " ") {
|
||||
return "trim-spaces";
|
||||
}
|
||||
if (!legalCharacters.test(name)) {
|
||||
return "illegal-characters";
|
||||
}
|
||||
for (let i = 1, l = name.length; i < l; i += 1) {
|
||||
if (name[i] === " " && name[i - 1] === " ") {
|
||||
return "multi-space-run";
|
||||
}
|
||||
}
|
||||
|
||||
/* all is well! Indicte not erroneous with a false */
|
||||
return false;
|
||||
/* all is well! Indicte not erroneous with a false */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,12 @@ create new colors state object. Paramters:
|
||||
"color by categorical metadata"}
|
||||
- colorAccessor - the obs annotations used for color-by
|
||||
*/
|
||||
export function createColors(world, colorMode = null, colorAccessor = null, userColors = null) {
|
||||
export function createColors(
|
||||
world,
|
||||
colorMode = null,
|
||||
colorAccessor = null,
|
||||
userColors = null
|
||||
) {
|
||||
switch (colorMode) {
|
||||
case "color by categorical metadata": {
|
||||
if (userColors && colorAccessor in userColors) {
|
||||
@@ -33,7 +38,7 @@ export function createColors(world, colorMode = null, colorAccessor = null, user
|
||||
const defaultCellColor = parseRGB(globals.defaultCellColor);
|
||||
return {
|
||||
rgb: new Array(world.nObs).fill(defaultCellColor),
|
||||
scale: undefined
|
||||
scale: undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -41,14 +46,17 @@ export function createColors(world, colorMode = null, colorAccessor = null, user
|
||||
|
||||
export function loadUserColorConfig(userColors) {
|
||||
const convertedUserColors = {};
|
||||
Object.keys(userColors).forEach(category => {
|
||||
const [colors, scaleMap] = Object.keys(userColors[category]).reduce((acc, label, i) => {
|
||||
const color = parseRGB(userColors[category][label]);
|
||||
acc[0][label] = color;
|
||||
acc[1][i] = d3.rgb(255 * color[0], 255 * color[1], 255 * color[2]);
|
||||
return acc;
|
||||
}, [{}, {}]);
|
||||
const scale = i => scaleMap[i];
|
||||
Object.keys(userColors).forEach((category) => {
|
||||
const [colors, scaleMap] = Object.keys(userColors[category]).reduce(
|
||||
(acc, label, i) => {
|
||||
const color = parseRGB(userColors[category][label]);
|
||||
acc[0][label] = color;
|
||||
acc[1][i] = d3.rgb(255 * color[0], 255 * color[1], 255 * color[2]);
|
||||
return acc;
|
||||
},
|
||||
[{}, {}]
|
||||
);
|
||||
const scale = (i) => scaleMap[i];
|
||||
convertedUserColors[category] = { colors, scale };
|
||||
});
|
||||
return convertedUserColors;
|
||||
@@ -147,13 +155,13 @@ function createColorsByExpression(world, accessor) {
|
||||
return { rgb, scale };
|
||||
}
|
||||
|
||||
export const resetColors = world => {
|
||||
export const resetColors = (world) => {
|
||||
const { rgb, scale } = createColors(world);
|
||||
return {
|
||||
colorMode: null,
|
||||
colorAccessor: null,
|
||||
rgb,
|
||||
scale
|
||||
scale,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -165,7 +173,7 @@ export const checkIfColorByDiffexpAndResetColors = (
|
||||
if (prevControls.diffexpGenes.includes(state.colorAccessor)) {
|
||||
return {
|
||||
...state,
|
||||
...resetColors(prevWorld)
|
||||
...resetColors(prevWorld),
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as globals from "../../globals";
|
||||
import { rangeFill as fillRange } from "../range";
|
||||
import {
|
||||
userDefinedDimensionName,
|
||||
diffexpDimensionName
|
||||
diffexpDimensionName,
|
||||
} from "../nameCreators";
|
||||
|
||||
export function maxCategoryItems(config) {
|
||||
@@ -47,7 +47,7 @@ Remember that option values can be ANY js type, except undefined/null.
|
||||
function topNCategories(colSchema, summary, N) {
|
||||
/* return top N by occurrences in the data, preserving original category order */
|
||||
const { categories } = colSchema;
|
||||
const counts = categories.map(cat => summary.categoryCounts.get(cat) ?? 0);
|
||||
const counts = categories.map((cat) => summary.categoryCounts.get(cat) ?? 0);
|
||||
|
||||
if (categories.length <= N) {
|
||||
return [categories, counts];
|
||||
@@ -80,14 +80,14 @@ export function selectableCategoryNames(schema, maxCatItems, names) {
|
||||
const { index, columns } = schema.annotations.obs;
|
||||
|
||||
return columns
|
||||
.filter(colSchema => !names || names.indexOf(colSchema.name) !== -1)
|
||||
.filter(colSchema => {
|
||||
.filter((colSchema) => !names || names.indexOf(colSchema.name) !== -1)
|
||||
.filter((colSchema) => {
|
||||
const { type, name } = colSchema;
|
||||
const isSelectableType =
|
||||
type === "string" || type === "boolean" || type === "categorical";
|
||||
return isSelectableType && name !== index;
|
||||
})
|
||||
.map(v => v.name);
|
||||
.map((v) => v.name);
|
||||
}
|
||||
|
||||
export function createCategoricalSelection(world, names) {
|
||||
@@ -122,7 +122,7 @@ export function createCategoricalSelection(world, names) {
|
||||
isTruncated, // bool: true if list was truncated
|
||||
categoryValueCounts, // array: cardinality of each category,
|
||||
categorySelected: true, // bool - default state for entire category
|
||||
isUserAnno // bool
|
||||
isUserAnno, // bool
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
@@ -70,7 +70,7 @@ export function decodeMatrixFBS(arrayBuffer, inplace = false) {
|
||||
nCols,
|
||||
columns,
|
||||
colIdx,
|
||||
rowIdx: null
|
||||
rowIdx: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -102,9 +102,9 @@ export function encodeMatrixFBS(df) {
|
||||
let encColumns;
|
||||
|
||||
if (shape[0] > 0 && shape[1] > 0) {
|
||||
const columns = df.columns().map(col => col.asArray());
|
||||
const columns = df.columns().map((col) => col.asArray());
|
||||
|
||||
const cols = columns.map(carr => {
|
||||
const cols = columns.map((carr) => {
|
||||
let uType;
|
||||
let tarr;
|
||||
if (isTypedArray(carr)) {
|
||||
|
||||
@@ -10,18 +10,24 @@ var NetEncoding = NetEncoding || {};
|
||||
* @enum
|
||||
*/
|
||||
NetEncoding.TypedArray = {
|
||||
NONE: 0, 0: 'NONE',
|
||||
Float32Array: 1, 1: 'Float32Array',
|
||||
Int32Array: 2, 2: 'Int32Array',
|
||||
Uint32Array: 3, 3: 'Uint32Array',
|
||||
Float64Array: 4, 4: 'Float64Array',
|
||||
JSONEncodedArray: 5, 5: 'JSONEncodedArray'
|
||||
NONE: 0,
|
||||
0: "NONE",
|
||||
Float32Array: 1,
|
||||
1: "Float32Array",
|
||||
Int32Array: 2,
|
||||
2: "Int32Array",
|
||||
Uint32Array: 3,
|
||||
3: "Uint32Array",
|
||||
Float64Array: 4,
|
||||
4: "Float64Array",
|
||||
JSONEncodedArray: 5,
|
||||
5: "JSONEncodedArray",
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
NetEncoding.Float32Array = function() {
|
||||
NetEncoding.Float32Array = function () {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
@@ -38,7 +44,7 @@ NetEncoding.Float32Array = function() {
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @returns {NetEncoding.Float32Array}
|
||||
*/
|
||||
NetEncoding.Float32Array.prototype.__init = function(i, bb) {
|
||||
NetEncoding.Float32Array.prototype.__init = function (i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
@@ -49,23 +55,28 @@ NetEncoding.Float32Array.prototype.__init = function(i, bb) {
|
||||
* @param {NetEncoding.Float32Array=} obj
|
||||
* @returns {NetEncoding.Float32Array}
|
||||
*/
|
||||
NetEncoding.Float32Array.getRootAsFloat32Array = function(bb, obj) {
|
||||
return (obj || new NetEncoding.Float32Array).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
NetEncoding.Float32Array.getRootAsFloat32Array = function (bb, obj) {
|
||||
return (obj || new NetEncoding.Float32Array()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} index
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Float32Array.prototype.data = function(index) {
|
||||
NetEncoding.Float32Array.prototype.data = function (index) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readFloat32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0;
|
||||
return offset
|
||||
? this.bb.readFloat32(this.bb.__vector(this.bb_pos + offset) + index * 4)
|
||||
: 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Float32Array.prototype.dataLength = function() {
|
||||
NetEncoding.Float32Array.prototype.dataLength = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
@@ -73,15 +84,21 @@ NetEncoding.Float32Array.prototype.dataLength = function() {
|
||||
/**
|
||||
* @returns {Float32Array}
|
||||
*/
|
||||
NetEncoding.Float32Array.prototype.dataArray = function() {
|
||||
NetEncoding.Float32Array.prototype.dataArray = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? new Float32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
return offset
|
||||
? new Float32Array(
|
||||
this.bb.bytes().buffer,
|
||||
this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset),
|
||||
this.bb.__vector_len(this.bb_pos + offset)
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
NetEncoding.Float32Array.startFloat32Array = function(builder) {
|
||||
NetEncoding.Float32Array.startFloat32Array = function (builder) {
|
||||
builder.startObject(1);
|
||||
};
|
||||
|
||||
@@ -89,7 +106,7 @@ NetEncoding.Float32Array.startFloat32Array = function(builder) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} dataOffset
|
||||
*/
|
||||
NetEncoding.Float32Array.addData = function(builder, dataOffset) {
|
||||
NetEncoding.Float32Array.addData = function (builder, dataOffset) {
|
||||
builder.addFieldOffset(0, dataOffset, 0);
|
||||
};
|
||||
|
||||
@@ -98,7 +115,7 @@ NetEncoding.Float32Array.addData = function(builder, dataOffset) {
|
||||
* @param {Array.<number>} data
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Float32Array.createDataVector = function(builder, data) {
|
||||
NetEncoding.Float32Array.createDataVector = function (builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
builder.addFloat32(data[i]);
|
||||
@@ -110,7 +127,7 @@ NetEncoding.Float32Array.createDataVector = function(builder, data) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} numElems
|
||||
*/
|
||||
NetEncoding.Float32Array.startDataVector = function(builder, numElems) {
|
||||
NetEncoding.Float32Array.startDataVector = function (builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
};
|
||||
|
||||
@@ -118,7 +135,7 @@ NetEncoding.Float32Array.startDataVector = function(builder, numElems) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Float32Array.endFloat32Array = function(builder) {
|
||||
NetEncoding.Float32Array.endFloat32Array = function (builder) {
|
||||
var offset = builder.endObject();
|
||||
return offset;
|
||||
};
|
||||
@@ -126,7 +143,7 @@ NetEncoding.Float32Array.endFloat32Array = function(builder) {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
NetEncoding.Uint32Array = function() {
|
||||
NetEncoding.Uint32Array = function () {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
@@ -143,7 +160,7 @@ NetEncoding.Uint32Array = function() {
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @returns {NetEncoding.Uint32Array}
|
||||
*/
|
||||
NetEncoding.Uint32Array.prototype.__init = function(i, bb) {
|
||||
NetEncoding.Uint32Array.prototype.__init = function (i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
@@ -154,23 +171,28 @@ NetEncoding.Uint32Array.prototype.__init = function(i, bb) {
|
||||
* @param {NetEncoding.Uint32Array=} obj
|
||||
* @returns {NetEncoding.Uint32Array}
|
||||
*/
|
||||
NetEncoding.Uint32Array.getRootAsUint32Array = function(bb, obj) {
|
||||
return (obj || new NetEncoding.Uint32Array).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
NetEncoding.Uint32Array.getRootAsUint32Array = function (bb, obj) {
|
||||
return (obj || new NetEncoding.Uint32Array()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} index
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Uint32Array.prototype.data = function(index) {
|
||||
NetEncoding.Uint32Array.prototype.data = function (index) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0;
|
||||
return offset
|
||||
? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4)
|
||||
: 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Uint32Array.prototype.dataLength = function() {
|
||||
NetEncoding.Uint32Array.prototype.dataLength = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
@@ -178,15 +200,21 @@ NetEncoding.Uint32Array.prototype.dataLength = function() {
|
||||
/**
|
||||
* @returns {Uint32Array}
|
||||
*/
|
||||
NetEncoding.Uint32Array.prototype.dataArray = function() {
|
||||
NetEncoding.Uint32Array.prototype.dataArray = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? new Uint32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
return offset
|
||||
? new Uint32Array(
|
||||
this.bb.bytes().buffer,
|
||||
this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset),
|
||||
this.bb.__vector_len(this.bb_pos + offset)
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
NetEncoding.Uint32Array.startUint32Array = function(builder) {
|
||||
NetEncoding.Uint32Array.startUint32Array = function (builder) {
|
||||
builder.startObject(1);
|
||||
};
|
||||
|
||||
@@ -194,7 +222,7 @@ NetEncoding.Uint32Array.startUint32Array = function(builder) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} dataOffset
|
||||
*/
|
||||
NetEncoding.Uint32Array.addData = function(builder, dataOffset) {
|
||||
NetEncoding.Uint32Array.addData = function (builder, dataOffset) {
|
||||
builder.addFieldOffset(0, dataOffset, 0);
|
||||
};
|
||||
|
||||
@@ -203,7 +231,7 @@ NetEncoding.Uint32Array.addData = function(builder, dataOffset) {
|
||||
* @param {Array.<number>} data
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Uint32Array.createDataVector = function(builder, data) {
|
||||
NetEncoding.Uint32Array.createDataVector = function (builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt32(data[i]);
|
||||
@@ -215,7 +243,7 @@ NetEncoding.Uint32Array.createDataVector = function(builder, data) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} numElems
|
||||
*/
|
||||
NetEncoding.Uint32Array.startDataVector = function(builder, numElems) {
|
||||
NetEncoding.Uint32Array.startDataVector = function (builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
};
|
||||
|
||||
@@ -223,7 +251,7 @@ NetEncoding.Uint32Array.startDataVector = function(builder, numElems) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Uint32Array.endUint32Array = function(builder) {
|
||||
NetEncoding.Uint32Array.endUint32Array = function (builder) {
|
||||
var offset = builder.endObject();
|
||||
return offset;
|
||||
};
|
||||
@@ -231,7 +259,7 @@ NetEncoding.Uint32Array.endUint32Array = function(builder) {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
NetEncoding.Int32Array = function() {
|
||||
NetEncoding.Int32Array = function () {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
@@ -248,7 +276,7 @@ NetEncoding.Int32Array = function() {
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @returns {NetEncoding.Int32Array}
|
||||
*/
|
||||
NetEncoding.Int32Array.prototype.__init = function(i, bb) {
|
||||
NetEncoding.Int32Array.prototype.__init = function (i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
@@ -259,23 +287,28 @@ NetEncoding.Int32Array.prototype.__init = function(i, bb) {
|
||||
* @param {NetEncoding.Int32Array=} obj
|
||||
* @returns {NetEncoding.Int32Array}
|
||||
*/
|
||||
NetEncoding.Int32Array.getRootAsInt32Array = function(bb, obj) {
|
||||
return (obj || new NetEncoding.Int32Array).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
NetEncoding.Int32Array.getRootAsInt32Array = function (bb, obj) {
|
||||
return (obj || new NetEncoding.Int32Array()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} index
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Int32Array.prototype.data = function(index) {
|
||||
NetEncoding.Int32Array.prototype.data = function (index) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readInt32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0;
|
||||
return offset
|
||||
? this.bb.readInt32(this.bb.__vector(this.bb_pos + offset) + index * 4)
|
||||
: 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Int32Array.prototype.dataLength = function() {
|
||||
NetEncoding.Int32Array.prototype.dataLength = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
@@ -283,15 +316,21 @@ NetEncoding.Int32Array.prototype.dataLength = function() {
|
||||
/**
|
||||
* @returns {Int32Array}
|
||||
*/
|
||||
NetEncoding.Int32Array.prototype.dataArray = function() {
|
||||
NetEncoding.Int32Array.prototype.dataArray = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? new Int32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
return offset
|
||||
? new Int32Array(
|
||||
this.bb.bytes().buffer,
|
||||
this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset),
|
||||
this.bb.__vector_len(this.bb_pos + offset)
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
NetEncoding.Int32Array.startInt32Array = function(builder) {
|
||||
NetEncoding.Int32Array.startInt32Array = function (builder) {
|
||||
builder.startObject(1);
|
||||
};
|
||||
|
||||
@@ -299,7 +338,7 @@ NetEncoding.Int32Array.startInt32Array = function(builder) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} dataOffset
|
||||
*/
|
||||
NetEncoding.Int32Array.addData = function(builder, dataOffset) {
|
||||
NetEncoding.Int32Array.addData = function (builder, dataOffset) {
|
||||
builder.addFieldOffset(0, dataOffset, 0);
|
||||
};
|
||||
|
||||
@@ -308,7 +347,7 @@ NetEncoding.Int32Array.addData = function(builder, dataOffset) {
|
||||
* @param {Array.<number>} data
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Int32Array.createDataVector = function(builder, data) {
|
||||
NetEncoding.Int32Array.createDataVector = function (builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt32(data[i]);
|
||||
@@ -320,7 +359,7 @@ NetEncoding.Int32Array.createDataVector = function(builder, data) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} numElems
|
||||
*/
|
||||
NetEncoding.Int32Array.startDataVector = function(builder, numElems) {
|
||||
NetEncoding.Int32Array.startDataVector = function (builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
};
|
||||
|
||||
@@ -328,7 +367,7 @@ NetEncoding.Int32Array.startDataVector = function(builder, numElems) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Int32Array.endInt32Array = function(builder) {
|
||||
NetEncoding.Int32Array.endInt32Array = function (builder) {
|
||||
var offset = builder.endObject();
|
||||
return offset;
|
||||
};
|
||||
@@ -336,7 +375,7 @@ NetEncoding.Int32Array.endInt32Array = function(builder) {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
NetEncoding.Float64Array = function() {
|
||||
NetEncoding.Float64Array = function () {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
@@ -353,7 +392,7 @@ NetEncoding.Float64Array = function() {
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @returns {NetEncoding.Float64Array}
|
||||
*/
|
||||
NetEncoding.Float64Array.prototype.__init = function(i, bb) {
|
||||
NetEncoding.Float64Array.prototype.__init = function (i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
@@ -364,23 +403,28 @@ NetEncoding.Float64Array.prototype.__init = function(i, bb) {
|
||||
* @param {NetEncoding.Float64Array=} obj
|
||||
* @returns {NetEncoding.Float64Array}
|
||||
*/
|
||||
NetEncoding.Float64Array.getRootAsFloat64Array = function(bb, obj) {
|
||||
return (obj || new NetEncoding.Float64Array).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
NetEncoding.Float64Array.getRootAsFloat64Array = function (bb, obj) {
|
||||
return (obj || new NetEncoding.Float64Array()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} index
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Float64Array.prototype.data = function(index) {
|
||||
NetEncoding.Float64Array.prototype.data = function (index) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0;
|
||||
return offset
|
||||
? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8)
|
||||
: 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Float64Array.prototype.dataLength = function() {
|
||||
NetEncoding.Float64Array.prototype.dataLength = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
@@ -388,15 +432,21 @@ NetEncoding.Float64Array.prototype.dataLength = function() {
|
||||
/**
|
||||
* @returns {Float64Array}
|
||||
*/
|
||||
NetEncoding.Float64Array.prototype.dataArray = function() {
|
||||
NetEncoding.Float64Array.prototype.dataArray = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
return offset
|
||||
? new Float64Array(
|
||||
this.bb.bytes().buffer,
|
||||
this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset),
|
||||
this.bb.__vector_len(this.bb_pos + offset)
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
NetEncoding.Float64Array.startFloat64Array = function(builder) {
|
||||
NetEncoding.Float64Array.startFloat64Array = function (builder) {
|
||||
builder.startObject(1);
|
||||
};
|
||||
|
||||
@@ -404,7 +454,7 @@ NetEncoding.Float64Array.startFloat64Array = function(builder) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} dataOffset
|
||||
*/
|
||||
NetEncoding.Float64Array.addData = function(builder, dataOffset) {
|
||||
NetEncoding.Float64Array.addData = function (builder, dataOffset) {
|
||||
builder.addFieldOffset(0, dataOffset, 0);
|
||||
};
|
||||
|
||||
@@ -413,7 +463,7 @@ NetEncoding.Float64Array.addData = function(builder, dataOffset) {
|
||||
* @param {Array.<number>} data
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Float64Array.createDataVector = function(builder, data) {
|
||||
NetEncoding.Float64Array.createDataVector = function (builder, data) {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
builder.addFloat64(data[i]);
|
||||
@@ -425,7 +475,7 @@ NetEncoding.Float64Array.createDataVector = function(builder, data) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} numElems
|
||||
*/
|
||||
NetEncoding.Float64Array.startDataVector = function(builder, numElems) {
|
||||
NetEncoding.Float64Array.startDataVector = function (builder, numElems) {
|
||||
builder.startVector(8, numElems, 8);
|
||||
};
|
||||
|
||||
@@ -433,7 +483,7 @@ NetEncoding.Float64Array.startDataVector = function(builder, numElems) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Float64Array.endFloat64Array = function(builder) {
|
||||
NetEncoding.Float64Array.endFloat64Array = function (builder) {
|
||||
var offset = builder.endObject();
|
||||
return offset;
|
||||
};
|
||||
@@ -441,7 +491,7 @@ NetEncoding.Float64Array.endFloat64Array = function(builder) {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray = function() {
|
||||
NetEncoding.JSONEncodedArray = function () {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
@@ -458,7 +508,7 @@ NetEncoding.JSONEncodedArray = function() {
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @returns {NetEncoding.JSONEncodedArray}
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.prototype.__init = function(i, bb) {
|
||||
NetEncoding.JSONEncodedArray.prototype.__init = function (i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
@@ -469,23 +519,28 @@ NetEncoding.JSONEncodedArray.prototype.__init = function(i, bb) {
|
||||
* @param {NetEncoding.JSONEncodedArray=} obj
|
||||
* @returns {NetEncoding.JSONEncodedArray}
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.getRootAsJSONEncodedArray = function(bb, obj) {
|
||||
return (obj || new NetEncoding.JSONEncodedArray).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
NetEncoding.JSONEncodedArray.getRootAsJSONEncodedArray = function (bb, obj) {
|
||||
return (obj || new NetEncoding.JSONEncodedArray()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} index
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.prototype.data = function(index) {
|
||||
NetEncoding.JSONEncodedArray.prototype.data = function (index) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
|
||||
return offset
|
||||
? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index)
|
||||
: 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.prototype.dataLength = function() {
|
||||
NetEncoding.JSONEncodedArray.prototype.dataLength = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
@@ -493,15 +548,21 @@ NetEncoding.JSONEncodedArray.prototype.dataLength = function() {
|
||||
/**
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.prototype.dataArray = function() {
|
||||
NetEncoding.JSONEncodedArray.prototype.dataArray = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
return offset
|
||||
? new Uint8Array(
|
||||
this.bb.bytes().buffer,
|
||||
this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset),
|
||||
this.bb.__vector_len(this.bb_pos + offset)
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.startJSONEncodedArray = function(builder) {
|
||||
NetEncoding.JSONEncodedArray.startJSONEncodedArray = function (builder) {
|
||||
builder.startObject(1);
|
||||
};
|
||||
|
||||
@@ -509,7 +570,7 @@ NetEncoding.JSONEncodedArray.startJSONEncodedArray = function(builder) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} dataOffset
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.addData = function(builder, dataOffset) {
|
||||
NetEncoding.JSONEncodedArray.addData = function (builder, dataOffset) {
|
||||
builder.addFieldOffset(0, dataOffset, 0);
|
||||
};
|
||||
|
||||
@@ -518,7 +579,7 @@ NetEncoding.JSONEncodedArray.addData = function(builder, dataOffset) {
|
||||
* @param {Array.<number>} data
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.createDataVector = function(builder, data) {
|
||||
NetEncoding.JSONEncodedArray.createDataVector = function (builder, data) {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
@@ -530,7 +591,7 @@ NetEncoding.JSONEncodedArray.createDataVector = function(builder, data) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} numElems
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.startDataVector = function(builder, numElems) {
|
||||
NetEncoding.JSONEncodedArray.startDataVector = function (builder, numElems) {
|
||||
builder.startVector(1, numElems, 1);
|
||||
};
|
||||
|
||||
@@ -538,7 +599,7 @@ NetEncoding.JSONEncodedArray.startDataVector = function(builder, numElems) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.JSONEncodedArray.endJSONEncodedArray = function(builder) {
|
||||
NetEncoding.JSONEncodedArray.endJSONEncodedArray = function (builder) {
|
||||
var offset = builder.endObject();
|
||||
return offset;
|
||||
};
|
||||
@@ -546,7 +607,7 @@ NetEncoding.JSONEncodedArray.endJSONEncodedArray = function(builder) {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
NetEncoding.Column = function() {
|
||||
NetEncoding.Column = function () {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
@@ -563,7 +624,7 @@ NetEncoding.Column = function() {
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @returns {NetEncoding.Column}
|
||||
*/
|
||||
NetEncoding.Column.prototype.__init = function(i, bb) {
|
||||
NetEncoding.Column.prototype.__init = function (i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
@@ -574,23 +635,30 @@ NetEncoding.Column.prototype.__init = function(i, bb) {
|
||||
* @param {NetEncoding.Column=} obj
|
||||
* @returns {NetEncoding.Column}
|
||||
*/
|
||||
NetEncoding.Column.getRootAsColumn = function(bb, obj) {
|
||||
return (obj || new NetEncoding.Column).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
NetEncoding.Column.getRootAsColumn = function (bb, obj) {
|
||||
return (obj || new NetEncoding.Column()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {NetEncoding.TypedArray}
|
||||
*/
|
||||
NetEncoding.Column.prototype.uType = function() {
|
||||
NetEncoding.Column.prototype.uType = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? /** @type {NetEncoding.TypedArray} */ (this.bb.readUint8(this.bb_pos + offset)) : NetEncoding.TypedArray.NONE;
|
||||
return offset
|
||||
? /** @type {NetEncoding.TypedArray} */ (this.bb.readUint8(
|
||||
this.bb_pos + offset
|
||||
))
|
||||
: NetEncoding.TypedArray.NONE;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Table} obj
|
||||
* @returns {?flatbuffers.Table}
|
||||
*/
|
||||
NetEncoding.Column.prototype.u = function(obj) {
|
||||
NetEncoding.Column.prototype.u = function (obj) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
|
||||
};
|
||||
@@ -598,7 +666,7 @@ NetEncoding.Column.prototype.u = function(obj) {
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
NetEncoding.Column.startColumn = function(builder) {
|
||||
NetEncoding.Column.startColumn = function (builder) {
|
||||
builder.startObject(2);
|
||||
};
|
||||
|
||||
@@ -606,7 +674,7 @@ NetEncoding.Column.startColumn = function(builder) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {NetEncoding.TypedArray} uType
|
||||
*/
|
||||
NetEncoding.Column.addUType = function(builder, uType) {
|
||||
NetEncoding.Column.addUType = function (builder, uType) {
|
||||
builder.addFieldInt8(0, uType, NetEncoding.TypedArray.NONE);
|
||||
};
|
||||
|
||||
@@ -614,7 +682,7 @@ NetEncoding.Column.addUType = function(builder, uType) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} uOffset
|
||||
*/
|
||||
NetEncoding.Column.addU = function(builder, uOffset) {
|
||||
NetEncoding.Column.addU = function (builder, uOffset) {
|
||||
builder.addFieldOffset(1, uOffset, 0);
|
||||
};
|
||||
|
||||
@@ -622,7 +690,7 @@ NetEncoding.Column.addU = function(builder, uOffset) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Column.endColumn = function(builder) {
|
||||
NetEncoding.Column.endColumn = function (builder) {
|
||||
var offset = builder.endObject();
|
||||
return offset;
|
||||
};
|
||||
@@ -630,7 +698,7 @@ NetEncoding.Column.endColumn = function(builder) {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
NetEncoding.Matrix = function() {
|
||||
NetEncoding.Matrix = function () {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
@@ -647,7 +715,7 @@ NetEncoding.Matrix = function() {
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @returns {NetEncoding.Matrix}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.__init = function(i, bb) {
|
||||
NetEncoding.Matrix.prototype.__init = function (i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
@@ -658,14 +726,17 @@ NetEncoding.Matrix.prototype.__init = function(i, bb) {
|
||||
* @param {NetEncoding.Matrix=} obj
|
||||
* @returns {NetEncoding.Matrix}
|
||||
*/
|
||||
NetEncoding.Matrix.getRootAsMatrix = function(bb, obj) {
|
||||
return (obj || new NetEncoding.Matrix).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
NetEncoding.Matrix.getRootAsMatrix = function (bb, obj) {
|
||||
return (obj || new NetEncoding.Matrix()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.nRows = function() {
|
||||
NetEncoding.Matrix.prototype.nRows = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
|
||||
};
|
||||
@@ -673,7 +744,7 @@ NetEncoding.Matrix.prototype.nRows = function() {
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.nCols = function() {
|
||||
NetEncoding.Matrix.prototype.nCols = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
|
||||
};
|
||||
@@ -683,15 +754,20 @@ NetEncoding.Matrix.prototype.nCols = function() {
|
||||
* @param {NetEncoding.Column=} obj
|
||||
* @returns {NetEncoding.Column}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.columns = function(index, obj) {
|
||||
NetEncoding.Matrix.prototype.columns = function (index, obj) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? (obj || new NetEncoding.Column).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
|
||||
return offset
|
||||
? (obj || new NetEncoding.Column()).__init(
|
||||
this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4),
|
||||
this.bb
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.columnsLength = function() {
|
||||
NetEncoding.Matrix.prototype.columnsLength = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
@@ -699,16 +775,20 @@ NetEncoding.Matrix.prototype.columnsLength = function() {
|
||||
/**
|
||||
* @returns {NetEncoding.TypedArray}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.colIndexType = function() {
|
||||
NetEncoding.Matrix.prototype.colIndexType = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 10);
|
||||
return offset ? /** @type {NetEncoding.TypedArray} */ (this.bb.readUint8(this.bb_pos + offset)) : NetEncoding.TypedArray.NONE;
|
||||
return offset
|
||||
? /** @type {NetEncoding.TypedArray} */ (this.bb.readUint8(
|
||||
this.bb_pos + offset
|
||||
))
|
||||
: NetEncoding.TypedArray.NONE;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Table} obj
|
||||
* @returns {?flatbuffers.Table}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.colIndex = function(obj) {
|
||||
NetEncoding.Matrix.prototype.colIndex = function (obj) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 12);
|
||||
return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
|
||||
};
|
||||
@@ -716,16 +796,20 @@ NetEncoding.Matrix.prototype.colIndex = function(obj) {
|
||||
/**
|
||||
* @returns {NetEncoding.TypedArray}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.rowIndexType = function() {
|
||||
NetEncoding.Matrix.prototype.rowIndexType = function () {
|
||||
var offset = this.bb.__offset(this.bb_pos, 14);
|
||||
return offset ? /** @type {NetEncoding.TypedArray} */ (this.bb.readUint8(this.bb_pos + offset)) : NetEncoding.TypedArray.NONE;
|
||||
return offset
|
||||
? /** @type {NetEncoding.TypedArray} */ (this.bb.readUint8(
|
||||
this.bb_pos + offset
|
||||
))
|
||||
: NetEncoding.TypedArray.NONE;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Table} obj
|
||||
* @returns {?flatbuffers.Table}
|
||||
*/
|
||||
NetEncoding.Matrix.prototype.rowIndex = function(obj) {
|
||||
NetEncoding.Matrix.prototype.rowIndex = function (obj) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 16);
|
||||
return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
|
||||
};
|
||||
@@ -733,7 +817,7 @@ NetEncoding.Matrix.prototype.rowIndex = function(obj) {
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
NetEncoding.Matrix.startMatrix = function(builder) {
|
||||
NetEncoding.Matrix.startMatrix = function (builder) {
|
||||
builder.startObject(7);
|
||||
};
|
||||
|
||||
@@ -741,7 +825,7 @@ NetEncoding.Matrix.startMatrix = function(builder) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} nRows
|
||||
*/
|
||||
NetEncoding.Matrix.addNRows = function(builder, nRows) {
|
||||
NetEncoding.Matrix.addNRows = function (builder, nRows) {
|
||||
builder.addFieldInt32(0, nRows, 0);
|
||||
};
|
||||
|
||||
@@ -749,7 +833,7 @@ NetEncoding.Matrix.addNRows = function(builder, nRows) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} nCols
|
||||
*/
|
||||
NetEncoding.Matrix.addNCols = function(builder, nCols) {
|
||||
NetEncoding.Matrix.addNCols = function (builder, nCols) {
|
||||
builder.addFieldInt32(1, nCols, 0);
|
||||
};
|
||||
|
||||
@@ -757,7 +841,7 @@ NetEncoding.Matrix.addNCols = function(builder, nCols) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} columnsOffset
|
||||
*/
|
||||
NetEncoding.Matrix.addColumns = function(builder, columnsOffset) {
|
||||
NetEncoding.Matrix.addColumns = function (builder, columnsOffset) {
|
||||
builder.addFieldOffset(2, columnsOffset, 0);
|
||||
};
|
||||
|
||||
@@ -766,7 +850,7 @@ NetEncoding.Matrix.addColumns = function(builder, columnsOffset) {
|
||||
* @param {Array.<flatbuffers.Offset>} data
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Matrix.createColumnsVector = function(builder, data) {
|
||||
NetEncoding.Matrix.createColumnsVector = function (builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
@@ -778,7 +862,7 @@ NetEncoding.Matrix.createColumnsVector = function(builder, data) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} numElems
|
||||
*/
|
||||
NetEncoding.Matrix.startColumnsVector = function(builder, numElems) {
|
||||
NetEncoding.Matrix.startColumnsVector = function (builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
};
|
||||
|
||||
@@ -786,7 +870,7 @@ NetEncoding.Matrix.startColumnsVector = function(builder, numElems) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {NetEncoding.TypedArray} colIndexType
|
||||
*/
|
||||
NetEncoding.Matrix.addColIndexType = function(builder, colIndexType) {
|
||||
NetEncoding.Matrix.addColIndexType = function (builder, colIndexType) {
|
||||
builder.addFieldInt8(3, colIndexType, NetEncoding.TypedArray.NONE);
|
||||
};
|
||||
|
||||
@@ -794,7 +878,7 @@ NetEncoding.Matrix.addColIndexType = function(builder, colIndexType) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} colIndexOffset
|
||||
*/
|
||||
NetEncoding.Matrix.addColIndex = function(builder, colIndexOffset) {
|
||||
NetEncoding.Matrix.addColIndex = function (builder, colIndexOffset) {
|
||||
builder.addFieldOffset(4, colIndexOffset, 0);
|
||||
};
|
||||
|
||||
@@ -802,7 +886,7 @@ NetEncoding.Matrix.addColIndex = function(builder, colIndexOffset) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {NetEncoding.TypedArray} rowIndexType
|
||||
*/
|
||||
NetEncoding.Matrix.addRowIndexType = function(builder, rowIndexType) {
|
||||
NetEncoding.Matrix.addRowIndexType = function (builder, rowIndexType) {
|
||||
builder.addFieldInt8(5, rowIndexType, NetEncoding.TypedArray.NONE);
|
||||
};
|
||||
|
||||
@@ -810,7 +894,7 @@ NetEncoding.Matrix.addRowIndexType = function(builder, rowIndexType) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} rowIndexOffset
|
||||
*/
|
||||
NetEncoding.Matrix.addRowIndex = function(builder, rowIndexOffset) {
|
||||
NetEncoding.Matrix.addRowIndex = function (builder, rowIndexOffset) {
|
||||
builder.addFieldOffset(6, rowIndexOffset, 0);
|
||||
};
|
||||
|
||||
@@ -818,7 +902,7 @@ NetEncoding.Matrix.addRowIndex = function(builder, rowIndexOffset) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
NetEncoding.Matrix.endMatrix = function(builder) {
|
||||
NetEncoding.Matrix.endMatrix = function (builder) {
|
||||
var offset = builder.endObject();
|
||||
return offset;
|
||||
};
|
||||
@@ -827,9 +911,9 @@ NetEncoding.Matrix.endMatrix = function(builder) {
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} offset
|
||||
*/
|
||||
NetEncoding.Matrix.finishMatrixBuffer = function(builder, offset) {
|
||||
NetEncoding.Matrix.finishMatrixBuffer = function (builder, offset) {
|
||||
builder.finish(offset);
|
||||
};
|
||||
|
||||
// Exports for ECMAScript6 Modules
|
||||
export {NetEncoding};
|
||||
export { NetEncoding };
|
||||
|
||||
@@ -19,16 +19,16 @@ System wide schema assumptions:
|
||||
export function indexEntireSchema(schema) {
|
||||
/* Index schema for ease of use */
|
||||
schema.annotations.obsByName = fromEntries(
|
||||
schema.annotations.obs.columns.map(v => [v.name, v])
|
||||
schema.annotations.obs.columns.map((v) => [v.name, v])
|
||||
);
|
||||
schema.annotations.varByName = fromEntries(
|
||||
schema.annotations.var.columns.map(v => [v.name, v])
|
||||
schema.annotations.var.columns.map((v) => [v.name, v])
|
||||
);
|
||||
schema.layout.obsByName = fromEntries(
|
||||
schema.layout.obs.map(v => [v.name, v])
|
||||
schema.layout.obs.map((v) => [v.name, v])
|
||||
);
|
||||
schema.layout.varByName = fromEntries(
|
||||
schema.layout.var.map(v => [v.name, v])
|
||||
schema.layout.var.map((v) => [v.name, v])
|
||||
);
|
||||
|
||||
return schema;
|
||||
@@ -40,8 +40,8 @@ function _copyObsAnno(schema) {
|
||||
...schema,
|
||||
annotations: {
|
||||
...schema.annotations,
|
||||
obs: _.cloneDeep(schema.annotations.obs)
|
||||
}
|
||||
obs: _.cloneDeep(schema.annotations.obs),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -50,22 +50,22 @@ function _copyObsLayout(schema) {
|
||||
...schema,
|
||||
layout: {
|
||||
...schema.layout,
|
||||
obs: _.cloneDeep(schema.layout.obs)
|
||||
}
|
||||
obs: _.cloneDeep(schema.layout.obs),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function _reindexObsAnno(schema) {
|
||||
/* reindex obs annotations ONLY */
|
||||
schema.annotations.obsByName = fromEntries(
|
||||
schema.annotations.obs.columns.map(v => [v.name, v])
|
||||
schema.annotations.obs.columns.map((v) => [v.name, v])
|
||||
);
|
||||
return schema;
|
||||
}
|
||||
|
||||
function _reindexObsLayout(schema) {
|
||||
schema.layout.obsByName = fromEntries(
|
||||
schema.layout.obs.map(v => [v.name, v])
|
||||
schema.layout.obs.map((v) => [v.name, v])
|
||||
);
|
||||
return schema;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ function _reindexObsLayout(schema) {
|
||||
export function removeObsAnnoColumn(schema, name) {
|
||||
const newSchema = _copyObsAnno(schema);
|
||||
newSchema.annotations.obs.columns = schema.annotations.obs.columns.filter(
|
||||
v => v.name !== name
|
||||
(v) => v.name !== name
|
||||
);
|
||||
return _reindexObsAnno(newSchema);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ export function addObsAnnoCategory(schema, name, category) {
|
||||
const catAnno = newSchema.annotations.obsByName[name];
|
||||
catAnno.categories = catLabelSort(catAnno.writable, [
|
||||
...catAnno.categories,
|
||||
category
|
||||
category,
|
||||
]);
|
||||
return newSchema;
|
||||
}
|
||||
@@ -130,6 +130,6 @@ export function addObsLayout(schema, layout) {
|
||||
export function removeObsLayout(schema, name) {
|
||||
/* remove a layout */
|
||||
const newSchema = _copyObsLayout(schema);
|
||||
newSchema.layout.obs = schema.layout.obs.filter(v => v.name !== name);
|
||||
newSchema.layout.obs = schema.layout.obs.filter((v) => v.name !== name);
|
||||
return _reindexObsLayout(newSchema);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ function templateUniverse() {
|
||||
/*
|
||||
Var data columns - subset of all
|
||||
*/
|
||||
varData: Dataframe.Dataframe.empty(null, new Dataframe.KeyIndex())
|
||||
varData: Dataframe.Dataframe.empty(null, new Dataframe.KeyIndex()),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -91,22 +91,22 @@ export function matrixFBSToDataframe(arrayBuffers) {
|
||||
return Dataframe.Dataframe.empty();
|
||||
}
|
||||
|
||||
const fbs = arrayBuffers.map(ab => decodeMatrixFBS(ab, true)); // leave in place
|
||||
const fbs = arrayBuffers.map((ab) => decodeMatrixFBS(ab, true)); // leave in place
|
||||
/* check that all FBS have same row dimensionality */
|
||||
const { nRows } = fbs[0];
|
||||
fbs.forEach(b => {
|
||||
fbs.forEach((b) => {
|
||||
if (b.nRows !== nRows)
|
||||
throw new Error("FBS with inconsistent dimensionality");
|
||||
});
|
||||
const columns = fbs
|
||||
.map(fb =>
|
||||
fb.columns.map(c => {
|
||||
.map((fb) =>
|
||||
fb.columns.map((c) => {
|
||||
if (isFpTypedArray(c) || Array.isArray(c)) return c;
|
||||
return promoteTypedArray(c);
|
||||
})
|
||||
)
|
||||
.flat();
|
||||
const colIdx = fbs.map(b => b.colIdx).flat();
|
||||
const colIdx = fbs.map((b) => b.colIdx).flat();
|
||||
const nCols = columns.length;
|
||||
|
||||
const df = new Dataframe.Dataframe(
|
||||
@@ -145,8 +145,8 @@ function normalizeSchemaCategory(colSchema, col = undefined) {
|
||||
let categories = [
|
||||
...new Set([
|
||||
...(colSchema.categories ?? []),
|
||||
...(col?.summarize?.().categories ?? [])
|
||||
])
|
||||
...(col?.summarize?.().categories ?? []),
|
||||
]),
|
||||
];
|
||||
if (writable && categories.indexOf(unassignedCategoryLabel) === -1) {
|
||||
categories = categories.concat(unassignedCategoryLabel);
|
||||
@@ -165,7 +165,7 @@ function normalizeSchemaCategory(colSchema, col = undefined) {
|
||||
|
||||
function normalizeEntireSchema(schema) {
|
||||
// currently only needed for obsAnnotations
|
||||
schema.annotations.obs.columns.forEach(colSchema =>
|
||||
schema.annotations.obs.columns.forEach((colSchema) =>
|
||||
normalizeSchemaCategory(colSchema)
|
||||
);
|
||||
}
|
||||
@@ -178,9 +178,9 @@ export function addObsAnnotations(universe, df) {
|
||||
|
||||
// for all of the new data, reconcile with schema and sort categories.
|
||||
const dfs = Array.isArray(df) ? df : [df];
|
||||
const keys = dfs.map(d => d.colIndex.keys()).flat();
|
||||
const keys = dfs.map((d) => d.colIndex.keys()).flat();
|
||||
const { schema } = universe;
|
||||
keys.forEach(k => {
|
||||
keys.forEach((k) => {
|
||||
const colSchema = schema.annotations.obsByName[k];
|
||||
const col = obsAnnotations.col(k);
|
||||
normalizeSchemaCategory(colSchema, col);
|
||||
|
||||
@@ -69,8 +69,8 @@ function templateWorld() {
|
||||
/* unclipped dataframes - subset, but not value clipped */
|
||||
unclipped: {
|
||||
obsAnnotations,
|
||||
varData
|
||||
}
|
||||
varData,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ export function createWorldFromEntireUniverse(universe) {
|
||||
/* save unclipped copies of potentially clipped dataframes */
|
||||
world.unclipped = {
|
||||
obsAnnotations: world.obsAnnotations.clone(),
|
||||
varData: world.varData.clone()
|
||||
varData: world.varData.clone(),
|
||||
};
|
||||
|
||||
return world;
|
||||
@@ -219,7 +219,7 @@ export function createWorldWithNewClip(
|
||||
newWorld.obsLayout = world.obsLayout.clone();
|
||||
newWorld.unclipped = {
|
||||
obsAnnotations: world.unclipped.obsAnnotations.clone(),
|
||||
varData: world.unclipped.varData.clone()
|
||||
varData: world.unclipped.varData.clone(),
|
||||
};
|
||||
|
||||
/* and now clip */
|
||||
@@ -295,7 +295,7 @@ export function createObsDimensions(crossfilter, world, XYdimNames) {
|
||||
const { schema, obsLayout } = world;
|
||||
const indexName = schema.annotations.obs.index;
|
||||
const annoList = schema.annotations.obs.columns.filter(
|
||||
anno => anno.name !== indexName
|
||||
(anno) => anno.name !== indexName
|
||||
);
|
||||
crossfilter = annoList.reduce((xfltr, anno) => {
|
||||
return addObsDimension(xfltr, world, anno);
|
||||
|
||||
Reference in New Issue
Block a user