| 283 | } |
| 284 | |
| 285 | function assertLabelsMatchShape( |
| 286 | inputValues: number[][]|tf.Tensor2D, labels: string[], dimension: 0|1) { |
| 287 | const shape = inputValues instanceof tf.Tensor ? |
| 288 | inputValues.shape : |
| 289 | [inputValues.length, inputValues[0].length]; |
| 290 | if (dimension === 0) { |
| 291 | assert( |
| 292 | shape[0] === labels.length, |
| 293 | `Length of xTickLabels (${labels.length}) must match number of rows` + |
| 294 | ` (${shape[0]})`); |
| 295 | } else if (dimension === 1) { |
| 296 | assert( |
| 297 | shape[1] === labels.length, |
| 298 | `Length of yTickLabels (${ |
| 299 | labels.length}) must match number of columns (${shape[1]})`); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | const defaultOpts: HeatmapOptions = { |
| 304 | xLabel: null, |