MCPcopy Index your code
hub / github.com/tensorflow/tfjs / assertPositiveInteger

Function assertPositiveInteger

tfjs-layers/src/utils/generic_utils.ts:441–453  ·  view source on GitHub ↗
(value: number|number[], name: string)

Source from the content-addressed store, hash-verified

439 * @param name Name of the value, used to make the error message.
440 */
441export function assertPositiveInteger(value: number|number[], name: string) {
442 if (Array.isArray(value)) {
443 util.assert(
444 value.length > 0, () => `${name} is unexpectedly an empty array.`);
445 value.forEach(
446 (v, i) => assertPositiveInteger(v, `element ${i + 1} of ${name}`));
447 } else {
448 util.assert(
449 Number.isInteger(value) && value > 0,
450 () => `Expected ${name} to be a positive integer, but got ` +
451 `${formatAsFriendlyString(value)}.`);
452 }
453}
454
455/**
456 * Format a value into a display-friendly, human-readable fashion.

Callers 6

constructorMethod · 0.90
constructorMethod · 0.90
constructorFunction · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90

Calls 1

formatAsFriendlyStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…