MCPcopy
hub / github.com/tensorflow/tfjs / prepareData

Function prepareData

tfjs-vis/src/render/histogram.ts:203–224  ·  view source on GitHub ↗

* Formats data to the internal format used by this chart.

(data: Array<{value: number}>|number[]|
                     TypedArray)

Source from the content-addressed store, hash-verified

201 * Formats data to the internal format used by this chart.
202 */
203function prepareData(data: Array<{value: number}>|number[]|
204 TypedArray): Array<{value: number}> {
205 if (data.length == null) {
206 throw new Error('input data must be an array');
207 }
208
209 if (data.length === 0) {
210 return [];
211 } else if (typeof data[0] === 'object') {
212 if ((data[0] as {value: number}).value == null) {
213 throw new Error('input data must have a value field');
214 } else {
215 return data as Array<{value: number}>;
216 }
217 } else {
218 const ret = Array(data.length);
219 for (let i = 0; i < data.length; i++) {
220 ret[i] = {value: data[i]};
221 }
222 return ret;
223 }
224}

Callers 1

histogramFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…